]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6278 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Oct 2023 09:43:29 +0000 (11:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Oct 2023 09:43:29 +0000 (11:43 +0200)
app/Fluidbook/Compiler/Compiler.php
resources/tools/dockerwebcontainer/base
resources/tools/dockerwebcontainer/elasticsearch
resources/tools/dockerwebcontainer/matomo
resources/tools/dockerwebcontainer/mysql
resources/tools/dockerwebcontainer/php
resources/tools/dockerwebcontainer/redis
resources/tools/dockerwebcontainer/template/config/cron/crontab
resources/tools/dockerwebcontainer/template/images/elasticsearch/Dockerfile [new file with mode: 0644]
resources/tools/dockerwebcontainer/template/images/php-fpm/Dockerfile

index 5922d57aca2f0773c2f32bbbd571eb9f82a90f4b..6dfc6d039e315f66d1c91b4e42eac8f4a80925bf 100644 (file)
@@ -170,7 +170,7 @@ class Compiler extends Base implements CompilerInterface
         ],
     ];
 
-    protected $specialJsFiles = array();
+    protected $specialJsFiles = [];
 
 
     public $jsFiles = [];
@@ -179,21 +179,21 @@ class Compiler extends Base implements CompilerInterface
     // Filename with no extension, relative to the /style directory in the player build folder
     public $lessFiles = ['fluidbook'];
 
-    public $specialCSS = array();
+    public $specialCSS = [];
     public $phonegapStandardPlugins = array('ios' => array('ExternalFileUtil'),
         'android' => array('webintent'));
-    public $pluginCSS = array();
-    public $pluginJs = array();
-    public $htmlmultimedia = array();
-    public $cssX = array();
-    public $cssY = array();
-    public $cssWidths = array();
+    public $pluginCSS = [];
+    public $pluginJs = [];
+    public $htmlmultimedia = [];
+    public $cssX = [];
+    public $cssY = [];
+    public $cssWidths = [];
     public $pdf2htmlRatio;
     public $scale;
     public $multiply;
-    public $div = array();
+    public $div = [];
     public $numerotation;
-    public $fontDocs = array();
+    public $fontDocs = [];
     public $dir;
     public $z = 3;
     protected $_lottieIDByHash = [];
@@ -215,25 +215,25 @@ class Compiler extends Base implements CompilerInterface
     public $linkScale;
     public $optimalWidth = 567;
     public $optimalHeight = 709;
-    public $additionalConfig = array();
+    public $additionalConfig = [];
     public $fontScale = 1;
-    public $cache = array();
-    public $backgroundsPrefix = array();
+    public $cache = [];
+    public $backgroundsPrefix = [];
     public $svg = true;
     public $assets = '';
     public $phonegap = false;
     public $phonegapVersion;
     public $standalone = false;
-    public $hiddenContents = array();
+    public $hiddenContents = [];
     public $appcache;
     public $home;
     public $widget = true;
     public $multiApp = false;
-    public $pageLabels = array();
-    public $stylesheets = array();
+    public $pageLabels = [];
+    public $stylesheets = [];
     public $logfp = null;
     public $logtime = null;
-    public $beginBody = array();
+    public $beginBody = [];
 
     public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com', '*.googletagmanager.com'];
     public $writeLinksData = false;
@@ -793,7 +793,7 @@ class Compiler extends Base implements CompilerInterface
         $e = explode("\n", $this->fluidbookSettings->mobilePlugins);
         $main = array_pop($this->jsFiles);
 
