]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7786
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 9 Oct 2025 16:41:39 +0000 (18:41 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 9 Oct 2025 16:41:39 +0000 (18:41 +0200)
app/Fluidbook/Compiler/Compiler.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php
app/Http/Controllers/Admin/Operations/Tools/FluidbookSecurePage.php
app/Models/FluidbookPublication.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php

index ac6c6adff668449e545d263fb0bc2a3a2bec635f..b58c917456c1fff92a849c35555bcd4a9c6075b3 100644 (file)
@@ -309,7 +309,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
      * @throws \Exception
      */
 
-    function __construct(FluidbookPublication $book, $scormVariant = false, $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
+    function __construct(FluidbookPublication $book, $variant = 'online', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
     {
         ExcelToArray::setCache($book->protected_path('fluidbookpublication/cache/exceltoarray'));
         YoutubeDL::setCookiesFile(resource_path('yt-dlp/cookies.txt'), 'firefox');
@@ -326,7 +326,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
         $this->multiApp = $this->home = $home;
         $this->devversion = /*$this->getFluidbook()->version < 3 ? "dev" : */
             $this->getFluidbook()->mobileLVersion;
-        $this->scormVariant = $scormVariant;
+        $this->scormVariant = $variant==='scorm';
 
         $this->hybrid = $hybrid;
 
@@ -344,7 +344,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
 
         $this->log('Start compilation');
 
-        $this->dir = $this->getFluidbook()->getFinalPath($theme, $scormVariant);
+        $this->dir = $this->getFluidbook()->getFinalPath($theme, $variant);
         $this->vdir = new VirtualDirectory($this->dir);
         $this->vdir->setLogger($this);
         $this->vdir->setErrorListener($this);
@@ -2648,9 +2648,9 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
      * @return void
      * @throws \Exception
      */
-    public static function compile($fluidbook, $scormVariant = false, $hybrid = false, $sync = false)
+    public static function compile($fluidbook, $variant = 'online', $hybrid = false, $sync = false)
     {
-        $compiler = new static($fluidbook instanceof FluidbookPublication ? $fluidbook : FluidbookPublication::withoutGlobalScopes()->find($fluidbook), scormVariant: $scormVariant, hybrid: $hybrid);
+        $compiler = new static($fluidbook instanceof FluidbookPublication ? $fluidbook : FluidbookPublication::withoutGlobalScopes()->find($fluidbook), variant: $variant, hybrid: $hybrid);
         if ($sync) {
             $compiler->handle();
         } else {
index 3b517cbae75c95b9d15add51e391e9c994f979d3..7b023274239fd4ec60dc4b7599ea43b62f731bff 100644 (file)
@@ -134,7 +134,7 @@ trait PreviewOperation
             $skipCompile = false;
         }
 
-        $dest = $fluidbook->getFinalPath($theme, $isScorm);
+        $dest = $fluidbook->getFinalPath($theme, $version?:'online');
         if ($path === 'index.html') {
             $fluidbook->incrementPreviewVisit();
             if (!$skipCompile) {
@@ -155,6 +155,7 @@ trait PreviewOperation
             $html = str_replace('<head>', '<head><script>FORCE_SCORM=true;</script>', $html);
             return $html;
         }
+
         return XSendFileController::sendfile($relayPath);
     }
 
index 9db70d118138ef207bf47d04886396373bb981e5..b86def309e549590be73447df107d169a3c7996a 100644 (file)
@@ -35,7 +35,7 @@ trait FluidbookSecurePage
         $fluidbook = FluidbookPublication::withoutGlobalScopes()->find(request()->get('fluidbook'));
         $fluidbook->secureClientSidePassword = '___secure.html';
         move_uploaded_file(request()->allFiles()['template']->getPathname(), $fluidbook->getAssetDir() . '/___secure.html');
-        Compiler::compile($fluidbook, false, false, true);
+        Compiler::compile($fluidbook, 'online', false, true);
         $final = $fluidbook->getFinalPath();
 
         // TODO : add other assets by parsing html and finding needed assets (images, logo)
index 25f4b2b9c126f82bb96432fba66672f6baacf56f..ea43c581b3817d2de3297bec7dc5aa5ba06f7e73 100644 (file)
@@ -695,7 +695,7 @@ class FluidbookPublication extends ToolboxStatusModel
         return $this->region;
     }
 
-    public function getFinalPath($theme = null, $scormVariant = false)
+    public function getFinalPath($theme = null, $variant = 'online')
     {
         $dir = $this->id;
 
@@ -708,7 +708,7 @@ class FluidbookPublication extends ToolboxStatusModel
         if (null !== $theme && ($themeId != $this->theme)) {
             $dir .= '-' . $themeId;
         }
-        return $this->protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
+        return $this->protected_path('fluidbookpublication/final/' . $dir . '/' . ($variant));
     }
 
     public function _getFreeFileRootDirectory()
index a22b6df3ed1144ee32b3a744100ca9defe98cf89..9af110f6e1049a2beceeadba900d8cbca27b9308 100644 (file)
@@ -4,6 +4,10 @@
     $suffixv3='';
     $previewURL=$crud->route.'/preview/'.$entry->getKey().'_'.$entry->hash;
     $actions['preview']=['label'=>__('Version online'),'url'=>$previewURL,'target'=>'_blank'];
+    if($entry->hosting_loadbalancer){
+        $previewNLB=$crud->route.'/preview/nolb/'.$entry->getKey().'_'.$entry->hash;
+        $actions['preview_nolb']=['label'=>__('Version online'). ' ('.__('sans loadbalancer').')','url'=>$previewNLB,'target'=>'_blank'];
+    }
     if($entry->isSCORMEnabled()){
         $actions['scorm']=['label'=>__('Version SCORM'),'url'=>$crud->route.'/preview/scorm/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
     }