]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5661 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Jan 2023 08:53:10 +0000 (09:53 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Jan 2023 08:53:10 +0000 (09:53 +0100)
14 files changed:
.docker/images/php/Dockerfile
app/Fluidbook/Packager/ChromeOS.php
app/Fluidbook/Packager/Download.php
app/Fluidbook/Packager/MacOS.php
app/Fluidbook/Packager/OfflineHTML.php
app/Fluidbook/Packager/Online.php
app/Fluidbook/Packager/Packager.php
app/Fluidbook/Packager/Precompiled.php
app/Fluidbook/Packager/USBKey.php
app/Fluidbook/Packager/WindowsInstaller.php
app/Slack/Slack.php
config/app.php
config/larabug.php [deleted file]
config/logging.php

index 20aa07eee8e1fc1366ff0c8870ac21528438accd..6584c4752213d21570309ec562bb1901d8481f9c 100644 (file)
@@ -87,7 +87,7 @@ RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o
 RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
 
 ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
-RUN npm install --unsafe-perm --global uglify-js less sass puppeteer favicons nw-builder@^3
+RUN npm install --unsafe-perm --global uglify-js less sass puppeteer favicons crx3 nw-builder@^3
 RUN pip3 install font-line
 
 RUN groupadd sudo;useradd -d /application -g 33 -G sudo -s /bin/bash -u 1001 toolbox
index d778c42cacd6ee820b3098209a8e52778b9abdf5..9fcccc1a8e856d656d84ff15166dcf97a7352807 100644 (file)
@@ -7,10 +7,10 @@ use Cubist\Util\CommandLine;
 class ChromeOS extends Online
 {
 
-    public $type='chormeos';
-    public $cleanOnDestruct=true;
+    public $type = 'chormeos';
+    public $cleanOnDestruct = true;
 
-    public $downloadExt='crx';
+    public $downloadExt = 'crx';
 
     protected function preparePackage()
     {
@@ -37,10 +37,17 @@ class ChromeOS extends Online
     {
         $this->preparePackage();
 
+        //
+
+        $final = $this->getPathBase('crx');
+
         $chrome = new CommandLine('crx3');
-        $chrome->setArg('o', WS_PACKAGER . '/download/' . $this->getBaseFile() . '.crx');
+        $chrome->setArg('o', $final);
         $chrome->setArg(null, $this->vdir . '/m/');
         $chrome->execute();
         $chrome->debug();
+
+        $this->setFinalURL($this->getDownloadURL('crx'));
+        $this->setFinalPath($final);
     }
 }
index c5d6d2e02a2b2076ad0b850bda67ff0b350e2117..a57b5f2c7c9785dc0fa45adb25e98f52298679e2 100644 (file)
@@ -5,6 +5,7 @@ namespace App\Fluidbook\Packager;
 use App\Jobs\DownloadBase;
 use App\Services\ScormCloud;
 use Cubist\Util\Files\Files;
+use Illuminate\Support\Facades\Log;
 
 class Download extends DownloadBase
 {
@@ -63,16 +64,18 @@ class Download extends DownloadBase
             $url = $this->_compileandpackage();
             $subject = __($this->_subject, ['title' => $this->_title(), 'nb' => $this->_id()]);
             $text = '';
-            $actions = ['Télécharger' => $url];
+            if ($this->action === 'download' || $this->action === 'scormcloud') {
+                $actions = ['Télécharger' => $url];
 
-            if ($this->action === 'scormcloud') {
-                try {
-                    $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->_id());
-                    $actions[__('Tester sur SCORM Cloud')] = $scormURL;
-                } catch (\Exception $e) {
+                if ($this->action === 'scormcloud') {
+                    try {
+                        $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->_id());
+                        $actions[__('Tester sur SCORM Cloud')] = $scormURL;
+                    } catch (\Exception $e) {
 
+                    }
+                    $text = __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
                 }
-                $text = __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
             }
         } catch (\Exception $e) {
             $subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
@@ -85,9 +88,16 @@ class Download extends DownloadBase
 
     protected function _compileandpackage()
     {
-        if($this->action==='download' || $this->action===''){
-            $zip=true;
+        if ($this->action === 'download' || $this->action === '') {
+            $zip = true;
         }
-        Packager::package($this->entry->id, $this->version);
+        $packager = Packager::package($this->entry->id, $this->version, $zip);
+        $packager->makePackage($zip);
+        Log::debug($this->action . '/' . $this->entry->id . '/' . $this->version . '/' . get_class($packager) . '///' . $packager->getFinalURL() . '//' . $packager->getFinalPath());
+        $url = $packager->getFinalURL();
+        if ($url) {
+            return $url;
+        }
+        return $packager->getFinalPath();
     }
 }
index 331721db4524948e7a25aad67ff6dc1221a093a7..b55c984e080718da6733b8597db69158a92320e8 100644 (file)
@@ -29,6 +29,8 @@ class MacOS extends WindowsZIP
             $res = $this->getFinalPackageDir();
         }
         $this->postPackage();
+        $this->setFinalURL(null);
+        $this->setFinalPath($res);
         return $res;
     }
 
index 1d5e4d3a66580caeb200b7161355b2fe00150531..798f7a75a5d483a118d777244a4fe9e08f074d45 100644 (file)
@@ -6,13 +6,4 @@ class OfflineHTML extends Online
 {
     protected $_allowNetworking = 'internal';
     public $type = 'win_html';
-
-
-    protected function copyFluidbookFiles()
-    {
-        parent::copyFluidbookFiles();
-        unlink($this->vdir . '/index.swf');
-        unlink($this->vdir . '/player.swf');
-        copy(WS_COMPILE_ASSETS . '/offline.swf', $this->vdir . '/index.swf');
-    }
 }
index 57b7b59a3f188b4f8fa74a7383b3a969c6968700..9d4dcd58b0b39b95d0419e553504567ac47ce85f 100644 (file)
@@ -68,6 +68,9 @@ class Online extends Packager
         if ($zip) {
             return $this->zip();
         }
+
+        $this->setFinalURL(null);
+        $this->setFinalPath($this->getFinalPackageDir());
         return $this->getFinalPackageDir();
     }
 