-        $plugins = array();
+        $plugins = [];
 
         foreach ($e as $plugin) {
             $plugin = trim($plugin);
@@ -897,6 +897,12 @@ class Compiler extends Base implements CompilerInterface
     public function getIndexVars()
     {
         if (null === $this->_indexVars) {
+            $assetsPrefix = '';
+            if ($this->fluidbookSettings->hosting_loadbalancer) {
+                $assetsPrefix = 'https://s1.lb.fluidbook.com/' . $this->book_id . '_' . $this->_fluidbook->hash . '/';
+            }
+
+
             $titre = $this->fluidbookSettings->title;
 
             if (null === $this->_signature) {
@@ -905,15 +911,14 @@ class Compiler extends Base implements CompilerInterface
             } else {
                 $credits = '';
             }
-            $hiddenContents = implode("\n", $this->hiddenContents);
             $bgcolor = $this->themeSettings->loadingBackColor;
 
             // Feuilles de style
             $sheets = array_merge($this->stylesheets, $this->specialCSS);
 
-            $style = array();
+            $style = [];
             foreach ($sheets as $sheet) {
-                $style[] = '<link type="text/css" rel="stylesheet" media="screen" href="' . $sheet . '?j=' . time() . '">';
+                $style[] = '<link type="text/css" rel="stylesheet" media="screen" href="' . $assetsPrefix . $sheet . '?j=' . time() . '">';
             }
             $style = implode("\n\t\t", $style);
 
@@ -927,6 +932,7 @@ class Compiler extends Base implements CompilerInterface
 
             $jstime = "?j=" . time();
 
+
             $iscript = '';
             if (count($this->htmlmultimedia)) {
                 $iscript .= '<script type="text/javascript">' . "\n";
@@ -934,18 +940,18 @@ class Compiler extends Base implements CompilerInterface
                 $iscript .= '</script>' . "\n";
             }
 
-            $script = '<script type="text/javascript" charset="utf-8" src="data/datas.js' . $jstime . '"></script>' . "\n";
+            $script = '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/datas.js' . $jstime . '"></script>' . "\n";
             foreach ($this->jsLibs as $jsLib => $files) {
-                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="data/' . $jsLib . '.js' . $jstime . '"></script>' . "\n";
+                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/' . $jsLib . '.js' . $jstime . '"></script>' . "\n";
             }
             if ($this->fluidbookSettings->scorm_enable) {
-                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="data/scorm.js' . $jstime . '"></script>' . "\n";
+                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/scorm.js' . $jstime . '"></script>' . "\n";
             }
             if (count($this->specialJsFiles)) {
-                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="data/special.js' . $jstime . '"></script>' . "\n";
+                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . 'data/special.js' . $jstime . '"></script>' . "\n";
             }
             foreach ($this->pluginJs as $p) {
-                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $p . $jstime . '"></script>' . "\n";
+                $script .= "\t" . '<script type="text/javascript" charset="utf-8" src="' . $assetsPrefix . $p . $jstime . '"></script>' . "\n";
             }
             $script .= $iscript;
 
@@ -991,7 +997,7 @@ class Compiler extends Base implements CompilerInterface
                 $datapng = 'data:image/png;base64,' . base64_encode(file_get_contents($pngFile));
 
                 $favicon .= '<link rel="icon" type="image/png" href="' . $datapng . '" />' . "\n\t";
-                $favicon .= '<link rel="apple-touch-icon" href="data/apple-touch-icon.png" />';
+                $favicon .= '<link rel="apple-touch-icon" href="' . $assetsPrefix . 'data/apple-touch-icon.png" />';
             }
 
             $print = $this->writePDF();
@@ -1082,7 +1088,7 @@ class Compiler extends Base implements CompilerInterface
             }
 
             $this->log('Got index vars 5');
-            $vars = array('lang', 'titre', 'credits', 'style', 'script', 'pagesContents', 'print', 'hiddenContents', 'splash', 'splashstyles', 'cache', 'bgcolor', 'message', 'favicon', 'svg', 'beginbody', 'csp', 'opengraph', 'twittercard', 'description', 'console');
+            $vars = array('lang', 'titre', 'credits', 'style', 'script', 'pagesContents', 'print', 'splash', 'splashstyles', 'cache', 'bgcolor', 'message', 'favicon', 'svg', 'beginbody', 'csp', 'opengraph', 'twittercard', 'description', 'console');
 
             $res = [];
             foreach ($vars as $v) {
@@ -1236,7 +1242,7 @@ class Compiler extends Base implements CompilerInterface
             return;
         }
         if (!isset($this->config->filesInfos)) {
-            $this->config->filesInfos = array();
+            $this->config->filesInfos = [];
         }
         $infos = array('filesize' => filesize($file));
         $dim = Image::getimagesize($file);
@@ -1262,7 +1268,7 @@ class Compiler extends Base implements CompilerInterface
 
         $multilang = Text::explodeNewLines($this->config->get('multilang', ''));
         if (count($multilang)) {
-            $m = array();
+            $m = [];
             foreach ($multilang as $line) {
                 $line = trim($line);
                 if ($line == '') {
@@ -1492,7 +1498,7 @@ class Compiler extends Base implements CompilerInterface
         $this->addPDFJS();
 
         if ($this->fluidbookSettings->scorm_enable) {
-            $finals['scorm'] = array();
+            $finals['scorm'] = [];
             $finals['scorm'][] = 'js/libs/scorm/apiwrapper.js';
             $finals['scorm'][] = 'js/libs/scorm/scorm.js';
         }
@@ -1630,6 +1636,7 @@ class Compiler extends Base implements CompilerInterface
                 $v = $data[$k] = !!$v;
             }
         }
+        $data['hiddenContents'] = implode('', $this->hiddenContents);
         $data['id'] = $this->book_id;
         $data['compiler'] = 3;
         return 'var SETTINGS=' . json_encode($data) . ';' . "\n";
@@ -1644,7 +1651,7 @@ class Compiler extends Base implements CompilerInterface
 
     protected function writeManifest()
     {
-        $res = array();
+        $res = [];
         // TODO: Why was this function missing a return statement? It's called from populateConfig() is expected to return a value.
         return $res;
     }
@@ -1701,7 +1708,7 @@ class Compiler extends Base implements CompilerInterface
 
     protected function writeCSS($links)
     {
-        $res = array();
+        $res = [];
 
         $this->addFontKit('OpenSans');
 
@@ -1943,7 +1950,7 @@ class Compiler extends Base implements CompilerInterface
         $from = $this->assets . '/style/*';
         `cp -r $from $tmp`;
 
-        $bookVariables = array();
+        $bookVariables = [];
         foreach ($variables as $k => $v) {
             $bookVariables[] = '@' . trim($k) . ':' . $v . ';';
         }
@@ -2072,7 +2079,7 @@ class Compiler extends Base implements CompilerInterface
 
     public static function writeCSSUA($property, $value)
     {
-        $res = array();
+        $res = [];
         foreach (self::$uaPrefixes as $prefix) {
             $res[] = $prefix . $property . ':' . $value;
         }
@@ -2235,7 +2242,7 @@ class Compiler extends Base implements CompilerInterface
 
         if (is_string($format)) {
             if ($format == 'none') {
-                $format = array();
+                $format = [];
             } elseif ($format == 'all') {
                 $format = $videos;
             } else {
@@ -2244,7 +2251,7 @@ class Compiler extends Base implements CompilerInterface
         }
 
         if (!$force) {
-            $format = array();
+            $format = [];
         }
 
 
@@ -2284,7 +2291,7 @@ class Compiler extends Base implements CompilerInterface
             $e = explode('.', $source);
             array_pop($e);
             $base = implode('.', $e);
-            $source = array();
+            $source = [];
             foreach ($types as $type) {
                 $source[] = $base . '.' . $type;
             }
@@ -2351,7 +2358,7 @@ class Compiler extends Base implements CompilerInterface
                 $res['height'] = intval((string)$meta->getAttribute('content'));
             }
 
-            $r = array('html' => 'index.html', 'inject' => array(), 'injectcss' => array(), 'injectjs' => array());
+            $r = array('html' => 'index.html', 'inject' => [], 'injectcss' => [], 'injectjs' => []);
         } else {
             $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js'));
         }
@@ -2386,7 +2393,7 @@ class Compiler extends Base implements CompilerInterface
 
     public static function getPhonegapVersions()
     {
-        $versions = array();
+        $versions = [];
         $phonegap_dir = resource_path('fluidbookpublication/phonegap');
 
         if (is_dir($phonegap_dir)) {
index 93716760f3163e420741d9eb790ac0d6731bfec5..d6a541f5490443ec4bf5908b5c112c07f2a1db59 100644 (file)
@@ -8,12 +8,9 @@ services:
             - './www/public/:/usr/local/apache2/htdocs/'
             - './www/:/application/'
             - './config/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf'
-        ports:
-            - '$port:80'
         environment:
             VIRTUAL_HOST: $domain
             LETSENCRYPT_HOST: $domain
         networks:
             - $name
         restart: unless-stopped
-
index e5d76ceffdb876a252707ba174ab8424bb538c53..2035df7548a310b2b04dcf92b5cf0519af903533 100644 (file)
@@ -1,12 +1,13 @@
     elasticsearch:
         container_name: $name-elasticsearch
-        image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
+        build: './images/elasticsearch'
         volumes:
           - ./esdata:/usr/share/elasticsearch/data
         environment:
-          - bootstrap.memory_lock=true
           - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
           - discovery.type=single-node
+          - xpack.security.enabled=false
         networks:
           - $name
         restart: unless-stopped
+
index a86901d29706194c7bad665fd8a70832b684da01..d70067557bee022691d13e2969607316c06bc349 100644 (file)
@@ -56,3 +56,4 @@
         - ./matomo/redis:/data
       networks:
         - $name
+
index 7d1003ecaf53a1ea9a2071079f0868ccb0e18aae..666d2159a87989ebc98a86a9a268cf77fe2716d4 100644 (file)
@@ -2,14 +2,13 @@
       image: 'adminer:latest'
       container_name: $name-adminer
       restart: unless-stopped
-      ports:
-        - $portadminer:8080
       environment:
         ADMINER_DEFAULT_SERVER: $name-mariadb
         VIRTUAL_HOST: adminer.$domain
         LETSENCRYPT_HOST: adminer.$domain
       networks:
         - $name
+
     mariadb:
         container_name: $name-mariadb
         image: 'mariadb:latest'
index d72b0ec0f9eae4c852d5bc012dade07c793e112a..40a6810eb84e7d4dc6af1cdccb1678135378e024 100644 (file)
@@ -29,3 +29,4 @@
         networks:
           - $name
         restart: unless-stopped
+
index cc1313cb81aa76de9a9f403ba51fa604abf388b1..299a41617589a9aba727406965f77e3fc8ccfe53 100644 (file)
@@ -6,3 +6,4 @@
         networks:
           - $name
         restart: unless-stopped
+
index ea5e3f9a350855f09d33967db5a9efb79ca264d9..72643719a3dcaa5ee11bbe523a8df3f9ae3343b9 100644 (file)
@@ -2,4 +2,5 @@ MAILTO=sysadmin@cubedesigners.com
 SHELL=/bin/sh
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
-
+* * * * *   runuser -l $name -c '/usr/bin/php /application/artisan schedule:run' > /proc/1/fd/1 2>/proc/1/fd/2
+# 20 5 * * *  /application/scripts/restartworkers > /proc/1/fd/1 2>/proc/1/fd/2
diff --git a/resources/tools/dockerwebcontainer/template/images/elasticsearch/Dockerfile b/resources/tools/dockerwebcontainer/template/images/elasticsearch/Dockerfile
new file mode 100644 (file)
index 0000000..3d66109
--- /dev/null
@@ -0,0 +1,2 @@
+FROM docker.elastic.co/elasticsearch/elasticsearch:8.10.2
+RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
index 12ba4acdf4cdbd5e28aef7095cc8428980dab164..36cc86301d6ea230bd7c8a404289369a99d38a18 100644 (file)
@@ -18,13 +18,13 @@ RUN apt update \
     && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \
     && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
 
+# Add Nodejs Repository
 RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
 RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
 
 RUN apt update
 
 RUN apt -y --no-install-recommends install \
-        ca-certificates \
         unzip \
         git \
         php$phpversion-apcu \