]> _ Git - fluidbook-toolbox.git/commitdiff
wait #4592 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Jul 2021 12:48:35 +0000 (14:48 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Jul 2021 12:48:35 +0000 (14:48 +0200)
app/Jobs/GenerateThemePreview.php
app/Models/FluidbookTheme.php
resources/views/fluidbook_theme/preview.blade.php [new file with mode: 0644]

index 4c327bff295566a855fb409290ae417575697995..ff3ec14ef8bec67d5efd4ed7f4509c075c68fd7d 100644 (file)
@@ -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();
     }
 }
index 2bfe9f8d62018f1f2672e1b2b728a3229d465224..692d3fb3f3ba5c63623d317f2c9dc095835c4c1e 100644 (file)
@@ -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 (file)
index 0000000..15f5827
--- /dev/null
@@ -0,0 +1,23 @@
+@php
+    $previewURL=$crud->entry->getPreviewURL(['widget'=>1,'action'=>'fullscreen'],0)
+@endphp
+
+@section('form_below_shortcuts')
+    <style type="text/css">
+        #themePreview {
+            position: relative;
+            padding-bottom: 75%;
+        }
+
+        #themePreview iframe {
+            position: absolute;
+            top: 0;
+            left: 0;
+            width: 100%;
+            height: 100%;;
+        }
+    </style>
+    <div class="card" id="themePreview">
+        <iframe src="{{$previewURL}}" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>
+    </div>
+@endsection