diff --git a/app/Console/Commands/Database/MigrateLibraryItemSlugs.php b/app/Console/Commands/Database/MigrateLibraryItemSlugs.php new file mode 100644 index 00000000..4575a899 --- /dev/null +++ b/app/Console/Commands/Database/MigrateLibraryItemSlugs.php @@ -0,0 +1,38 @@ +slug = str($item->name)->slug('-', 'de'); + $item->save(); + } + + return Command::SUCCESS; + } +} diff --git a/app/Http/Livewire/News/ArticleOverview.php b/app/Http/Livewire/News/ArticleOverview.php new file mode 100644 index 00000000..f93df79c --- /dev/null +++ b/app/Http/Livewire/News/ArticleOverview.php @@ -0,0 +1,32 @@ + LibraryItem::query() + ->with([ + 'createdBy.roles', + 'lecturer', + 'tags', + ]) + ->where('type', 'markdown_article') + ->whereHas('createdBy.roles', + fn($query) => $query->where('roles.name', 'news-editor')) + ->get(), + ])->layout('layouts.app', [ + 'SEOData' => new SEOData( + title: __('News'), + description: __('Here we post important news that is relevant for everyone.'), + image: asset('img/einundzwanzig-wallpaper-benrath.png'), + ) + ]); + } +} diff --git a/app/Http/Livewire/News/InternArticleView.php b/app/Http/Livewire/News/InternArticleView.php new file mode 100644 index 00000000..7afd1b93 --- /dev/null +++ b/app/Http/Livewire/News/InternArticleView.php @@ -0,0 +1,27 @@ +layout('layouts.app', [ + 'SEOData' => new SEOData( + title: $this->libraryItem->name, + description: $this->libraryItem->excerpt ?? __('Here we post important news that is relevant for everyone.'), + author: $this->libraryItem->lecturer->name, + image: asset('img/einundzwanzig-wallpaper-benrath.png'), + published_time: Carbon::parse($this->libraryItem->created_at), + type: 'article', + ) + ]); + } +} diff --git a/app/Models/City.php b/app/Models/City.php index 2f0f9cb3..576af044 100644 --- a/app/Models/City.php +++ b/app/Models/City.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Facades\Cookie; use Spatie\Sluggable\HasSlug; use Spatie\Sluggable\SlugOptions; @@ -48,7 +49,7 @@ class City extends Model return SlugOptions::create() ->generateSlugsFrom(['country.code', 'name']) ->saveSlugsTo('slug') - ->usingLanguage('de'); + ->usingLanguage(Cookie::get('lang', config('app.locale'))); } public function createdBy(): BelongsTo diff --git a/app/Models/Lecturer.php b/app/Models/Lecturer.php index 1c57e361..8a8fdc85 100644 --- a/app/Models/Lecturer.php +++ b/app/Models/Lecturer.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; +use Illuminate\Support\Facades\Cookie; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -76,7 +77,7 @@ class Lecturer extends Model implements HasMedia return SlugOptions::create() ->generateSlugsFrom(['name']) ->saveSlugsTo('slug') - ->usingLanguage('de'); + ->usingLanguage(Cookie::get('lang', config('app.locale'))); } public function createdBy(): BelongsTo diff --git a/app/Models/LibraryItem.php b/app/Models/LibraryItem.php index de9d7cd5..5e3a7e0e 100644 --- a/app/Models/LibraryItem.php +++ b/app/Models/LibraryItem.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Support\Facades\Cookie; use Spatie\EloquentSortable\Sortable; use Spatie\EloquentSortable\SortableTrait; use Spatie\Image\Manipulations; @@ -12,6 +13,8 @@ use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; use Spatie\ModelStatus\HasStatuses; +use Spatie\Sluggable\HasSlug; +use Spatie\Sluggable\SlugOptions; use Spatie\Tags\HasTags; class LibraryItem extends Model implements HasMedia, Sortable @@ -20,6 +23,7 @@ class LibraryItem extends Model implements HasMedia, Sortable use HasTags; use SortableTrait; use HasStatuses; + use HasSlug; /** * The attributes that aren't mass assignable. @@ -37,6 +41,14 @@ class LibraryItem extends Model implements HasMedia, Sortable 'library_id' => 'integer', ]; + public function getSlugOptions(): SlugOptions + { + return SlugOptions::create() + ->generateSlugsFrom(['name']) + ->saveSlugsTo('slug') + ->usingLanguage(Cookie::get('lang', config('app.locale'))); + } + protected static function booted() { static::creating(function ($model) { diff --git a/app/Models/Meetup.php b/app/Models/Meetup.php index 358dfea1..5f5dd6a4 100644 --- a/app/Models/Meetup.php +++ b/app/Models/Meetup.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Facades\Cookie; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -48,7 +49,7 @@ class Meetup extends Model implements HasMedia return SlugOptions::create() ->generateSlugsFrom(['name']) ->saveSlugsTo('slug') - ->usingLanguage('de'); + ->usingLanguage(Cookie::get('lang', config('app.locale'))); } public function registerMediaConversions(Media $media = null): void diff --git a/app/Models/Venue.php b/app/Models/Venue.php index 44337846..9b867c51 100644 --- a/app/Models/Venue.php +++ b/app/Models/Venue.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Facades\Cookie; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -71,7 +72,7 @@ class Venue extends Model implements HasMedia return SlugOptions::create() ->generateSlugsFrom(['city.slug', 'name',]) ->saveSlugsTo('slug') - ->usingLanguage('de'); + ->usingLanguage(Cookie::get('lang', config('app.locale'))); } public function createdBy(): BelongsTo diff --git a/app/Nova/LibraryItem.php b/app/Nova/LibraryItem.php index 50400a38..604ac884 100644 --- a/app/Nova/LibraryItem.php +++ b/app/Nova/LibraryItem.php @@ -13,6 +13,7 @@ use Laravel\Nova\Fields\BelongsTo; use Laravel\Nova\Fields\BelongsToMany; use Laravel\Nova\Fields\Code; use Laravel\Nova\Fields\ID; +use Laravel\Nova\Fields\Number; use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; @@ -112,7 +113,8 @@ class LibraryItem extends Resource ->options( config('languages.languages') ) - ->rules('required', 'string')->searchable(), + ->rules('required', 'string') + ->searchable(), Tags::make('Tags') ->type('library_item') @@ -121,6 +123,19 @@ class LibraryItem extends Resource Text::make('Name') ->rules('required', 'string'), + Text::make(__('Subtitle'), 'subtitle') + ->rules('nullable', 'string'), + + Text::make(__('Excerpt'), 'excerpt') + ->rules('nullable', 'string')->help(__('This is the excerpt that is shown in the overview.')), + + Text::make(__('Main image caption'), 'main_image_caption') + ->rules('nullable', 'string'), + + Number::make(__('Time to read'), 'read_time') + ->rules('nullable', 'numeric') + ->help(__('How many minutes to read?')), + Select::make(__('Type'), 'type') ->options( Options::forEnum(LibraryItemType::class) @@ -132,7 +147,9 @@ class LibraryItem extends Resource ->rules('nullable', 'string') ->help('Please paste the URL to the video here, or the link to the blog article, or the link to the book, or the Markdown itself.'), - BelongsTo::make(__('Lecturer/Content Creator'), 'lecturer', Lecturer::class)->searchable()->withSubtitles(), + BelongsTo::make(__('Lecturer/Content Creator'), 'lecturer', Lecturer::class) + ->searchable() + ->withSubtitles(), BelongsTo::make(__('Episode'), 'episode', Episode::class) ->nullable() @@ -145,7 +162,8 @@ class LibraryItem extends Resource return $request->user() ->hasRole('super-admin'); }) - ->searchable()->withSubtitles(), + ->searchable() + ->withSubtitles(), ]; } diff --git a/database/migrations/2023_01_20_121955_add_slug_field_to_library_items_table.php b/database/migrations/2023_01_20_121955_add_slug_field_to_library_items_table.php new file mode 100644 index 00000000..0c77c104 --- /dev/null +++ b/database/migrations/2023_01_20_121955_add_slug_field_to_library_items_table.php @@ -0,0 +1,32 @@ +string('slug') + ->unique() + ->nullable() + ->after('id'); + }); + } + + /** + * Reverse the migrations. + * @return void + */ + public function down() + { + Schema::table('library_items', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2023_01_20_125736_add_meta_fields_to_library_items_table.php b/database/migrations/2023_01_20_125736_add_meta_fields_to_library_items_table.php new file mode 100644 index 00000000..7f55a03b --- /dev/null +++ b/database/migrations/2023_01_20_125736_add_meta_fields_to_library_items_table.php @@ -0,0 +1,36 @@ +text('subtitle') + ->nullable(); + $table->text('excerpt') + ->nullable(); + $table->string('main_image_caption') + ->nullable(); + $table->string('read_time') + ->nullable(); + }); + } + + /** + * Reverse the migrations. + * @return void + */ + public function down() + { + Schema::table('library_items', function (Blueprint $table) { + // + }); + } +}; diff --git a/public/img/einundzwanzig-wallpaper-benrath.png b/public/img/einundzwanzig-wallpaper-benrath.png new file mode 100644 index 00000000..8d22b534 Binary files /dev/null and b/public/img/einundzwanzig-wallpaper-benrath.png differ diff --git a/resources/lang/de.json b/resources/lang/de.json index 88974c66..53b24b25 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -672,5 +672,15 @@ "PlebChat": "", "Close panel": "Schließe Panel", "This chat is limited by 21 messages.": "Dieser Chat ist auf 21 Nachrichten begrenzt. Die ältesten Nachrichten werden gelöscht und die Nachrichten werden nicht gespeichert. (nur im RAM des Servers)", - "Send": "Senden" -} + "Send": "Senden", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" +} \ No newline at end of file diff --git a/resources/lang/en.json b/resources/lang/en.json index 8e666f7b..81372d8d 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -666,5 +666,15 @@ "PlebChat": "", "Close panel": "", "This chat is limited by 21 messages.": "", - "Send": "" -} + "Send": "", + "Main image caption": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" +} \ No newline at end of file diff --git a/resources/lang/es.json b/resources/lang/es.json index 87687d64..672b3f1b 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -659,5 +659,22 @@ "Lightning Address": "", "LNURL": "", "Node Id": "", - "Scan this code or copy & paste it to your lightning wallet. Or click to login with your wallet.": "" -} + "Scan this code or copy & paste it to your lightning wallet. Or click to login with your wallet.": "", + "Parent": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "PlebChat": "", + "Close panel": "", + "This chat is limited by 21 messages.": "", + "Send": "", + "News": "", + "Entries": "", + "Dezentral News": "", + "min read": "", + "Payment Required": "", + "Here we post important news that is relevant for everyone.": "" +} \ No newline at end of file diff --git a/resources/lang/fr.json b/resources/lang/fr.json index b00544c6..b1565997 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/hr.json b/resources/lang/hr.json index 307b1230..b52255bf 100644 --- a/resources/lang/hr.json +++ b/resources/lang/hr.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/it.json b/resources/lang/it.json index 2fad5de3..216628f7 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/mk.json b/resources/lang/mk.json index aa105cda..e5946332 100644 --- a/resources/lang/mk.json +++ b/resources/lang/mk.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 8c7ae881..bfb9212a 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/pt.json b/resources/lang/pt.json index a70315d4..4dfba73a 100644 --- a/resources/lang/pt.json +++ b/resources/lang/pt.json @@ -667,5 +667,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/lang/tr.json b/resources/lang/tr.json index 4305bbb7..0e8e62d4 100644 --- a/resources/lang/tr.json +++ b/resources/lang/tr.json @@ -641,5 +641,15 @@ "Close panel": "", "This chat is limited by 100 messages.": "", "Send": "", - "This chat is limited by 21 messages.": "" + "This chat is limited by 21 messages.": "", + "Excerpt": "", + "This is the excerpt that is shown in the overview.": "", + "Main image caption": "", + "Time to read": "", + "How many minutes to read?": "", + "Read": "", + "News": "", + "Dezentral News": "", + "min read": "", + "Here we post important news that is relevant for everyone.": "" } \ No newline at end of file diff --git a/resources/views/columns/library_items/action.blade.php b/resources/views/columns/library_items/action.blade.php index d04a2aa9..1b1df482 100644 --- a/resources/views/columns/library_items/action.blade.php +++ b/resources/views/columns/library_items/action.blade.php @@ -17,14 +17,32 @@ {{ __('Listen') }} @endif + @if($row->type === 'markdown_article') + + + {{ __('Read') }} + + @endif - route('library.table.libraryItems', ['country' => 'de', 'table' => ['filters' => ['id' => $row->id]]]) }}', }" - @click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('Share url copied!') }}',icon:'success'});" - xs black> - - {{ __('Share link') }} - + @click.prevent="window.navigator.clipboard.writeText(textToCopy);window.$wireui.notify({title:'{{ __('Share url copied!') }}',icon:'success'});" + xs black> + + {{ __('Share link') }} + + @else + + + {{ __('Share link') }} + + @endif diff --git a/resources/views/livewire/frontend/welcome.blade.php b/resources/views/livewire/frontend/welcome.blade.php index 78712429..63831e4c 100644 --- a/resources/views/livewire/frontend/welcome.blade.php +++ b/resources/views/livewire/frontend/welcome.blade.php @@ -137,7 +137,7 @@
-
@@ -145,13 +145,11 @@ class="absolute bottom-0 left-0 z-10 w-full h-full bg-gradient-to-b from-transparent to-gray-900 opacity-30">
+ src="{{ asset('img/einundzwanzig-wallpaper-benrath.png') }}" alt="">
- {{ __('Plebs together strong') }}

- {{ __('PlebArt') }} + {{ __('News') }}

diff --git a/resources/views/livewire/news/article-overview.blade.php b/resources/views/livewire/news/article-overview.blade.php new file mode 100644 index 00000000..3a2d38c9 --- /dev/null +++ b/resources/views/livewire/news/article-overview.blade.php @@ -0,0 +1,66 @@ +
+
+
+
+
+
+
+

{{ __('Dezentral News') }}

+

{{ '' }}

+
+
+ + @foreach($libraryItems as $libraryItem) +
+
+ + {{ $libraryItem->name }} + +
+
+
+

+

{{ $libraryItem->tags->pluck('name')->join(', ') }}
+

+ +

{{ $libraryItem->name }}

+

{{ $libraryItem->excerpt }}

+
+
+
+
+
+ {{ $libraryItem->lecturer->name }} + {{ $libraryItem->lecturer->name }} +
+
+
+

+

{{ $libraryItem->lecturer->name }}
+

+
+ + @if($libraryItem->read_time) + + {{ $libraryItem->read_time }} {{ __('min read') }} + @endif +
+
+
+
+
+ @endforeach + +
+
+
+ {{-- FOOTER --}} + +
diff --git a/resources/views/livewire/news/intern-article-view.blade.php b/resources/views/livewire/news/intern-article-view.blade.php new file mode 100644 index 00000000..4e89c120 --- /dev/null +++ b/resources/views/livewire/news/intern-article-view.blade.php @@ -0,0 +1,51 @@ +
+
+
+ +
+
+

{{ $libraryItem->tags->pluck('name')->join(', ') }}

+

{{ $libraryItem->name }}

+
+
+
+
+ +
+
+
+ {{ $libraryItem->name }} +
+
+ + + {{ $libraryItem->main_image_caption ?? $libraryItem->name }} +
+
+
+
+
+
+

{{ $libraryItem->subtitle }}

+
+
+ + {!! $libraryItem->value !!} + +
+
+
+
+
+ {{-- FOOTER --}} + +
diff --git a/routes/web.php b/routes/web.php index e6451a7f..f09b9922 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,6 +9,14 @@ Route::middleware([ ->get('/', \App\Http\Livewire\Frontend\Welcome::class) ->name('welcome'); +Route::middleware([]) + ->get('/news', \App\Http\Livewire\News\ArticleOverview::class) + ->name('article.overview'); + +Route::middleware([]) + ->get('/news/{libraryItem:slug}', \App\Http\Livewire\News\InternArticleView::class) + ->name('article.view'); + Route::middleware([]) ->get('/my-meetups', \App\Http\Livewire\Profile\Meetups::class) ->name('profile.meetups');