index a351fc5cee71e870c319615cdd3458bfa1f52392..27c69b8ea12454246940cbfadaf9bd7c80d979cf 100644 (file)
@@ -38,7 +38,17 @@ class Packager extends \App\Jobs\Base
 
     public $zipPackage = true;
 
-    public $downloadExt='zip';
+    public $downloadExt = 'zip';
+
+    /**
+     * @var string
+     */
+    protected $_finalPath = '';
+
+    /**
+     * @var string
+     */
+    protected $_finalURL = '';
 
 
     public static function package($book_id, $type, $zipPackage = true, $cleanOnDestruct = true, $options = [])
@@ -235,6 +245,9 @@ class Packager extends \App\Jobs\Base
         if ($rename) {
             rename($zipfile, $final);
         }
+
+        $this->setFinalPath($final);
+        $this->setFinalURL($this->getDownloadURL('zip'));
         return $final;
     }
 
@@ -302,4 +315,37 @@ class Packager extends \App\Jobs\Base
             `find $dest -type f -name "*.html" -exec rename 's/\.html$/.$e/' '{}' \;`;
         }
     }
+
+    /**
+     * @return string
+     */
+    public function getFinalPath(): string
+    {
+        return $this->_finalPath;
+    }
+
+    /**
+     * @param string $finalPath
+     */
+    public function setFinalPath(string $finalPath): void
+    {
+        $this->_finalPath = $finalPath;
+    }
+
+    /**
+     * @return string
+     */
+    public function getFinalURL(): string
+    {
+        return $this->_finalURL;
+    }
+
+
+    /**
+     * @param string $finalURL
+     */
+    public function setFinalURL(string $finalURL): void
+    {
+        $this->_finalURL = $finalURL;
+    }
 }
