]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5898 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 9 May 2023 08:18:34 +0000 (10:18 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 9 May 2023 08:18:34 +0000 (10:18 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/SocialImageOperation.php

index 04e86eb86dc83ab5ce792a879e4d5a7331d3e876..96f40e9744dd7e6c977d6f3e99d96289c356f46b 100644 (file)
@@ -22,7 +22,8 @@ trait PreviewOperation
         })->where('id', '([0-9]+)(-[0-9]+)?')
             ->whereAlpha('version')
             ->where('hash', '[0-9a-f]{32}')
-            ->withoutMiddleware([CheckIfAdmin::class]);
+            ->withoutMiddleware([CheckIfAdmin::class])
+            ->name('fluidbook_preview');
 
         Route::match(['get'], $segment . '/preview/{version}/{id}_{hash}_{time}/{path?}', function ($version, $id, $hash, $time, $path = 'index.html') use ($segment, $controller) {
             return $this->_preview($segment, $version, $id, $hash, $time, $path);
@@ -30,7 +31,8 @@ trait PreviewOperation
             ->where('hash', '[0-9a-f]{32}')
             ->where('path', '.*')
             ->whereAlpha('version')
-            ->withoutMiddleware([CheckIfAdmin::class]);
+            ->withoutMiddleware([CheckIfAdmin::class])
+            ->name('fluidbook_preview_with_time');
 
         $this->_baseRoutes($segment, $controller);
     }
index c8eb25da79de183a522961ab8a838741bed10f05..65c781caa966b75007b3342e0d2cfaede6998f3b 100644 (file)
@@ -47,7 +47,7 @@ trait SocialImageOperation
 
     public static function socialImagePath($id, $ext = 'jpg')
     {
-        return Files::mkdir(protected_path('fluidbookpublication/socialimage')) . '/' . $id . '.' . $ext;
+        return Files::mkdir(protected_path('fluidbookpublication/socialimage')) . $id . '.' . $ext;
     }
 
     /**
@@ -89,8 +89,8 @@ trait SocialImageOperation
                 if (!file_exists($lock) || filemtime($lock) < time() - 3600) {
                     touch($lock);
 
-                    $params = ['nointerface' => 1, 'force' => (file_exists($res) && filemtime($res) < $limit) || isset($_GET['forcecompile'])];
-                    $url = backpack_url('/fluidbook-publication/preview/' . $id . '_' . $fluidbook->hash . '_' . time() . '/', $params);
+                    $force = (file_exists($res) && filemtime($res) < $limit) || isset($_GET['forcecompile']);
+                    $url = route('fluidbook_preview_with_time', ['version' => 'online', 'id' => $id, 'hash' => $fluidbook->hash, 'time' => time(), 'nointerface' => 1, 'force' => $force ? '1' : '0']);
 
                     $w = 1200;
                     $h = 628;