From c830b6562a58be47ab7be2aefc8a3c1408c1cf07 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 16 Jul 2021 14:48:35 +0200 Subject: [PATCH] wait #4592 @2 --- app/Jobs/GenerateThemePreview.php | 2 +- app/Models/FluidbookTheme.php | 22 +++++++++++++++++- .../views/fluidbook_theme/preview.blade.php | 23 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 resources/views/fluidbook_theme/preview.blade.php diff --git a/app/Jobs/GenerateThemePreview.php b/app/Jobs/GenerateThemePreview.php index 4c327bff2..ff3ec14ef 100644 --- a/app/Jobs/GenerateThemePreview.php +++ b/app/Jobs/GenerateThemePreview.php @@ -52,7 +52,7 @@ class GenerateThemePreview implements ShouldQueue $cl->setArg('delay', 2); $cl->setArg('scale', 1); $cl->setArg('dest', $dest); - $cl->setArg('url', 'https://workshop.fluidbook.com/viewerh/20098-' . $this->theme->getIdValue() . '_f2e0452eed6dba9878016ce5603fdc54_' . time() . '/?shortLoading=1#/page/2'); + $cl->setArg('url', $this->theme->getPreviewURL(['shortLoading'=>1])); $cl->execute(); } } diff --git a/app/Models/FluidbookTheme.php b/app/Models/FluidbookTheme.php index 2bfe9f8d6..692d3fb3f 100644 --- a/app/Models/FluidbookTheme.php +++ b/app/Models/FluidbookTheme.php @@ -44,6 +44,12 @@ class FluidbookTheme extends CubistMagicAbstractModel $this->setSettingsFields(); } + public function setup() + { + parent::setup(); + $this->addAdditionalEditView('fluidbook_theme.preview'); + } + public function setSettingsFields() { $this->addField([ @@ -692,7 +698,7 @@ class FluidbookTheme extends CubistMagicAbstractModel $data[] = ['theme_id' => $theme->id, 'signature' => 0, 'nom' => $theme->name, 'proprietaire' => $theme->owner, 'icones' => $theme->iconSet, 'date' => strtotime($theme->creation_date), 'parametres' => json_encode($settings)]; $dest = $t3dir . '/' . $theme->id . '.jpg'; - if(!file_exists($dest)) { + if (!file_exists($dest)) { $preview = storage_path('themes/' . $theme->id . '.jpg'); `ln -s $preview $dest`; } @@ -869,6 +875,20 @@ class FluidbookTheme extends CubistMagicAbstractModel } } + public function getPreviewURL($params = [], $page = 2) + { + if (count($params) > 0) { + $get = []; + foreach ($params as $k => $v) { + $get = [$k . '=' . urlencode($v)]; + } + $get = '?' . implode('&', $get); + }else{ + $get=''; + } + return 'https://workshop.fluidbook.com/viewerh/20098-' . $this->getIdValue() . '_f2e0452eed6dba9878016ce5603fdc54_' . time() . '/' . $get . '#/page/' . $page; + } + protected static function _unserialize($str) { diff --git a/resources/views/fluidbook_theme/preview.blade.php b/resources/views/fluidbook_theme/preview.blade.php new file mode 100644 index 000000000..15f58277d --- /dev/null +++ b/resources/views/fluidbook_theme/preview.blade.php @@ -0,0 +1,23 @@ +@php + $previewURL=$crud->entry->getPreviewURL(['widget'=>1,'action'=>'fullscreen'],0) +@endphp + +@section('form_below_shortcuts') + +
+ +
+@endsection -- 2.39.5