normalize filenames

This commit is contained in:
HolgerHatGarKeineNode
2023-02-27 16:50:25 +01:00
parent 9896618944
commit 2be0b8da2a
13 changed files with 145 additions and 126 deletions

View File

@@ -11,14 +11,12 @@ class ImportLibraryItems extends Command
{ {
/** /**
* The name and signature of the console command. * The name and signature of the console command.
*
* @var string * @var string
*/ */
protected $signature = 'import:l'; protected $signature = 'import:l';
/** /**
* The console command description. * The console command description.
*
* @var string * @var string
*/ */
protected $description = 'Command description'; protected $description = 'Command description';
@@ -123,6 +121,7 @@ class ImportLibraryItems extends Command
if (isset($matches[1])) { if (isset($matches[1])) {
$image = $matches[1]; $image = $matches[1];
$libraryItem->addMediaFromUrl($image) $libraryItem->addMediaFromUrl($image)
->usingFileName(md5($image->getClientOriginalName()).'.'.$image->getClientOriginalExtension())
->toMediaCollection('main'); ->toMediaCollection('main');
} else { } else {
$image = null; $image = null;

View File

@@ -76,6 +76,7 @@ class BitcoinEventForm extends Component
if ($this->image) { if ($this->image) {
$this->bitcoinEvent->addMedia($this->image) $this->bitcoinEvent->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('logo'); ->toMediaCollection('logo');
} }

View File

@@ -50,6 +50,9 @@ class OrangePillForm extends Component
} elseif ($this->orangePill->user_id !== auth()->id()) { } elseif ($this->orangePill->user_id !== auth()->id()) {
abort(403); abort(403);
} }
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
} }
public function save() public function save()

View File

@@ -62,10 +62,11 @@ class ContentCreatorForm extends Component
if ($this->image) { if ($this->image) {
$this->lecturer->addMedia($this->image) $this->lecturer->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('avatar'); ->toMediaCollection('avatar');
} }
return redirect($this->fromUrl ?? url()->route('welcome')); return redirect($this->fromUrl);
} }
public function render() public function render()

View File

@@ -106,11 +106,13 @@ class LibraryItemForm extends Component
if ($this->image) { if ($this->image) {
$this->libraryItem->addMedia($this->image) $this->libraryItem->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('main'); ->toMediaCollection('main');
} }
if ($this->file) { if ($this->file) {
$this->libraryItem->addMedia($this->file) $this->libraryItem->addMedia($this->file)
->usingFileName(md5($this->file->getClientOriginalName()).'.'.$this->file->getClientOriginalExtension())
->toMediaCollection('single_file'); ->toMediaCollection('single_file');
} }

View File

@@ -21,6 +21,10 @@ class MeetupEventForm extends Component
public array $series = []; public array $series = [];
public ?string $fromUrl = '';
protected $queryString = ['fromUrl' => ['except' => '']];
public function rules() public function rules()
{ {
return [ return [
@@ -52,6 +56,9 @@ class MeetupEventForm extends Component
->can('update', $this->meetupEvent)) { ->can('update', $this->meetupEvent)) {
abort(403); abort(403);
} }
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
} }
public function updatedMeetupEventStart($value) public function updatedMeetupEventStart($value)

View File

@@ -57,6 +57,9 @@ class MeetupForm extends Component
) { ) {
abort(403); abort(403);
} }
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
} }
public function submit() public function submit()
@@ -66,6 +69,7 @@ class MeetupForm extends Component
if ($this->image) { if ($this->image) {
$this->meetup->addMedia($this->image) $this->meetup->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('logo'); ->toMediaCollection('logo');
} }

View File

@@ -23,6 +23,10 @@ class NewsArticleForm extends Component
public array $temporaryUrls = []; public array $temporaryUrls = [];
public ?string $fromUrl = '';
protected $queryString = ['fromUrl' => ['except' => '']];
public function rules() public function rules()
{ {
return [ return [
@@ -56,6 +60,9 @@ class NewsArticleForm extends Component
->hasRole('news-editor'), ->hasRole('news-editor'),
]); ]);
} }
if (!$this->fromUrl) {
$this->fromUrl = url()->previous();
}
} }
public function updatedImages($value) public function updatedImages($value)
@@ -76,17 +83,18 @@ class NewsArticleForm extends Component
if ($this->image) { if ($this->image) {
$this->libraryItem->addMedia($this->image) $this->libraryItem->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('main'); ->toMediaCollection('main');
} }
return to_route('article.overview', ['country' => null]); return redirect($this->fromUrl);
} }
public function delete() public function delete()
{ {
$this->libraryItem->delete(); $this->libraryItem->delete();
return to_route('article.overview', ['country' => null]); return redirect($this->fromUrl);
} }
public function render() public function render()

View File

@@ -74,6 +74,7 @@ class VenueForm extends Component
if ($this->images && count($this->images) > 0) { if ($this->images && count($this->images) > 0) {
foreach ($this->images as $item) { foreach ($this->images as $item) {
$this->venue->addMedia($item) $this->venue->addMedia($item)
->usingFileName(md5($item->getClientOriginalName()).'.'.$item->getClientOriginalExtension())
->toMediaCollection('images'); ->toMediaCollection('images');
} }
} }

