diff --git a/app/Enums/LibraryItemType.php b/app/Enums/LibraryItemType.php index 6e616e53..11ffec5a 100644 --- a/app/Enums/LibraryItemType.php +++ b/app/Enums/LibraryItemType.php @@ -17,6 +17,7 @@ enum LibraryItemType: string case Book = 'book'; case BlogArticle = 'blog_article'; case MarkdownArticle = 'markdown_article'; + case MarkdownArticleExtern = 'markdown_article_extern'; case YoutubeVideo = 'youtube_video'; case VimeoVideo = 'vimeo_video'; case PodcastEpisode = 'podcast_episode'; @@ -25,26 +26,28 @@ enum LibraryItemType: string public static function labels(): array { return [ - 'book' => __('Book'), - 'blog_article' => __('Article'), - 'markdown_article' => __('Markdown Article'), - 'youtube_video' => __('Youtube Video'), - 'vimeo_video' => __('Vimeo Video'), - 'podcast_episode' => __('Podcast Episode'), - 'downloadable_file' => __('Downloadable File'), + 'book' => __('Book'), + 'blog_article' => __('Article'), + 'markdown_article' => __('Markdown Article'), + 'markdown_article_extern' => __('Markdown Article Extern'), + 'youtube_video' => __('Youtube Video'), + 'vimeo_video' => __('Vimeo Video'), + 'podcast_episode' => __('Podcast Episode'), + 'downloadable_file' => __('Downloadable File'), ]; } public static function icons(): array { return [ - 'book' => 'book', - 'blog_article' => 'newspaper', - 'markdown_article' => 'newspaper', - 'youtube_video' => 'video', - 'vimeo_video' => 'video', - 'podcast_episode' => 'podcast', - 'downloadable_file' => 'download', + 'book' => 'book', + 'blog_article' => 'newspaper', + 'markdown_article' => 'newspaper', + 'markdown_article_extern' => 'newspaper', + 'youtube_video' => 'video', + 'vimeo_video' => 'video', + 'podcast_episode' => 'podcast', + 'downloadable_file' => 'download', ]; } } diff --git a/app/Http/Livewire/City/Form/CityForm.php b/app/Http/Livewire/City/Form/CityForm.php index f8bdf133..470ab38c 100644 --- a/app/Http/Livewire/City/Form/CityForm.php +++ b/app/Http/Livewire/City/Form/CityForm.php @@ -32,6 +32,9 @@ class CityForm extends Component if (!$this->city) { $this->city = new City(); } + if (!$this->fromUrl) { + $this->fromUrl = url()->previous(); + } } public function save() @@ -39,7 +42,7 @@ class CityForm extends Component $this->validate(); $this->city->save(); - return redirect($this->fromUrl); + return redirect($this->fromUrl ?? url()->route('welcome')); } public function render() diff --git a/app/Http/Livewire/ContentCreator/Form/ContentCreatorForm.php b/app/Http/Livewire/ContentCreator/Form/ContentCreatorForm.php new file mode 100644 index 00000000..78405f0e --- /dev/null +++ b/app/Http/Livewire/ContentCreator/Form/ContentCreatorForm.php @@ -0,0 +1,69 @@ + ['except' => '']]; + + public function rules() + { + return [ + 'image' => [Rule::requiredIf(!$this->lecturer->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'], + + 'lecturer.name' => 'required', + 'lecturer.active' => 'boolean', + 'lecturer.subtitle' => 'required', + 'lecturer.intro' => 'required', + 'lecturer.twitter_username' => 'nullable|string', + 'lecturer.website' => 'nullable|url', + 'lecturer.lightning_address' => 'nullable|string', + 'lecturer.lnurl' => 'nullable|string', + 'lecturer.node_id' => 'nullable|string', + ]; + } + + public function mount() + { + if (!$this->lecturer) { + $this->lecturer = new Lecturer([ + 'intro' => '', + 'active' => true, + 'team_id' => true, + ]); + } + if (!$this->fromUrl) { + $this->fromUrl = url()->previous(); + } + } + + public function save() + { + $this->validate(); + $this->lecturer->save(); + + if ($this->image) { + $this->lecturer->addMedia($this->image) + ->toMediaCollection('avatar'); + } + + return redirect($this->fromUrl ?? url()->route('welcome')); + } + + public function render() + { + return view('livewire.content-creator.form.content-creator-form'); + } +} diff --git a/app/Http/Livewire/Library/Form/LibraryItemForm.php b/app/Http/Livewire/Library/Form/LibraryItemForm.php new file mode 100644 index 00000000..9a2357f2 --- /dev/null +++ b/app/Http/Livewire/Library/Form/LibraryItemForm.php @@ -0,0 +1,122 @@ + ['except' => ''], + 'lecturer' => ['except' => false], + ]; + + public function rules() + { + return [ + 'image' => [Rule::requiredIf(!$this->libraryItem->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'], + + 'library' => 'required', + + 'libraryItem.lecturer_id' => 'required', + 'libraryItem.name' => 'required', + 'libraryItem.type' => 'required', + 'libraryItem.language_code' => 'required', + 'libraryItem.value' => [ + 'required', + Rule::when( + $this->libraryItem->type !== LibraryItemType::MarkdownArticle + && $this->libraryItem->type !== LibraryItemType::MarkdownArticleExtern + && $this->libraryItem->type !== LibraryItemType::DownloadableFile, ['url'] + ) + ], + 'libraryItem.subtitle' => 'required', + 'libraryItem.excerpt' => 'required', + 'libraryItem.main_image_caption' => 'required', + 'libraryItem.read_time' => 'required', + 'libraryItem.approved' => 'boolean', + ]; + } + + public function mount() + { + if (!$this->libraryItem) { + $this->libraryItem = new LibraryItem([ + 'approved' => true, + 'read_time' => 1, + ]); + if ($this->lecturer) { + $this->library = Library::query() + ->firstWhere('name', '=', 'Dozentenmaterial')?->id; + } + } else { + $this->library = $this->libraryItem->libraries() + ->first() + ->id; + } + if (!$this->fromUrl) { + $this->fromUrl = url()->previous(); + } + } + + public function save() + { + $this->validate(); + $this->libraryItem->save(); + $this->libraryItem->setStatus('published'); + + if ($this->image) { + $this->libraryItem->addMedia($this->image) + ->toMediaCollection('main'); + } + + if ($this->file) { + $this->libraryItem->addMedia($this->file) + ->toMediaCollection('single_file'); + } + + $this->libraryItem->libraries() + ->syncWithoutDetaching([(int) $this->library]); + + return to_route('library.table.libraryItems', ['country' => $this->country]); + } + + public function render() + { + return view('livewire.library.form.library-item-form', [ + 'types' => Options::forEnum(LibraryItemType::class) + ->filter( + fn($type) => $type !== LibraryItemType::PodcastEpisode + && $type !== LibraryItemType::MarkdownArticle + ) + ->toArray(), + 'libraries' => Library::query() + ->where('is_public', true) + ->get() + ->map(fn($library) => [ + 'id' => $library->id, + 'name' => $library->name, + ]) + ->toArray(), + ]); + } +} diff --git a/resources/lang/de.json b/resources/lang/de.json index fa6d1521..fd892d5f 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -758,5 +758,10 @@ "Article tweeted": "Artikel getwittert", "Error tweeting article": "Fehler beim Twittern des Artikels", "Tweet": "Tweet", - "Are you sure you want to tweet this article?": "Bitte bestätige, dass du diesen Artikel tweeten möchtest." + "Are you sure you want to tweet this article?": "Bitte bestätige, dass du diesen Artikel tweeten möchtest.", + "Markdown Article Extern": "Markdown Artikel", + "twitter_username": "", + "Please classify by type of your entry.": "Bitte klassifiziere deinen Eintrag nach Art.", + "Choose language": "Wähle Sprache", + "File": "Datei" } diff --git a/resources/lang/en.json b/resources/lang/en.json index a31d8182..65c685f9 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -754,5 +754,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/es.json b/resources/lang/es.json index 91e1b8ad..9649df8c 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -754,5 +754,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/fr.json b/resources/lang/fr.json index f6ec74ca..5484c675 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/hr.json b/resources/lang/hr.json index 8cb1db50..a3be9078 100644 --- a/resources/lang/hr.json +++ b/resources/lang/hr.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/it.json b/resources/lang/it.json index 99c654fe..86d579bf 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/mk.json b/resources/lang/mk.json index aa38a33c..8aa193d3 100644 --- a/resources/lang/mk.json +++ b/resources/lang/mk.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 76fbad0b..bef8efc6 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/pt.json b/resources/lang/pt.json index bb8da6ad..4389b2f4 100644 --- a/resources/lang/pt.json +++ b/resources/lang/pt.json @@ -755,5 +755,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/sv.json b/resources/lang/sv.json index 786a7ff6..2d9c4dde 100644 --- a/resources/lang/sv.json +++ b/resources/lang/sv.json @@ -717,5 +717,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/lang/tr.json b/resources/lang/tr.json index b3c95d6a..566b72fd 100644 --- a/resources/lang/tr.json +++ b/resources/lang/tr.json @@ -729,5 +729,10 @@ "Article tweeted": "", "Error tweeting article": "", "Tweet": "", - "Are you sure you want to tweet this article?": "" + "Are you sure you want to tweet this article?": "", + "Markdown Article Extern": "", + "twitter_username": "", + "Please classify by type of your entry.": "", + "Choose language": "", + "File": "" } \ No newline at end of file diff --git a/resources/views/columns/cities/areas/toolbar-left-end.blade.php b/resources/views/columns/cities/areas/toolbar-left-end.blade.php index 64d49533..503b58af 100644 --- a/resources/views/columns/cities/areas/toolbar-left-end.blade.php +++ b/resources/views/columns/cities/areas/toolbar-left-end.blade.php @@ -1,5 +1,5 @@
- + {{ __('New City') }} diff --git a/resources/views/livewire/content-creator/form/content-creator-form.blade.php b/resources/views/livewire/content-creator/form/content-creator-form.blade.php new file mode 100644 index 00000000..d6d006a3 --- /dev/null +++ b/resources/views/livewire/content-creator/form/content-creator-form.blade.php @@ -0,0 +1,87 @@ +
+ +
+

