]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5611 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 31 Mar 2023 15:49:25 +0000 (17:49 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 31 Mar 2023 15:49:25 +0000 (17:49 +0200)
.docker/config/supervisor/ws2-worker.conf
app/Fluidbook/Links.php
app/Fluidbook/Packager/Download.php
app/Jobs/FluidbookCollectionDownload.php
app/Jobs/FluidbookCompiler.php
app/Jobs/FluidbookPackage.php
composer.lock

index d5d556ebf96c91a406b4e32681bfa1b591c68651..4b238f8d476b58f22d7937ba849cdc46f2705ad0 100644 (file)
@@ -5,7 +5,7 @@ autostart=true
 autorestart=true
 user=toolbox
 group=www-data
-numprocs=4
+numprocs=12
 redirect_stderr=true
 stdout_logfile=/proc/self/fd/2
 stopwaitsecs=3600
index 9236e3d9aea6efcf875674810b6d44ac555d4100..b7a601dec54653c3929b9debc49e3f3f819d91d5 100644 (file)
@@ -136,7 +136,7 @@ class Links
     }
 
 
-    public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = 'latest')
+    public static function getLinksAndRulers($book_id, &$links, &$rulers, $time = 'latest',$forceDecrypt=false)
     {
         if (null === $time) {
             $time = 'latest';
@@ -176,7 +176,7 @@ class Links
         $links = self::_UID($r['links']);
         $rulers = self::_UID($r['rulers']);
 
-        if (can('fluidbook-publication:links:edit-animations')) {
+        if ($forceDecrypt || can('fluidbook-publication:links:edit-animations')) {
             $links = Link::decryptLinks($links);
         } else {
             $links = Link::encryptLinks($links);
index dd0cbca951c58fbda376e659c7e8d79867f17ab4..54099c86f8bda8608c9f09f4567195600a95f584 100644 (file)
@@ -6,6 +6,8 @@ use App\Jobs\DownloadBase;
 use App\Models\FluidbookExternalInstallServer;
 use App\Services\ScormCloud;
 use Cubist\Backpack\Facades\App;
+use Cubist\Backpack\Magic\Models\ExternalServer;
+use Cubist\Net\Transfer\Driver;
 use Cubist\Util\CommandLine\Rsync;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Text;
@@ -99,7 +101,7 @@ class Download extends DownloadBase
                 }
             } else if ($this->action === 'install') {
                 $s = $this->entry->install_online;
-                $dest = self::_cleanInstallDir($s['path']);
+                $dest = Driver::cleanInstallDir($s['path']);
                 /** @var FluidbookExternalInstallServer $server */
                 $server = FluidbookExternalInstallServer::find($s['server']);
                 if (!$server) {
@@ -134,13 +136,6 @@ class Download extends DownloadBase
         $this->sendNotification($subject, $text, $actions, $showTextIfNotEmail);
     }
 
-    protected static function _cleanInstallDir($path)
-    {
-        $path = str_replace('/\.{2,}/', '', $path);
-        $path = preg_replace('/\/{2,}/', '/', $path);
-        $path = trim($path, '/');
-        return Text::str2URL($path, '-', true);
-    }
 
     protected function _compileandpackage($zip = true)
     {
index 281fb602df7c72b14026e1c6841085e7115f41d5..341de97a4bda586784b7575edbc3b3340be5b578 100644 (file)
@@ -4,8 +4,10 @@ namespace App\Jobs;
 
 use App\Console\Commands\WorkshopMigration;
 use App\Fluidbook\Packager\Packager;
+use App\Models\FluidbookExternalInstallServer;
 use App\Models\FluidbookPublication;
 use Cubist\Backpack\Magic\PageData;
+use Cubist\Net\Transfer\Driver;
 use Cubist\Util\CommandLine\Rsync;
 use Cubist\Util\Files\Files;
 use Cubist\Util\PHP;
@@ -26,16 +28,35 @@ class FluidbookCollectionDownload extends DownloadBase
     {
         $translateVariables = $this->_getTranslateVariables();
         if ($this->action === 'install') {
-            $url = $this->installHosting($this->entry->getPageData());
-            $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur hosting', $translateVariables), '', $url);
+            $s = $this->entry->install;
+            $dest = Driver::cleanInstallDir($s['path']);
+            /** @var FluidbookExternalInstallServer $server */
+            $server = FluidbookExternalInstallServer::find($s['server']);
+            if (!$server) {
+                throw new \Exception('No valid server defined for external installation');
+            }
+            if (!$dest) {
+                throw new \Exception('No path defined for external server installation');
+            }
+
+            $translateVariables['server'] = $server->name;
+            $url = $this->install($dest, $server);
+            $this->sendNotification(__('Collection ":title" (#:nb) installée sur le serveur :server', $translateVariables), __('La collection ":title" a été installée sur le serveur :server', $translateVariables), [__('Voir sur :server', $translateVariables) => $url]);
         } else if ($this->action === 'export' && in_array($this->entry->version, ['win_inss_html', 'win_ins_html'])) {
             $url = $this->downloadList($this->entry->getPageData());
-            $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text, $translateVariables), $url);
+            $this->sendNotification(__($this->_subject, $translateVariables), __($this->_text, $translateVariables), [__('Télécharger') => $url]);
         } else {
             parent::handle();
         }
     }
 
+    public function install($dest, $server)
+    {
+        $path = $this->_compile();
+        $driver = $server->getTransferDriver();
+        $driver->copy($path, $dest, false, false);
+        return $server->makeURL($dest);
+    }
 
     protected function _compile()
     {
@@ -46,7 +67,7 @@ class FluidbookCollectionDownload extends DownloadBase
 
     /**
      * @param $path
-     * @return null
+     * @return void
      * @throws \Exception
      */
     public function compile($path)
@@ -56,13 +77,12 @@ class FluidbookCollectionDownload extends DownloadBase
 
         PHP::neverStop();
         if ($data->type === 'scorm_multilang') {
-            $res = $this->compileMultilang($data, $path, true);
+            $this->compileMultilang($data, $path, true);
         } else if ($data->type === 'export_multilang') {
-            $res = $this->compileMultilang($data, $path, false);
+            $this->compileMultilang($data, $path, false);
         } elseif ($data->type === 'export') {
-            $res = $this->compileExport($data, $path);
+            $this->compileExport($data, $path);
         }
-        return $res;
     }
 
     protected function getCollectionGlobalSettings()
@@ -89,7 +109,7 @@ class FluidbookCollectionDownload extends DownloadBase
         $langs = [];
         $countries = [];
 
-        $defaultFlags = ['en' => 'gb', 'sv' => 'se'];
+        $defaultFlags = ['en' => 'gb', 'sv' => 'se', 'zh' => 'cn'];
 
         $fluidbooks = [];
 
@@ -127,7 +147,7 @@ class FluidbookCollectionDownload extends DownloadBase
 
         $jobs = [];
         foreach ($fluidbooks as $fbid => $publication) {
-            $jobs[] = $this->_jobDownloadFluidbook($fbid, $scorm ? 'scorm' : $data->version, $path . $langs[$fbid], $options);
+            $jobs[] = $this->_jobDownloadFluidbook($fbid, $scorm ? 'scorm' : 'online', $path . $langs[$fbid], $options);
         }
         $this->_waitJobs($jobs);
 
@@ -211,11 +231,13 @@ class FluidbookCollectionDownload extends DownloadBase
         $job->setBookId($id);
         $job->setVersion($version);
         $job->setOptions($options);
-        $job->setAction('export');
         $job->setJobName('export_' . $id);
         $job->setDestination($dest);
-        $f = $async ? 'dispatch' : 'dispatchSync';
-        $f($job)->onQueue('ws2');
+        if ($async) {
+            dispatch($job)->onQueue('ws2');
+        } else {
+            $job->handle();
+        }
         return $job;
     }
 
@@ -238,7 +260,7 @@ class FluidbookCollectionDownload extends DownloadBase
     {
         $nbjobs = count($jobs);
         $done = 0;
-        foreach ($jobs as $label => $job) {
+        foreach ($jobs as $job) {
             if ($job->isDone()) {
                 $done++;
             }
index 1399ea484efbae8485d24585e98600c83fdaae57..19a08dbb4cfc7c536b52aba94aad9ab320f216ac 100644 (file)
@@ -671,7 +671,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $file = $cdir . $this->fluidbookSettings->basketReferences;
         $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file);
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links,$rulers);
 
         foreach ($links as $link) {
             if ($link['type'] == '12') {
@@ -685,6 +685,10 @@ class FluidbookCompiler extends Base implements CompilerInterface
         }
     }
 
+    public function getLinksAndRulers(&$links, &$rulers){
+        Links::getLinksAndRulers($this->book_id, $links, $rulers,'latest',true);
+    }
+
     public function writeMIFCart()
     {
         $this->lessVariables['import-cart-styles'] = 'mif';
@@ -702,7 +706,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $file = $cdir . $this->fluidbookSettings->basketReferences;
         $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file);
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links, $rulers);
 
         foreach ($this->config->basketReferences as $ref => $data) {
             $source = $cdir . '/' . $data['Image'];
@@ -784,7 +788,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
             $this->vdir->copy($cdir . $f, 'data/commerce/' . $f);
         }
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links, $rulers);
     }
 
     public function writeGrandPavoisCart()
