From: Vincent Vanwaelscappel Date: Thu, 9 Oct 2025 16:41:39 +0000 (+0200) Subject: wip #7786 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=1053070cc3be44ffd9f74a00889cacb92a77ba22;p=fluidbook-toolbox.git wip #7786 --- diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index ac6c6adff..b58c91745 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -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 { diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php index 3b517cbae..7b0232742 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php @@ -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('', '', $html); return $html; } + return XSendFileController::sendfile($relayPath); } diff --git a/app/Http/Controllers/Admin/Operations/Tools/FluidbookSecurePage.php b/app/Http/Controllers/Admin/Operations/Tools/FluidbookSecurePage.php index 9db70d118..b86def309 100644 --- a/app/Http/Controllers/Admin/Operations/Tools/FluidbookSecurePage.php +++ b/app/Http/Controllers/Admin/Operations/Tools/FluidbookSecurePage.php @@ -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) diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 25f4b2b9c..ea43c581b 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -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() diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php index a22b6df3e..9af110f6e 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php @@ -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']; }