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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,26 +5,23 @@
<div class="max-w-screen-2xl mx-auto px-2 sm:px-10">
<div class="flex">
<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">
<div class="flex items-center space-x-1">
<x-button
:href="route('bookCases.form', ['bookCase' => $bookCase->id, 'country' => $country])"
class="whitespace-nowrap" primary class="text-21gray whitespace-nowrap"
>
{{ __('💊 Orange Pill Now') }}
</x-button>
</a>
</div>
</div>
<div class="p-4" x-data="{currentUrl: window.location.href}">
<div class="p-4">
<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">
@foreach($bookCase->orangePills as $orangePill)
@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 }}">
<li class="border border-amber-500 rounded">
<img class="mx-auto h-24 w-24 object-cover rounded"

View File

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