@@ -804,7 +808,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $file = $cdir . $this->fluidbookSettings->basketReferences;
         $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($file);
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links, $rulers);
     }
 
 
@@ -825,7 +829,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
             $this->config->eanReferences = ExcelToArray::excelToArrayIndexKeyVars($eanFile);
         }
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links, $rulers);
         foreach ($links as $link) {
             if ($link['type'] == '12' && isset($this->config->basketReferences[$link['to']])) {
                 $this->config->basketReferences[$link['to']]['zoom_image'] = 'data/links/zoom_' . $link['uid'] . '.jpg';
@@ -2160,7 +2164,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $this->vdir->copyDirectory($d['dir'], $d['fdir']);
         }
 
-        Links::getLinksAndRulers($this->book_id, $links, $rulers);
+        $this->getLinksAndRulers($links, $rulers);
         $this->_fluidbook->normalizeLinks($links);
 
         if ($this->fluidbookSettings->basketManager === 'Puma') {
@@ -2514,11 +2518,11 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     {
         Log::error($e);
 
-        $c = explode('\\', get_class($link));
+        /*$c = explode('\\', get_class($link));
         $type = array_pop($c);
         $type = str_replace('Link', '', $type);
 
-        throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . '  with message : ' . $e->getMessage());
+        throw new \Exception('Error on the ' . $type . ' link to ' . $link->to . ' on page ' . $link->page . '  with message : ' . $e->getMessage());*/
     }
 
     protected function _htmlLinkList($list)
index b2bb5a08485ff579b92696ace802e90a2ec4c6f3..e1e620d1f372f03ed51b51eb5c732ef019a365ca 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Jobs;
 
 use App\Fluidbook\Packager\Packager;
+use Cubist\Util\CommandLine\Rsync;
 use Illuminate\Support\Facades\Log;
 
 class FluidbookPackage extends Base
@@ -20,7 +21,9 @@ class FluidbookPackage extends Base
     {
         try {
             $packager = Packager::package($this->getBookId(), $this->getVersion(), false, true, $this->getOptions());
-            $this->setResult($packager->getFinalPath());
+            $packager->handle();
+            (new Rsync($packager->getFinalPath(),$this->getDestination()))->execute();
+            $this->setResult(true);
         } catch (\Exception $e) {
             $this->setException($e);
         }
index 56983e439b4eb9ca0c20ec0704a1843b6fc5e4fb..53d4d0f311cdefda93d80ecb1076f8f8616b518b 100644 (file)
         },
         {
             "name": "brick/math",
-            "version": "0.10.2",
+            "version": "0.11.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/brick/math.git",
-                "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f"
+                "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f",
-                "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f",
+                "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478",
+                "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478",
                 "shasum": ""
             },
             "require": {
-                "ext-json": "*",
-                "php": "^7.4 || ^8.0"
+                "php": "^8.0"
             },
             "require-dev": {
                 "php-coveralls/php-coveralls": "^2.2",
                 "phpunit/phpunit": "^9.0",
-                "vimeo/psalm": "4.25.0"
+                "vimeo/psalm": "5.0.0"
             },
             "type": "library",
             "autoload": {
             ],
             "support": {
                 "issues": "https://github.com/brick/math/issues",
-                "source": "https://github.com/brick/math/tree/0.10.2"
+                "source": "https://github.com/brick/math/tree/0.11.0"
             },
             "funding": [
                 {
                     "type": "github"
                 }
             ],
-            "time": "2022-08-10T22:54:19+00:00"
+            "time": "2023-01-15T23:15:59+00:00"
         },
         {
             "name": "cache/adapter-common",
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_cms-back.git",
-                "reference": "d3c2c4e5e13dfb63d851324d4e87a367219692dc"
+                "reference": "cd4d4fcc83a76f6c3b15b8f959ed8a9f4d6c0d7b"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-ca37b0.tar",
-                "reference": "d3c2c4e5e13dfb63d851324d4e87a367219692dc",
-                "shasum": "1f3141c258a8d6d1a5eaf5c249597ab0053ccae3"
+                "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-cc5f17.tar",
+                "reference": "cd4d4fcc83a76f6c3b15b8f959ed8a9f4d6c0d7b",
+                "shasum": "5cf65154b2b704fc6eb57bb4abc1bda4c9047b73"
             },
             "require": {
                 "backpack/backupmanager": "^3.0",
                 }
             ],
             "description": "Cubist Backpack extension",
