diff --git a/.gitignore b/.gitignore index ae3c8a3f..9038d41e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /public/storage /storage/*.key /storage/medialibrary +/storage/media-library /vendor /.idea /.vagrant diff --git a/app/Conversions/Svg.php b/app/Conversions/Svg.php new file mode 100644 index 00000000..76d5b3c3 --- /dev/null +++ b/app/Conversions/Svg.php @@ -0,0 +1,44 @@ +setBackgroundColor(new ImagickPixel('transparent')); // set bg BEFORE reading file to preserve transparency + $image->readImage($file); + $image->setImageFormat('png'); + + file_put_contents($imageFile, $image->getImageBlob()); + + return $imageFile; + } + + public function requirementsAreInstalled(): bool + { + return class_exists(\Imagick::class); + } + + public function supportedExtensions(): Collection + { + return collect(['svg']); + } + + public function supportedMimeTypes(): Collection + { + return collect(['image/svg+xml']); + } +} diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index c0c8976f..a6842ca8 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -56,12 +56,22 @@ public function updateImage(Request $request, string $setting_name): RedirectRes if ($request->hasFile($setting_name)) { $setting = Setting::firstOrCreate(['name' => $setting_name]); $setting->addMedia($request->file($setting_name))->toMediaCollection($setting_name); - // $message = $setting->processImage($request->file($image_name), 'settings'); - // $url = $setting->getFullImageUrlAttribute(); - $setting->value = url($setting->getFirstMediaUrl($setting_name) ?: '/img/default.png'); + $image = $setting->getFirstMedia($setting_name); + + $setting->update([ + 'value' => url($image?->getUrl() ?: '/img/default.png'), + ]); + + foreach (['thumb', 'medium', 'large'] as $conversion) { + if ($image->hasGeneratedConversion($conversion)) { + Setting::updateOrCreate( + ['name' => "{$setting_name}_{$conversion}"], + ['value' => $image->getUrl($conversion)] + ); + } + } - $setting->save(); $message = 'Settings image has been updated.'; } else { $message = 'Cannot update settings image.'; diff --git a/app/Setting.php b/app/Setting.php index 6f3a7eee..2f4784f9 100644 --- a/app/Setting.php +++ b/app/Setting.php @@ -58,6 +58,7 @@ protected function registerImageThumbnails(Media $media = null, $name, $width, $ ->width($width) ->height($height) ->crop(Manipulations::CROP_TOP, $width, $height) + ->format(Manipulations::FORMAT_PNG) ->performOnCollections('logo'); } diff --git a/config/media-library.php b/config/media-library.php index 002d5e1f..8238ef04 100644 --- a/config/media-library.php +++ b/config/media-library.php @@ -126,13 +126,13 @@ Spatie\MediaLibrary\Conversions\ImageGenerators\Image::class, Spatie\MediaLibrary\Conversions\ImageGenerators\Webp::class, Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf::class, - Spatie\MediaLibrary\Conversions\ImageGenerators\Svg::class, Spatie\MediaLibrary\Conversions\ImageGenerators\Video::class, + App\Conversions\Svg::class, ], /* * The path where to store temporary files while performing image conversions. - * If set to null, storage_path('medialibrary/temp') will be used. + * If set to null, storage_path('media-library/temp') will be used. */ 'temporary_directory_path' => null, diff --git a/config/purify.php b/config/purify.php index 7cbcee32..cc7bcf9b 100644 --- a/config/purify.php +++ b/config/purify.php @@ -50,6 +50,20 @@ 'AutoFormat.RemoveEmpty' => false, ], + 'trix_email' => [ + 'HTML.Doctype' => 'HTML 4.01 Transitional', + 'HTML.AllowedElements' => 'a,span', + 'HTML.AllowedAttributes' => 'a.href,a.style,span.style', + 'AutoFormat.RemoveEmpty' => true, + 'AutoFormat.RemoveEmpty.RemoveNbsp' => true, + 'CSS.AllowedProperties' => 'color,text-decoration', + 'Output.TidyFormat' => true, + 'HTML.Nofollow' => false, + 'Core.NormalizeNewlines' => true, + 'AutoFormat.AutoParagraph' => false, + 'AutoFormat.RemoveSpansWithoutAttributes' => true, + ], + ], /* diff --git a/resources/views/emails/reviewstudents.blade.php b/resources/views/emails/reviewstudents.blade.php index e3b7042b..d9739160 100644 --- a/resources/views/emails/reviewstudents.blade.php +++ b/resources/views/emails/reviewstudents.blade.php @@ -1,7 +1,7 @@ @extends('emails.template') @php - $primary_color = $settings['primary_color'] ?? '#008542'; + $primary_color = $settings['primary_color'] ?? '#154734'; @endphp @section('message') @@ -15,12 +15,23 @@

If you would like to review these undergraduate student research applications, please visit the following page. On this page, you will also be able to delegate review of the applications to another person or indicate if you're not accepting students.

-

- - Review Undergraduate Student Research Applications → - -

+ + + + +
+ + Review Undergraduate Student Research Applications → + +
@stop diff --git a/resources/views/emails/template.blade.php b/resources/views/emails/template.blade.php index 61e03a44..b79bffba 100644 --- a/resources/views/emails/template.blade.php +++ b/resources/views/emails/template.blade.php @@ -2,9 +2,11 @@ @php - $bg_primary = $settings['primary_color'] ?? '#008542'; - $bg_secondary = $settings['secondary_color'] ?? '#008542'; - $bg_tertiary = $settings['tertiary_color'] ?? '#69BE28'; + use Stevebauman\Purify\Facades\Purify; + + $bg_primary = $settings['primary_color'] ?? '#154734'; + $bg_secondary = $settings['secondary_color'] ?? '#C95100'; + $bg_tertiary = $settings['tertiary_color'] ?? '#34827A'; @endphp @@ -18,58 +20,68 @@ a[href], a[href]:visited { color: {{ $bg_primary }}; } .footer a[href], .footer a[href]:visited { color: #fff; } + td.footer-cell a[href] { color: #fff !important; font-size: 16px; text-decoration: underline; } - - - - - - - - - - - -
- - @if(isset($settings['logo'])) - - @endif - {{ $settings['site_title'] ?? 'Profiles' }} - -
- - - - @yield('message') - -
- -

This is an automated message from the {{ $settings['site_title'] ?? 'Profiles' }} website.

+ + + +
+ - - + + + + + + + + + - + + + + + + - - - - - - + @if(isset($settings['footer'])) + @php + $footer = Purify::config('trix_email')->clean($settings['footer']); + $footer = str_replace('Check our FAQ or contact us. + @endif + + +
+ + + + @isset($settings['logo_thumb']) + + @endisset + + +
+ {{ $settings['site_title'] ?? 'Profiles' }} logo + + {{ $settings['site_title'] ?? 'Profiles' }} +
+
+
+ + @yield('message') +
+

This is an automated message from the {{ $settings['site_title'] ?? 'Profiles' }} website.

+
-
-
+