{{ __('Lecturer/Content Creator') }}

+
+
+ + + {{ __('Back') }} + +
+
+
+ +
+
+
+ + +
+ @if ($image) +
{{ __('Preview') }}:
+ + @endif + @if ($lecturer->getFirstMediaUrl('avatar')) +
{{ __('Current picture') }}:
+ + @endif +
+ + @error('image') {{ $message }} @enderror +
+ + + + + + + + + + +
{{ __('For images in Markdown, please use eg. Imgur or another provider.') }}
+ + @error('lecturer.intro') {{ $message }} @enderror + {{ __('This is the introduction text that is shown on the landing page.') }} +
+ + + + + + + + + + + + + + + + + + + + + + + + + {{ __('Save') }} + + + +
+
+
+
diff --git a/resources/views/livewire/frontend/header.blade.php b/resources/views/livewire/frontend/header.blade.php index 73592fd7..872e363c 100644 --- a/resources/views/livewire/frontend/header.blade.php +++ b/resources/views/livewire/frontend/header.blade.php @@ -188,6 +188,19 @@

{{ __('Choose a topic that is right for you.') }}

+ @auth + @if(str(request()->route()->getName())->contains('lecturer')) + + + {{ __('Submit contents') }} + + @else + + + {{ __('Submit contents') }} + + @endif + @endauth
@endif diff --git a/resources/views/livewire/library/form/library-item-form.blade.php b/resources/views/livewire/library/form/library-item-form.blade.php new file mode 100644 index 00000000..8a755fe8 --- /dev/null +++ b/resources/views/livewire/library/form/library-item-form.blade.php @@ -0,0 +1,158 @@ +
+ +
+

