From: Vincent Vanwaelscappel Date: Mon, 21 Aug 2023 13:42:38 +0000 (+0200) Subject: wip #6201 @0:20 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a2596fe2aa92cbafa64e57d0bfe1f0d2463b9832;p=fluidbook-toolbox.git wip #6201 @0:20 --- diff --git a/.docker/config/php/php.ini b/.docker/config/php/php.ini index ddf9bce57..358c95942 100644 --- a/.docker/config/php/php.ini +++ b/.docker/config/php/php.ini @@ -1,5 +1,5 @@ -upload_max_filesize = 8G -post_max_size = 8G +upload_max_filesize = 100G +post_max_size = 100G error_log = /proc/self/fd/2 log_errors = 1 memory_limit = 12G diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 0b583ef62..946bac89d 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -414,6 +414,13 @@ class Compiler extends Base implements CompilerInterface $this->fluidbookSettings->set($key, $value); } + public function pushSetting($key, $value) + { + $v = $this->fluidbookSettings->get($key, []); + $v[] = $value; + $this->fluidbookSettings->set($key, $v); + } + /** * @param $key @@ -746,8 +753,17 @@ class Compiler extends Base implements CompilerInterface } + protected function _extranetToToolboxPath($path) + { + if (str_starts_with($path, '/application/fluidbook/books/working/')) { + return str_replace('/application/fluidbook/books/working/', '/application/protected/fluidbookpublication/working/', $path); + } + return $path; + } + protected function _wdirOrAbsolute($path) { + $path = $this->_extranetToToolboxPath($path); $e = explode('#', $path); if (file_exists($e[0])) { return $path; @@ -1847,8 +1863,8 @@ class Compiler extends Base implements CompilerInterface protected function _font($f) { - if(!$f){ - $f='OpenSans'; + if (!$f) { + $f = 'OpenSans'; } $font = FluidbookFont::getAvailableFonts()[$f]; if ($font['font_kit']) { diff --git a/app/Fluidbook/Compiler/Stats.php b/app/Fluidbook/Compiler/Stats.php index ad83a16ab..40903875c 100644 --- a/app/Fluidbook/Compiler/Stats.php +++ b/app/Fluidbook/Compiler/Stats.php @@ -30,7 +30,7 @@ trait Stats $default = ['page_name' => '']; $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->fluidbookSettings->tagcommander_default_vars)); - $this->config->tagcommander_default_vars['env_work'] = $this->fluidbookSettings->tagcommander_prod ? 'prod' : 'pre-prod'; + $this->config->set('tagcommander_default_vars.env_work', $this->fluidbookSettings->tagcommander_prod ? 'prod' : 'pre-prod'); $scriptNames = explode(',', $this->config->tagcommander_scriptname); $this->fluidbookSettings->googleAnalyticsCustom .= ''; diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php index bd729627e..3bccbef75 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php @@ -54,6 +54,9 @@ trait CompositionOperation $uploadID = Str::random(); $file = request()->file('file'); + if (null === $file) { + abort(500); + } $document = new FluidbookDocument(); $document->file = $file->getClientOriginalName(); $document->file_data = ["fileName" => $file->getClientOriginalName(), "fileSize" => $file->getSize(), "modificationDate" => $file->getMTime(), "creationDate" => $file->getCTime()]; diff --git a/app/Jobs/FluidbookDocumentFileProcess.php b/app/Jobs/FluidbookDocumentFileProcess.php index 6241d7484..5db7f88d3 100644 --- a/app/Jobs/FluidbookDocumentFileProcess.php +++ b/app/Jobs/FluidbookDocumentFileProcess.php @@ -22,6 +22,8 @@ class FluidbookDocumentFileProcess extends Base protected $path = ""; + protected $log = ''; + public function __construct($document, $page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false) { $this->onQueue('fluidbookprocess'); @@ -42,21 +44,25 @@ class FluidbookDocumentFileProcess extends Base public function handle() { $this->finish = false; - echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n"; + try { + echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n"; + } catch (\Exception $e) { + $this->log = $e->getMessage(); + } $this->finish = true; } /** * @return boolean */ - public function isDone() + public function isDone($forceCheck = false) { - return $this->finish || $this->isOK(); + return $this->finish || $this->isOK($forceCheck); } - public function isOK() + public function isOK($forceCheck = false) { - return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck); + return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck || $forceCheck); } public function isError() @@ -71,4 +77,8 @@ class FluidbookDocumentFileProcess extends Base { return $this->path; } + + public function getLog(){ + return $this->log; + } } diff --git a/app/Models/FluidbookDocument.php b/app/Models/FluidbookDocument.php index f04ae8a5d..9511ca1eb 100644 --- a/app/Models/FluidbookDocument.php +++ b/app/Models/FluidbookDocument.php @@ -15,6 +15,7 @@ use Cubist\PDF\PDFTools; use Cubist\Util\Gzip; use Cubist\Util\Math; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; // __('!!Paramètres des fluidbooks') class FluidbookDocument extends ToolboxModel @@ -261,13 +262,12 @@ class FluidbookDocument extends ToolboxModel public function _getPath($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html') { + $this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version); $cacheKey = $this->fileCacheKey($page, $format, $resolution, $quality, $withText, $withGraphics, $version); if (Cache::has($cacheKey)) { return Cache::get($cacheKey); } - $this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version); - $dir = $this->path($version) . '/'; if ($format === 'svg') { @@ -277,7 +277,7 @@ class FluidbookDocument extends ToolboxModel $file .= '-' . $resolution; } $file .= '.svg'; - } else if ($format === 'png' || $format === 'jpg') { + } else { $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : ''; $prefix = $withText ? 't' : 'h'; if ($resolution === 'thumb') { @@ -299,6 +299,9 @@ class FluidbookDocument extends ToolboxModel public function getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false) { $this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version); + if ($page == 1 && $version === 'mf') { + Log::debug('get file ' . $page . ', ' . $format . ', ' . $resolution . ', ' . $quality . ', ' . $withText . ', ' . $withGraphics . ', ' . $version . ', ' . $forceCheck . ', ' . $forceProcess); + } if ($forceProcess) { $this->removeFile($page, $format, $resolution, $withText, $withGraphics, $version); } diff --git a/app/Models/ToolSVGSprite.php b/app/Models/ToolSVGSprite.php index 6284d9701..b69800001 100644 --- a/app/Models/ToolSVGSprite.php +++ b/app/Models/ToolSVGSprite.php @@ -51,7 +51,8 @@ class ToolSVGSprite extends ToolboxModel public function generate() { - $res = '