View File

@@ -10,17 +10,14 @@
<img class="aspect-auto max-h-12" src="{{ asset('img/social_credit_minus.webp') }}" alt=""> <img class="aspect-auto max-h-12" src="{{ asset('img/social_credit_minus.webp') }}" alt="">
@endif @endif
</div> </div>
<div class="flex items-center space-x-1" <div class="flex items-center space-x-1">
x-data="{currentUrl: window.location.href}"> <x-button xs
<a :href="route('bookCases.form', ['bookCase' => $row->id, 'country' => $country])"
x-bind:href="'/{{ $country }}/book-cases/book-case/form/{{ $row->id }}/?fromUrl='+currentUrl">
<x-button
class="whitespace-nowrap" primary class="text-21gray whitespace-nowrap" class="whitespace-nowrap" primary class="text-21gray whitespace-nowrap"
> >
{{ __('💊 Orange Pill Now') }} {{ __('💊 Orange Pill Now') }}
</x-button> </x-button>
</a> <x-button xs class="whitespace-nowrap"
<x-button class="whitespace-nowrap"
:href="route('bookCases.comment.bookcase', ['bookCase' => $row->id, 'country' => $country])">{{ __('Details') }}</x-button> :href="route('bookCases.comment.bookcase', ['bookCase' => $row->id, 'country' => $country])">{{ __('Details') }}</x-button>
</div> </div>
@else @else

View File

@@ -98,14 +98,13 @@
</div> </div>
@endif @endif
@if(auth()->check() && auth()->user()->meetups->contains($row)) @if(auth()->check() && auth()->user()->meetups->contains($row))
<a x-bind:href="'/{{ $country->code ?? 'de' }}/meetup/meetup/form/{{ $row->id }}?fromUrl='+currentUrl">
<x-button <x-button
:href="route('meetup.meetup.form', ['meetup' => $row->id, 'country' => $country])"
xs xs
amber amber
> >
<i class="fa fa-thin fa-edit mr-2"></i> <i class="fa fa-thin fa-edit mr-2"></i>
{{ __('Edit') }} {{ __('Edit') }}
</x-button> </x-button>
</a>
@endif @endif
</div> </div>

View File

@@ -5,26 +5,23 @@
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10"> <div class="max-w-screen-2xl mx-auto px-2 sm:px-10">
<div class="flex"> <div class="flex">
<div class="flex items-center space-x-1" <div class="flex items-center space-x-1">
x-data="{currentUrl: window.location.href}">
<a
x-bind:href="'/{{ $country->code }}/book-cases/book-case/form/{{ $bookCase->id }}/?fromUrl='+currentUrl">
<x-button <x-button
:href="route('bookCases.form', ['bookCase' => $bookCase->id, 'country' => $country])"
class="whitespace-nowrap" primary class="text-21gray whitespace-nowrap" class="whitespace-nowrap" primary class="text-21gray whitespace-nowrap"
> >
{{ __('💊 Orange Pill Now') }} {{ __('💊 Orange Pill Now') }}
</x-button> </x-button>
</a>
</div> </div>
</div> </div>
<div class="p-4" x-data="{currentUrl: window.location.href}"> <div class="p-4">
<ul role="list" <ul role="list"
class="mx-auto grid max-w-2xl grid-cols-2 gap-y-16 gap-x-8 text-center sm:grid-cols-3 md:grid-cols-4 lg:mx-0 lg:max-w-none lg:grid-cols-5 xl:grid-cols-6"> class="mx-auto grid max-w-2xl grid-cols-2 gap-y-16 gap-x-8 text-center sm:grid-cols-3 md:grid-cols-4 lg:mx-0 lg:max-w-none lg:grid-cols-5 xl:grid-cols-6">
@foreach($bookCase->orangePills as $orangePill) @foreach($bookCase->orangePills as $orangePill)
@if($orangePill->user_id === auth()->id()) @if($orangePill->user_id === auth()->id())
<a x-bind:href="'/{{ $country->code }}/book-cases/book-case/form/{{ $bookCase->id }}/{{ $orangePill->id }}?fromUrl='+currentUrl" <a href="{{ route('bookCases.form', ['country' => $country, 'bookCase' => $orangePill->bookCase, 'orangePill' => $orangePill]) }}"
wire:key="orange_pill_{{ $loop->index }}"> wire:key="orange_pill_{{ $loop->index }}">
<li class="border border-amber-500 rounded"> <li class="border border-amber-500 rounded">
<img class="mx-auto h-24 w-24 object-cover rounded" <img class="mx-auto h-24 w-24 object-cover rounded"

View File

@@ -26,7 +26,7 @@
<div> <div>
{{ __('Author') }} {{ __('Author') }}
</div> </div>
<div x-data="{currentUrl: window.location.href}"> <div>
<x-button xs :href="route('contentCreator.form')"> <x-button xs :href="route('contentCreator.form')">
<i class="fa fa-thin fa-plus"></i> <i class="fa fa-thin fa-plus"></i>
{{ __('Create new author') }} {{ __('Create new author') }}