{{ __('Library Item') }}

+
+
+ + + {{ __('Back') }} + +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + @if($libraryItem->lecturer_id && $libraryItem->type && $library) + +
+ @if ($image) +
{{ __('Preview') }}:
+ + @endif + @if ($libraryItem->getFirstMediaUrl('main')) +
{{ __('Current picture') }}:
+ + @endif +
+ + @error('image') {{ $message }} @enderror +
+ + + + + + + + + + + + + + + + + + + + + + @if($libraryItem->type === App\Enums\LibraryItemType::MarkdownArticleExtern()) + +
{{ __('For images in Markdown, please use eg. Imgur or another provider.') }}
+ + @error('libraryItem.value') {{ $message }} @enderror +
+ @elseif($libraryItem->type !== App\Enums\LibraryItemType::DownloadableFile()) + + + + @elseif($libraryItem->type === App\Enums\LibraryItemType::DownloadableFile()) + + + @error('file') {{ $message }} @enderror + + @endif + + + + + + + + + {{ __('Save') }} + + + @endif + +
+
+
+
diff --git a/resources/views/livewire/library/library-table.blade.php b/resources/views/livewire/library/library-table.blade.php index f72bac3d..23c0508c 100644 --- a/resources/views/livewire/library/library-table.blade.php +++ b/resources/views/livewire/library/library-table.blade.php @@ -108,9 +108,9 @@
-