index 6f2ce8364f8101ac2601501666e1934ab80369e5..09793520e42cb9fc5e3535399af1ba9779120afb 100644 (file)
@@ -12,7 +12,6 @@ class Precompiled extends Online
         $this->book->parametres->embedAllLibraries = true;
     }
 
-
     public function prepareHTML5()
     {
         $res = parent::prepareHTML5();
index 78e855e10b2589a4e84321c8897bca500dc442dd..e7ea8d7b2ba348a512fef0f3738c28e8b2a468a8 100644 (file)
@@ -10,7 +10,7 @@ class USBKey extends MacOS
                $this->replaceAutorun();
 
                // Package mac app
-               $win = ROOT . Packager::package($this->book_id, 'win_inss_html', false, false);
+               $win =  Packager::package($this->book_id, 'win_inss_html', false, false);
 
                $dest = $this->getFinalPackageDir() . "/" . $this->exeName . '.exe';
                $cp = "cp $win $dest";
@@ -19,7 +19,7 @@ class USBKey extends MacOS
 
        public function replaceAutorun()
        {
-               $inf = file_get_contents(WS_COMPILE_ASSETS . '/autorun-html.inf');
+               $inf = file_get_contents($this->resource_path('fluidbook/packager') . '/autorun-html.inf');
                $toReplace = array('title' => $this->book->parametres->title, 'exe' => $this->exeName . '.exe', 'nwplatform' => $this->nwplatform);
                $inf = $this->replaceContents($inf, $toReplace);
                file_put_contents($this->getFinalPackageDir() . '/autorun.inf', utf8_decode($inf));
index 9fde1e8377103b8348bbe1408eb3983684fd43a2..85cdf193108086f2c29c878e6e05a083588d7ae0 100644 (file)
@@ -58,15 +58,21 @@ class WindowsInstaller extends WindowsZIP
         $makensis->setArg(null, '-V4');
         $makensis->setArg(null, $tmp);
         $makensis->execute();
-        if (!file_exists($this->getPathBase('exe'))) {
+
+        $out=$this->getPathBase('exe');
+
+        if (!file_exists($out) ){
             die('Error while building the installer  : ' . $this->getPathBase('exe'));
         }
 
         $this->signInstaller();
 
-        if (!file_exists($this->getPathBase('exe'))) {
+        if (!file_exists($out)) {
             die('Error during the signing process : ' . $this->getPathBase('exe'));
         }
+
+        $this->setFinalURL($this->getDownloadURL('exe'));
+        $this->setFinalPath($out);
     }
 
     public function signInstaller()
index 574efd7da56b7d39e53961373da01ab55162425d..7af07bb6b917cfdc49d189b6631ae2929b904e47 100644 (file)
@@ -57,12 +57,15 @@ class Slack
             $actionsText = '';
             $i = 0;
             foreach ($actions as $label => $data) {
-                if (is_null($data)) {
-                    $data = ['url' => '#nourl'];
+                if (!$data) {
+                    $data = ['url' => ''];
                 }
                 if (is_string($data)) {
                     $data = ['url' => $data];
                 }
+                if (!$data['url']) {
+                    $data['url'] = 'https://toolbox.fluidbook.com/404';
+                }
                 if ($i < 6) {
                     $a['elements'][] = array_merge([
                         'type' => 'button',
index 9ebb1a97cb4aee1b6b34c339d63984927d9880ca..335768003202bfbab55d5faa7dc7f8c20fffac38 100644 (file)
@@ -39,7 +39,7 @@ return [
     |
     */
 
-    'debug' => !isset($_SERVER['HTTP_X_REAL_IP']) || in_array($_SERVER['HTTP_X_REAL_IP'], ['130.180.213.67']),
+    'debug' => !isset($_SERVER['HTTP_X_REAL_IP']) || in_array($_SERVER['HTTP_X_REAL_IP'], ['130.180.213.67']) ? env('APP_DEBUG') : false,
 
     /*
     |--------------------------------------------------------------------------
diff --git a/config/larabug.php b/config/larabug.php
deleted file mode 100644 (file)
index c5796bb..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-
-return [
-
-    /*
-    |--------------------------------------------------------------------------
-    | Login key
-    |--------------------------------------------------------------------------
-    |
-    | This is your authorization key which you get from your profile.
-    | Retrieve your key from https://www.larabug.com
-    |
-    */
-
-    'login_key' => env('LB_KEY', ''),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Project key
-    |--------------------------------------------------------------------------
-    |
-    | This is your project key which you receive when creating a project
-    | Retrieve your key from https://www.larabug.com
-    |
-    */
-
-    'project_key' => env('LB_PROJECT_KEY', ''),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Environment setting
-    |--------------------------------------------------------------------------
-    |
-    | This setting determines if the exception should be send over or not.
-    |
-    */
-
-    'environments' => [
-        'production',
-        'staging',
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Project version
-    |--------------------------------------------------------------------------
-    |
-    | Set the project version, default: null.
-    | For git repository: shell_exec("git log -1 --pretty=format:'%h' --abbrev-commit")
-    |
-    */
-    'project_version' => null,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Lines near exception
-    |--------------------------------------------------------------------------
-    |
-    | How many lines to show near exception line. The more you specify the bigger
-    | the displayed code will be. Max value can be 50, will be defaulted to
-    | 12 if higher than 50 automatically.
-    |
-    */
-
-    'lines_count' => 12,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Prevent duplicates
-    |--------------------------------------------------------------------------
-    |
-    | Set the sleep time between duplicate exceptions. This value is in seconds, default: 60 seconds (1 minute)
-    |
-    */
-
-    'sleep' => 60,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Skip exceptions
-    |--------------------------------------------------------------------------
-    |
-    | List of exceptions to skip sending.
-    |
-    */
-
-    'except' => [
-        'Symfony\Component\HttpKernel\Exception\NotFoundHttpException',
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Key filtering
-    |--------------------------------------------------------------------------
-    |
-    | Filter out these variables before sending them to LaraBug
-    |
-    */
-
-    'blacklist' => [
-        '*authorization*',
-        '*password*',
-        '*token*',
-        '*auth*',
-        '*verification*',
-        '*credit_card*',
-        'cardToken', // mollie card token
-        '*cvv*',
-        '*iban*',
-        '*name*',
-        '*email*'
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Release git hash
-    |--------------------------------------------------------------------------
-    |
-    |
-    */
-
-    // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Server setting
-    |--------------------------------------------------------------------------
-    |
-    | This setting allows you to change the server.
-    |
-    */
-
-    'server' => env('LB_SERVER', 'https://www.larabug.com/api/log'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Verify SSL setting
-    |--------------------------------------------------------------------------
-    |
-    | Enables / disables the SSL verification when sending exceptions to LaraBug
-    | Never turn SSL verification off on production instances
-    |
-    */
-    'verify_ssl' => env('LB_VERIFY_SSL', true),
-
-];
index 5e6ab7fd4e26d2eee5140b70a9b70d911ebe06fc..a72b700b9597ef02690fbc6c854f4c7fadd67939 100644 (file)
@@ -37,7 +37,7 @@ return [
     'channels' => [
         'stack' => [
             'driver' => 'stack',
-            'channels' => ['daily', 'stderr', 'larabug'],
+            'channels' => ['daily', 'stderr', 'slack'],
             'ignore_exceptions' => false,
         ],
 
@@ -102,6 +102,7 @@ return [
 
         'larabug' => [
             'driver' => 'larabug',
+            'level' => 'debug',
         ],
     ],