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 @@
{{ __('Choose a topic that is right for you.') }}
+ @auth + @if(str(request()->route()->getName())->contains('lecturer')) +-