From: Vincent Vanwaelscappel Date: Tue, 28 Mar 2023 18:09:12 +0000 (+0200) Subject: wip #5835 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=88f74af0ad170a9d11385d44c4f5937fc9428260;p=fluidbook-toolbox.git wip #5835 @2 --- diff --git a/app/Fluidbook/Packager/Download.php b/app/Fluidbook/Packager/Download.php index 281418ddf..02a7c71d4 100644 --- a/app/Fluidbook/Packager/Download.php +++ b/app/Fluidbook/Packager/Download.php @@ -22,6 +22,12 @@ class Download extends DownloadBase // __('Fluidbook ":title" (#:nb) installé sur :server') protected $_installSubject = 'Fluidbook ":title" (#:nb) installé sur :server'; + // __('Le Fluidbook ":title" est prêt au téléchargement.'); + protected $_text = 'Le Fluidbook ":title" est prêt au téléchargement.'; + + // __('Le Fluidbook ":title" a été installé sur :server.') + protected $_installText = 'Le Fluidbook ":title" a été installé sur :server.'; + protected $_params = []; public function __construct($entry, $version, $action, $user, $params = []) @@ -71,8 +77,10 @@ class Download extends DownloadBase { try { $url = $this->_compileandpackage(); - $subject = __($this->_subject, ['title' => $this->_title(), 'nb' => $this->_id()]); - $text = ''; + $translateVariables = ['title' => $this->_title(), 'nb' => $this->_id()]; + + $subject = __($this->_subject, $translateVariables); + $text = __($this->_text, $translateVariables); $actions = []; if ($this->action === 'download' || $this->action === 'scormcloud') { $actions = ['Télécharger' => $url]; @@ -97,7 +105,10 @@ class Download extends DownloadBase if (!$dest) { throw new \Exception('No path defined for external server installation'); } - $subject = __($this->_installSubject, ['title' => $this->_title(), 'nb' => $this->_id(), 'server' => $server->name]); + + $translateVariables['server'] = $server->name; + $subject = __($this->_installSubject, $translateVariables); + $text = __($this->_installText, $translateVariables); $path = $this->_compileandpackage(false); $driver = $server->getTransferDriver(); diff --git a/app/Jobs/DownloadBase.php b/app/Jobs/DownloadBase.php index 7150fb3bf..6f479df7e 100644 --- a/app/Jobs/DownloadBase.php +++ b/app/Jobs/DownloadBase.php @@ -37,6 +37,8 @@ class DownloadBase extends Base protected $_subject; + protected $_text; + /** * @param $entry CubistMagicAbstractModel * @param $action string @@ -123,9 +125,10 @@ class DownloadBase extends Base { try { $url = $this->_compileandpackage(); - $subject = __($this->_subject, ['title' => $this->_title(), 'nb' => $this->_id()]); - $text = ''; - $actions = ['Télécharger' => $url]; + $translateVariables = $this->_getTranslateVariables(); + $subject = __($this->_subject, $translateVariables); + $text = __($this->_text, $translateVariables); + $actions = [__('Télécharger') => $url]; try { if ($this->action === 'scormcloud') { $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->_id()); @@ -143,6 +146,11 @@ class DownloadBase extends Base $this->sendNotification($subject, $text, $actions); } + protected function _getTranslateVariables() + { + return ['title' => $this->_title(), 'nb' => $this->_id()]; + } + protected function _compileandpackage() { diff --git a/app/Jobs/ElearningMediaDownload.php b/app/Jobs/ElearningMediaDownload.php index dea8bb12f..8d350e1ae 100644 --- a/app/Jobs/ElearningMediaDownload.php +++ b/app/Jobs/ElearningMediaDownload.php @@ -11,4 +11,6 @@ class ElearningMediaDownload extends DownloadBase protected $type = 'elearningmedia'; // __('Media ":title" (#:nb) prêt au téléchargement') protected $_subject = 'Media ":title" (#:nb) prêt au téléchargement'; + // __('Le media ":title" est prêt au téléchargement'); + protected $_text = 'Le media ":title" est prêt au téléchargement'; } diff --git a/app/Jobs/ElearningPackageDownload.php b/app/Jobs/ElearningPackageDownload.php index d4fbb5845..53a73876c 100644 --- a/app/Jobs/ElearningPackageDownload.php +++ b/app/Jobs/ElearningPackageDownload.php @@ -11,4 +11,6 @@ class ElearningPackageDownload extends DownloadBase protected $type = 'elearningpackage'; // __('Package ":title" (#:nb) prêt au téléchargement') protected $_subject = 'Package ":title" (#:nb) prêt au téléchargement'; + // __('Le package ":title" est prêt au téléchargement'); + protected $_text = 'Le package ":title" est prêt au téléchargement'; } diff --git a/app/Jobs/FluidbookCollectionDownload.php b/app/Jobs/FluidbookCollectionDownload.php index 76974023d..7bdb873d2 100644 --- a/app/Jobs/FluidbookCollectionDownload.php +++ b/app/Jobs/FluidbookCollectionDownload.php @@ -18,16 +18,19 @@ class FluidbookCollectionDownload extends DownloadBase // __('Collection ":title" (#:nb) prête au téléchargement') protected $_subject = 'Collection ":title" (#:nb) prête au téléchargement'; + // __('La collection ":title" est prêt au téléchargement'); + protected $_text = 'La collection ":title" est prêt au téléchargement'; public function handle() { + $translateVariables = $this->_getTranslateVariables(); if ($this->action === 'install') { $url = $this->installHosting($this->entry->getPageData()); - $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur hosting', ['title' => $this->_title(), 'nb' => $this->_id()]), '', $url); + $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur hosting', $translateVariables), '', $url); } else if ($this->action === 'export' && in_array($this->entry->version, ['win_inss_html', 'win_ins_html'])) { $url = $this->downloadList($this->entry->getPageData()); - $this->sendNotification(__('Collection ":title" (#:nb) prête au téléchargement', ['title' => $this->_title(), 'nb' => $this->_id()]), '', $url); + $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text,$translateVariables), $url); } else { parent::handle(); } diff --git a/app/Jobs/QuizDownload.php b/app/Jobs/QuizDownload.php index 8489f1c2d..9d2ce2961 100644 --- a/app/Jobs/QuizDownload.php +++ b/app/Jobs/QuizDownload.php @@ -12,4 +12,7 @@ class QuizDownload extends DownloadBase protected $type = 'quiz'; // __('Quiz ":title" (#:nb) prêt au téléchargement') protected $_subject = 'Quiz ":title" (#:nb) prêt au téléchargement'; + // __('Le quiz ":title" est prêt au téléchargement') + protected $_text = 'Le quiz ":title" est prêt au téléchargement'; + } diff --git a/app/Jobs/Tools/FluidbookAssetsDownloader.php b/app/Jobs/Tools/FluidbookAssetsDownloader.php index 2454cc388..f6b47d97b 100644 --- a/app/Jobs/Tools/FluidbookAssetsDownloader.php +++ b/app/Jobs/Tools/FluidbookAssetsDownloader.php @@ -24,7 +24,7 @@ class FluidbookAssetsDownloader extends Base throw new \Exception('Fluidbook has not be set'); } $this->setJobName(__('Téléchargement massif d\'assets dans un fluidbook')); - $this->dest = '/application/protected/fluidbookpublication/working/' . $fluidbook . '/'; + $this->dest = Files::mkdir(protected_path('fluidbookpublication/working/' . $fluidbook)); if ($folder !== 'working') { $this->dest .= $folder . '/'; } diff --git a/app/Notifications/DownloadReady.php b/app/Notifications/DownloadReady.php index 444b46573..316587ded 100644 --- a/app/Notifications/DownloadReady.php +++ b/app/Notifications/DownloadReady.php @@ -6,6 +6,7 @@ use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use Illuminate\Support\HtmlString; class DownloadReady extends Notification { @@ -14,17 +15,19 @@ class DownloadReady extends Notification protected $subject; protected $text; protected $actions = []; + protected $error = false; /** * Create a new notification instance. * * @return void */ - public function __construct($subject = '', $text = '', $actions = []) + public function __construct($subject = '', $text = '', $actions = [], $error = false) { $this->subject = $subject; $this->text = $text; $this->actions = $actions; + $this->error = $error; } /** @@ -35,6 +38,7 @@ class DownloadReady extends Notification */ public function via($notifiable) { + return ['database', 'mail']; if ($notifiable->slack) { return ['database', FluidbookslackChannel::class]; } else { @@ -50,10 +54,22 @@ class DownloadReady extends Notification */ public function toMail($notifiable) { - return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', url('/')) - ->line('Thank you for using our application!'); + $m = (new MailMessage)->greeting(__('Bonjour !')) + ->subject($this->subject); + if ($this->text) { + $m->line($this->text); + } + foreach ($this->actions as $label => $url) { + $m->line(new HtmlString($label . __(': ') . ' ' . $url . '')); + } + $m->salutation(new HtmlString(__('Cordialement,') . "
" . __('L\'équipe Fluidbook'))); + if ($this->error) { + $m->error(); + } else { + $m->success(); + } + return $m; + } /** diff --git a/public/images/logo-email.png b/public/images/logo-email.png new file mode 100644 index 000000000..07e289990 Binary files /dev/null and b/public/images/logo-email.png differ diff --git a/resources/views/vendor/mail/html/button.blade.php b/resources/views/vendor/mail/html/button.blade.php new file mode 100644 index 000000000..e74fe55a7 --- /dev/null +++ b/resources/views/vendor/mail/html/button.blade.php @@ -0,0 +1,19 @@ + + + + + diff --git a/resources/views/vendor/mail/html/footer.blade.php b/resources/views/vendor/mail/html/footer.blade.php new file mode 100644 index 000000000..3ff41f89c --- /dev/null +++ b/resources/views/vendor/mail/html/footer.blade.php @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/resources/views/vendor/mail/html/header.blade.php b/resources/views/vendor/mail/html/header.blade.php new file mode 100644 index 000000000..fa1875caa --- /dev/null +++ b/resources/views/vendor/mail/html/header.blade.php @@ -0,0 +1,11 @@ + + + +@if (trim($slot) === 'Laravel') + +@else +{{ $slot }} +@endif + + + diff --git a/resources/views/vendor/mail/html/layout.blade.php b/resources/views/vendor/mail/html/layout.blade.php new file mode 100644 index 000000000..21d349b39 --- /dev/null +++ b/resources/views/vendor/mail/html/layout.blade.php @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php new file mode 100644 index 000000000..b5adaa77e --- /dev/null +++ b/resources/views/vendor/mail/html/message.blade.php @@ -0,0 +1,27 @@ +@component('mail::layout') + {{-- Header --}} + @slot('header') + @component('mail::header', ['url' => config('app.url')]) + {{ config('app.name') }} + @endcomponent + @endslot + + {{-- Body --}} + {{ $slot }} + + {{-- Subcopy --}} + @isset($subcopy) + @slot('subcopy') + @component('mail::subcopy') + {{ $subcopy }} + @endcomponent + @endslot + @endisset + + {{-- Footer --}} + @slot('footer') + @component('mail::footer') + © {{ date('Y') }} {{ config('app.name') }} +@endcomponent +@endslot +@endcomponent diff --git a/resources/views/vendor/mail/html/panel.blade.php b/resources/views/vendor/mail/html/panel.blade.php new file mode 100644 index 000000000..2975a60a0 --- /dev/null +++ b/resources/views/vendor/mail/html/panel.blade.php @@ -0,0 +1,14 @@ + + + + + + diff --git a/resources/views/vendor/mail/html/subcopy.blade.php b/resources/views/vendor/mail/html/subcopy.blade.php new file mode 100644 index 000000000..790ce6c24 --- /dev/null +++ b/resources/views/vendor/mail/html/subcopy.blade.php @@ -0,0 +1,7 @@ + + + + + diff --git a/resources/views/vendor/mail/html/table.blade.php b/resources/views/vendor/mail/html/table.blade.php new file mode 100644 index 000000000..a5f3348b2 --- /dev/null +++ b/resources/views/vendor/mail/html/table.blade.php @@ -0,0 +1,3 @@ +
+{{ Illuminate\Mail\Markdown::parse($slot) }} +
diff --git a/resources/views/vendor/mail/html/themes/default.css b/resources/views/vendor/mail/html/themes/default.css new file mode 100644 index 000000000..95c3cd1e2 --- /dev/null +++ b/resources/views/vendor/mail/html/themes/default.css @@ -0,0 +1,296 @@ +/* Base */ + +body, +body *:not(html):not(style):not(br):not(tr):not(code) { + box-sizing: border-box; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, + 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; + position: relative; +} + +html{ + min-height: 100%; + height: 100%; +} + +body { + -webkit-text-size-adjust: none; + background-color: #edf2f7; + color: #718096; + min-height: 100%; + height: 100%; + line-height: 1.4; + margin: 0; + padding: 0; + width: 100% !important; +} + +p, +ul, +ol, +blockquote { + line-height: 1.4; + text-align: left; +} + +a { + color: #3869d4; +} + +a img { + border: none; +} + +/* Typography */ + +h1 { + color: #3d4852; + font-size: 18px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +h2 { + font-size: 16px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +h3 { + font-size: 14px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +p { + font-size: 16px; + line-height: 1.5em; + margin-top: 0; + text-align: left; +} + +p.sub { + font-size: 12px; +} + +img { + max-width: 100%; +} + +/* Layout */ + +.wrapper { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + background-color: #edf2f7; + margin: 0; + padding: 0; + width: 100%; +} + +.content { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 0; + padding: 0; + width: 100%; +} + +/* Header */ + +.header { + padding: 25px 0; + text-align: center; +} + +.header a { + color: #3d4852; + font-size: 19px; + font-weight: bold; + text-decoration: none; +} + +/* Logo */ + +.logo { + height: 75px; + max-height: 75px; + width: 75px; +} + +/* Body */ + +.body { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + background-color: #edf2f7; + border-bottom: 1px solid #edf2f7; + border-top: 1px solid #edf2f7; + margin: 0; + padding: 0; + width: 100%; +} + +.inner-body { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 570px; + background-color: #ffffff; + border-color: #e8e5ef; + border-radius: 2px; + border-width: 1px; + box-shadow: 0 2px 0 rgba(0, 0, 150, 0.025), 2px 4px 0 rgba(0, 0, 150, 0.015); + margin: 0 auto; + padding: 0; + width: 570px; +} + +/* Subcopy */ + +.subcopy { + border-top: 1px solid #e8e5ef; + margin-top: 25px; + padding-top: 25px; +} + +.subcopy p { + font-size: 14px; +} + +/* Footer */ + +.footer { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 570px; + margin: 0 auto; + padding: 0; + text-align: center; + width: 570px; +} + +.footer p { + color: #b0adc5; + font-size: 12px; + text-align: center; +} + +.footer a { + color: #b0adc5; + text-decoration: underline; +} + +/* Tables */ + +.table table { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 30px auto; + width: 100%; +} + +.table th { + border-bottom: 1px solid #edeff2; + margin: 0; + padding-bottom: 8px; +} + +.table td { + color: #74787e; + font-size: 15px; + line-height: 18px; + margin: 0; + padding: 10px 0; +} + +.content-cell { + max-width: 100vw; + padding: 32px; +} + +/* Buttons */ + +.action { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 30px auto; + padding: 0; + text-align: center; + width: 100%; +} + +.button { + -webkit-text-size-adjust: none; + border-radius: 4px; + color: #fff; + display: inline-block; + overflow: hidden; + text-decoration: none; +} + +.button-blue, +.button-primary { + background-color: #2d3748; + border-bottom: 8px solid #2d3748; + border-left: 18px solid #2d3748; + border-right: 18px solid #2d3748; + border-top: 8px solid #2d3748; +} + +.button-green, +.button-success { + background-color: #48bb78; + border-bottom: 8px solid #48bb78; + border-left: 18px solid #48bb78; + border-right: 18px solid #48bb78; + border-top: 8px solid #48bb78; +} + +.button-red, +.button-error { + background-color: #e53e3e; + border-bottom: 8px solid #e53e3e; + border-left: 18px solid #e53e3e; + border-right: 18px solid #e53e3e; + border-top: 8px solid #e53e3e; +} + +/* Panels */ + +.panel { + border-left: #2d3748 solid 4px; + margin: 21px 0; +} + +.panel-content { + background-color: #edf2f7; + color: #718096; + padding: 16px; +} + +.panel-content p { + color: #718096; +} + +.panel-item { + padding: 0; +} + +.panel-item p:last-of-type { + margin-bottom: 0; + padding-bottom: 0; +} + +/* Utilities */ + +.break-all { + word-break: break-all; +} diff --git a/resources/views/vendor/mail/text/button.blade.php b/resources/views/vendor/mail/text/button.blade.php new file mode 100644 index 000000000..97444ebdc --- /dev/null +++ b/resources/views/vendor/mail/text/button.blade.php @@ -0,0 +1 @@ +{{ $slot }}: {{ $url }} diff --git a/resources/views/vendor/mail/text/footer.blade.php b/resources/views/vendor/mail/text/footer.blade.php new file mode 100644 index 000000000..3338f620e --- /dev/null +++ b/resources/views/vendor/mail/text/footer.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/header.blade.php b/resources/views/vendor/mail/text/header.blade.php new file mode 100644 index 000000000..aaa3e5754 --- /dev/null +++ b/resources/views/vendor/mail/text/header.blade.php @@ -0,0 +1 @@ +[{{ $slot }}]({{ $url }}) diff --git a/resources/views/vendor/mail/text/layout.blade.php b/resources/views/vendor/mail/text/layout.blade.php new file mode 100644 index 000000000..9378baa07 --- /dev/null +++ b/resources/views/vendor/mail/text/layout.blade.php @@ -0,0 +1,9 @@ +{!! strip_tags($header) !!} + +{!! strip_tags($slot) !!} +@isset($subcopy) + +{!! strip_tags($subcopy) !!} +@endisset + +{!! strip_tags($footer) !!} diff --git a/resources/views/vendor/mail/text/message.blade.php b/resources/views/vendor/mail/text/message.blade.php new file mode 100644 index 000000000..ec50544ad --- /dev/null +++ b/resources/views/vendor/mail/text/message.blade.php @@ -0,0 +1,27 @@ +@component('mail::layout') + {{-- Header --}} + @slot('header') + @component('mail::header', ['url' => config('app.url')]) + {{ config('app.name') }} + @endcomponent + @endslot + + {{-- Body --}} + {{ $slot }} + + {{-- Subcopy --}} + @isset($subcopy) + @slot('subcopy') + @component('mail::subcopy') + {{ $subcopy }} + @endcomponent + @endslot + @endisset + + {{-- Footer --}} + @slot('footer') + @component('mail::footer') + © {{ date('Y') }} {{ config('app.name') }}. + @endcomponent + @endslot +@endcomponent diff --git a/resources/views/vendor/mail/text/panel.blade.php b/resources/views/vendor/mail/text/panel.blade.php new file mode 100644 index 000000000..3338f620e --- /dev/null +++ b/resources/views/vendor/mail/text/panel.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/subcopy.blade.php b/resources/views/vendor/mail/text/subcopy.blade.php new file mode 100644 index 000000000..3338f620e --- /dev/null +++ b/resources/views/vendor/mail/text/subcopy.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/table.blade.php b/resources/views/vendor/mail/text/table.blade.php new file mode 100644 index 000000000..3338f620e --- /dev/null +++ b/resources/views/vendor/mail/text/table.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php new file mode 100644 index 000000000..2a8ebddc8 --- /dev/null +++ b/resources/views/vendor/notifications/email.blade.php @@ -0,0 +1,66 @@ +@component('mail::message') +{{-- Greeting --}} +@if (! empty($greeting)) +# {{ $greeting }} +@else +@if ($level === 'error') +# @lang('Whoops!') +@else +# @lang('Hello!') +@endif +@endif + +@slot('header') + +@endslot + +{{-- Intro Lines --}} +@foreach ($introLines as $line) +{{ $line }} + +@endforeach + +{{-- Action Button --}} +@isset($actionText) + +@component('mail::button', ['url' => $actionUrl, 'color' => $color]) +{{ $actionText }} +@endcomponent +@endisset + +{{-- Outro Lines --}} +@foreach ($outroLines as $line) +{{ $line }} + +@endforeach + +{{-- Salutation --}} +@if (! empty($salutation)) +{{ $salutation }} +@else +@lang('Regards'),
+{{ config('app.name') }} +@endif + +{{-- Subcopy --}} +@isset($actionText) +@slot('subcopy') +@lang( + "If you're having trouble clicking the \":actionText\" button, copy and paste the URL below\n". + 'into your web browser:', + [ + 'actionText' => $actionText, + ] +) [{{ $displayableActionUrl }}]({{ $actionUrl }}) +@endslot +@endisset +@endcomponent