]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6201 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Aug 2023 13:42:38 +0000 (15:42 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Aug 2023 13:42:38 +0000 (15:42 +0200)
.docker/config/php/php.ini
app/Fluidbook/Compiler/Compiler.php
app/Fluidbook/Compiler/Stats.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/CompositionOperation.php
app/Jobs/FluidbookDocumentFileProcess.php
app/Models/FluidbookDocument.php
app/Models/ToolSVGSprite.php

index ddf9bce575be281986fc91521d552faacbecbf11..358c959423a39b9d7e0b93bf583f20a8f8024b5e 100644 (file)
@@ -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
index 0b583ef6228d08be4a5fe4fe863eb0eeef7b973d..946bac89dfa36a8addb6b5e61ff307fb1a6c0ecc 100644 (file)
@@ -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']) {
index ad83a16ab648f9129fe977146479a6fdf0c118ba..40903875cf0c7440d11e4d8851d79bf981c32aec 100644 (file)
@@ -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 .= '<script>window.tc_vars=' . json_encode($this->config->tagcommander_default_vars) . ';</script><script src="//cdn.tagcommander.com/' . $id . '/' . $scriptNames[0] . '"></script>';
index bd729627ea19df837da863df35c63d591f5732a0..3bccbef75b0ca06c24ef544c46be32e56b923902 100644 (file)
@@ -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()];
index 6241d7484e259db0571c9fafc7e841963447cc0e..5db7f88d32ac6cce28c1540b18c3776694d53ca0 100644 (file)
@@ -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;
+    }
 }
index f04ae8a5d516b32dffad722d4ab14b4b55a61bbf..9511ca1eb2d12390b823ae5948b1511e278b25e9 100644 (file)
@@ -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);
         }
index 6284d97019146a183482ed543cee875e31149ed5..b69800001a4e4c049ed07f4023f3608127f41f92 100644 (file)
@@ -51,7 +51,8 @@ class ToolSVGSprite extends ToolboxModel
 
     public function generate()
     {
-        $res = '<div class="svg-sprite" style="height: 0;width: 0;position: absolute;" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" style="display: none;">';
+        $res = '{{--' . "\n\n" . 'Downloaded from ' . backpack_url('tool-sprite/' . $this->id . '/download')  . "\n" . 'Edit here : ' . backpack_url('tool-sprite/' . $this->id . '/edit') . "\n\n" . '--}}';
+        $res .= '<div class="svg-sprite" style="height: 0;width: 0;position: absolute;" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" style="display: none;">';
         foreach ($this->icons as $icon) {
             if (preg_match('/<svg(.*)viewBox="([^\"]+)"([^>]*)?>(.*)<\/svg>/ms', $icon['svgcode'], $matches)) {
                 $svg = $matches[4];