-            "time": "2023-03-30T14:44:48+00:00"
+            "time": "2023-03-31T11:53:56+00:00"
         },
         {
             "name": "cubist/cms-front",
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_net.git",
-                "reference": "48d99d29868cf879ddd258e89ff23f1c19820d8e"
+                "reference": "4dad0f1bddd1e5c0655db0d7a975a1de52c23f22"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-6b4fb6.tar",
-                "reference": "48d99d29868cf879ddd258e89ff23f1c19820d8e",
-                "shasum": "47fdf6d79be5d8fbdd6113a1b3d8e67f94436fa4"
+                "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-f3e6ce.tar",
+                "reference": "4dad0f1bddd1e5c0655db0d7a975a1de52c23f22",
+                "shasum": "a6e68a4029c88dbded4d4c4eb1a660a1f310a289"
             },
             "require": {
                 "cubist/util": "dev-master",
                 }
             ],
             "description": "net cubist composer package",
-            "time": "2023-02-13T18:16:16+00:00"
+            "time": "2023-03-31T11:53:22+00:00"
         },
         {
             "name": "cubist/pdf",
         },
         {
             "name": "ramsey/uuid",
-            "version": "4.7.3",
+            "version": "4.x-dev",
             "source": {
                 "type": "git",
                 "url": "https://github.com/ramsey/uuid.git",
-                "reference": "433b2014e3979047db08a17a205f410ba3869cf2"
+                "reference": "8e955307d32dc9b6992440ff81321d3cb09db75a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2",
-                "reference": "433b2014e3979047db08a17a205f410ba3869cf2",
+                "url": "https://api.github.com/repos/ramsey/uuid/zipball/8e955307d32dc9b6992440ff81321d3cb09db75a",
+                "reference": "8e955307d32dc9b6992440ff81321d3cb09db75a",
                 "shasum": ""
             },
             "require": {
-                "brick/math": "^0.8.8 || ^0.9 || ^0.10",
+                "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
                 "ext-json": "*",
                 "php": "^8.0",
                 "ramsey/collection": "^1.2 || ^2.0"
                 "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
                 "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
             },
+            "default-branch": true,
             "type": "library",
             "extra": {
                 "captainhook": {
             ],
             "support": {
                 "issues": "https://github.com/ramsey/uuid/issues",
-                "source": "https://github.com/ramsey/uuid/tree/4.7.3"
+                "source": "https://github.com/ramsey/uuid/tree/4.x"
             },
             "funding": [
                 {
                     "type": "tidelift"
                 }
             ],
-            "time": "2023-01-12T18:13:24+00:00"
+            "time": "2023-03-27T22:05:11+00:00"
         },
         {
             "name": "react/promise",
         "ext-zlib": "*"
     },
     "platform-dev": [],
-    "plugin-api-version": "2.3.0"
+    "plugin-api-version": "2.1.0"
 }