-

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

+
+
{{ $libraryItem->lecturer->name }}
+
@@ -119,14 +119,24 @@ {{ $libraryItem->read_time }} {{ __('min read') }} @endif
+
+
+ + + {{ __('Edit') }} + +
+
@endforeach -
{ entries.forEach(entry => { @@ -140,8 +150,8 @@ observer.observe(this.$el) } }" - x-init="observe" - >
+ x-init="observe" + > @if($libraryItems->hasMorePages()) {{ __('load more...') }} diff --git a/resources/views/livewire/meetup/landing-page-event.blade.php b/resources/views/livewire/meetup/landing-page-event.blade.php index 015862c5..34e2f6e1 100644 --- a/resources/views/livewire/meetup/landing-page-event.blade.php +++ b/resources/views/livewire/meetup/landing-page-event.blade.php @@ -159,9 +159,10 @@ id: 'attend-event', icon: 'question', accept: {label: '{{ __('Yes') }}', - execute: () => $wire.attend()}, + execute: () => $wire.attend()}, reject: {label: '{{ __('No, cancel') }}', - execute: () => window.$wireui.notify({'title': '{{ __('You have not confirmed your participation.') }}','icon': 'warning'})}})" + execute: () => window.$wireui.notify({'title': '{{ __('You have not confirmed your participation.') }}','icon': 'warning'})} + })" > {{ __('I will show up') }} diff --git a/resources/views/livewire/news/form/news-article-form.blade.php b/resources/views/livewire/news/form/news-article-form.blade.php index d4c05d35..bdfc106a 100644 --- a/resources/views/livewire/news/form/news-article-form.blade.php +++ b/resources/views/livewire/news/form/news-article-form.blade.php @@ -93,8 +93,8 @@ - {{ __('For images in Markdown, please use eg. Imgur or another provider.') }} +
{{ __('For images in Markdown, please use eg. Imgur or another provider.') }}
@error('libraryItem.value') {{ $message }} @enderror
diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php index 0cef884d..94e63c95 100644 --- a/resources/views/navigation-menu.blade.php +++ b/resources/views/navigation-menu.blade.php @@ -49,15 +49,6 @@ @endif - @if(str(request()->route()->getName())->contains(['library.', 'article.'])) -
- - - {{ __('Submit contents') }} - -
- @endif - @if(str(request()->route()->getName())->contains('bitcoinEvent.'))
@@ -240,12 +231,6 @@ @endif - @if(str(request()->route()->getName())->contains('library.')) - - {{ __('Submit contents') }} - - @endif - @if(str(request()->route()->getName())->contains('bitcoinEvent.')) {{ __('Register event') }} diff --git a/routes/web.php b/routes/web.php index ec81b1f7..393b7ce2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -36,6 +36,20 @@ Route::middleware([ ->name('form'); }); + +/* + * Content Creator + * */ +Route::middleware([ + 'auth' +]) + ->as('contentCreator.') + ->prefix('/content-creator') + ->group(function () { + Route::get('/form/{lecturer?}', \App\Http\Livewire\ContentCreator\Form\ContentCreatorForm::class) + ->name('form'); + }); + /* * Cities * */ @@ -131,6 +145,9 @@ Route::middleware([]) ->as('library.') ->prefix('/{country:code}/library') ->group(function () { + Route::get('/library-item/form/{libraryItem?}', \App\Http\Livewire\Library\Form\LibraryItemForm::class) + ->name('libraryItem.form')->middleware(['auth']); + Route::get('/library-item', \App\Http\Livewire\Library\LibraryTable::class) ->name('table.libraryItems');