]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6998 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2024 09:04:52 +0000 (11:04 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2024 09:04:52 +0000 (11:04 +0200)
19 files changed:
.docker/fluidbook-workshop/config/httpd.conf [new file with mode: 0644]
.docker/fluidbook-workshop/docker-compose.yml [new file with mode: 0644]
.docker/fluidbook-workshop/html/.htaccess [new file with mode: 0644]
.docker/fluidbook-workshop/html/index.php [new file with mode: 0644]
.docker/fluidbook-workshop/update [new file with mode: 0644]
app/Console/Commands/SyncFluidbooksV3ToWorkshop.php [deleted file]
app/Console/Commands/ToolboxToWorkshop.php [deleted file]
app/Console/Commands/WorkshopMigration.php [deleted file]
app/Console/Kernel.php
app/Fluidbook/Compiler/Compiler.php
app/Fluidbook/Packager/Download.php
app/Jobs/FluidbookCollectionDownload.php
app/Jobs/FluidbookWS2Download.php [deleted file]
app/Jobs/HostingUpdate.php
app/Jobs/UpdateWS2ThemeTable.php [deleted file]
app/Models/FluidbookPublication.php
app/Models/FluidbookTheme.php
bin/mount.sh
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php

diff --git a/.docker/fluidbook-workshop/config/httpd.conf b/.docker/fluidbook-workshop/config/httpd.conf
new file mode 100644 (file)
index 0000000..93e5350
--- /dev/null
@@ -0,0 +1,10 @@
+LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
+
+<Directory /var/www/html>
+        Options Indexes FollowSymLinks
+        AllowOverride All
+        Require all granted
+</Directory>
+
+User #1004
+Group #33
diff --git a/.docker/fluidbook-workshop/docker-compose.yml b/.docker/fluidbook-workshop/docker-compose.yml
new file mode 100644 (file)
index 0000000..521053f
--- /dev/null
@@ -0,0 +1,18 @@
+services:
+  webserver:
+    container_name: fluidbook-workshop
+    image: php:apache
+    volumes:
+      - './html:/var/www/html'
+      - './config/httpd.conf:/etc/apache2/conf-enabled/99-config.conf'
+    environment:
+      VIRTUAL_HOST: workshop.fluidbook.com,exe.workshop.fluidbook.com,ws.fluidbook.com
+      LETSENCRYPT_HOST: workshop.fluidbook.com,exe.workshop.fluidbook.com,ws.fluidbook.com
+    networks:
+      - fluidbook-workshop
+    restart: unless-stopped
+
+networks:
+  fluidbook-workshop:
+    external:
+      name: fluidbook-workshop
diff --git a/.docker/fluidbook-workshop/html/.htaccess b/.docker/fluidbook-workshop/html/.htaccess
new file mode 100644 (file)
index 0000000..bfc83ca
--- /dev/null
@@ -0,0 +1,22 @@
+Options +FollowSymlinks
+
+<IfModule mod_rewrite.c>
+       RewriteEngine on
+       RewriteBase /
+
+    RewriteRule ^viewerh/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/$1 [R=308,L]
+    RewriteRule ^viewers/(.+)$ https://toolbox.fluidbook.com/fluidbook-publication/preview/scorm/$1 [R=308,L]
+
+    RewriteRule ^publications$ https://toolbox.fluidbook.com/fluidbook-publication/ [R=308,L]
+    RewriteRule ^fichiers$ https://toolbox.fluidbook.com/file/ [R=308,L]
+    RewriteRule ^dashboard$ https://toolbox.fluidbook.com/ [R=308,L]
+
+       # Ignore static files or directories
+       RewriteCond %{REQUEST_FILENAME} -s [OR]
+       RewriteCond %{REQUEST_FILENAME} -l [OR]
+       RewriteCond %{REQUEST_FILENAME} -d
+       RewriteRule ^.*$ - [NC,L]
+
+       RewriteRule ^([-,_a-zA-Z0-9\./\%\@]+)$ index.php/$1 [L]
+</IfModule>
+
diff --git a/.docker/fluidbook-workshop/html/index.php b/.docker/fluidbook-workshop/html/index.php
new file mode 100644 (file)
index 0000000..5e973bd
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+$path = $_SERVER['PATH_INFO'] ?? '/';
+header('Location: https://toolbox.fluidbook.com' . $path, true, 301);
diff --git a/.docker/fluidbook-workshop/update b/.docker/fluidbook-workshop/update
new file mode 100644 (file)
index 0000000..4d46d3b
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+cd /docker/fluidbook-workshop
+docker network create fluidbook-workshop
+docker compose pull
+docker compose down -v
+docker compose up -d
diff --git a/app/Console/Commands/SyncFluidbooksV3ToWorkshop.php b/app/Console/Commands/SyncFluidbooksV3ToWorkshop.php
deleted file mode 100644 (file)
index a54dca9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Console\Commands\Base\ToolboxCommand;
-use App\Models\FluidbookPublication;
-use Illuminate\Support\Facades\DB;
-
-class SyncFluidbooksV3ToWorkshop extends ToolboxCommand
-{
-    protected $signature = 'syncfluidbooksv3toworkshop';
-    protected $description = 'Sync fluidbooks database to show on workshop fluidbooks made on toolbox';
-
-    public function handle()
-    {
-        // Delete fluidbook V3
-        DB::connection('extranet')->table('books')->where('version', "3")->delete();
-
-        $inserts = [];
-        $ids = [];
-
-        foreach (FluidbookPublication::withoutGlobalScopes()->where('created_ok', '1')->where('version', 3)->orderBy('id', 'ASC')->get() as $fb) {
-            /** @var $fb FluidbookPublication */
-            $i = ['book_id' => $fb->id,
-                'version' => 3,
-                'nom' => $fb->c_title,
-                'lang' => $fb->locale,
-                'region' => $fb->region,
-                'theme' => $fb->theme,
-                'proprietaire' => $fb->owner,
-                'status' => $fb->status,
-                'tache' => $fb->extranet_task ?? 0,
-                'date' => (new \DateTime($fb->created_at))->getTimestamp(),
-                'changedate' => (new \DateTime($fb->updated_at))->getTimestamp(),
-                'numerotation' => $fb->page_numbers??'',
-                'parametres' => $fb->settings,
-                'hash' => $fb->hash,
-                'cid' => $fb->cid,
-            ];
-            $inserts[] = $i;
-            $ids[] = $fb->id;
-        }
-
-        DB::connection('extranet')->table('books')->whereIn('book_id', $ids)->delete();
-        foreach ($inserts as $insert) {
-            DB::connection('extranet')->table('books')->insert($insert);
-        }
-    }
-}
diff --git a/app/Console/Commands/ToolboxToWorkshop.php b/app/Console/Commands/ToolboxToWorkshop.php
deleted file mode 100644 (file)
index 7fde1da..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Console\Commands\Base\ToolboxCommand;
-use App\Models\FluidbookPublication;
-use Illuminate\Support\Facades\DB;
-
-class ToolboxToWorkshop extends ToolboxCommand
-{
-    protected $signature = 'toolboxtows {id} {targetid=new}';
-    protected $description = 'Migrate a fluidbook made on the toolbox back to the workshop';
-
-    protected static $_wstable = 'extranet_clean.books';
-
-    public function handle()
-    {
-        /** @var FluidbookPublication $source */
-        $source = FluidbookPublication::find($this->argument('id'));
-        $map = WorkshopMigration::mapNames(true);
-        $mapValues = WorkshopMigration::mapValues(true);
-
-        $data = [];
-        foreach ($source->getAttributes() as $k => $v) {
-            if ($k === 'settings' || $k === 'id' || !isset($map[$k])) {
-                continue;
-            }
-            $key = isset($map[$k]) ? $map[$k] : $k;
-
-            if (stristr($key, 'date')) {
-                $date = new \DateTime($v);
-                $v = $date->getTimestamp();
-            }
-            $data[$key] = $v;
-
-        }
-        $targetid = $this->argument('targetid');
-        if ($targetid === 'new') {
-            $res = DB::select(DB::raw('SELECT MAX(book_id)+1 AS book_id FROM ' . self::$_wstable));
-            $data['book_id'] = $res[0]->book_id;
-
-            DB::table(self::$_wstable)->insert($data);
-        } else {
-            DB::table(self::$_wstable)->where('book_id', $targetid)->update($data);
-        }
-    }
-}
diff --git a/app/Console/Commands/WorkshopMigration.php b/app/Console/Commands/WorkshopMigration.php
deleted file mode 100644 (file)
index 118018c..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-<?php
-
-
-namespace App\Console\Commands;
-
-use App\Models\FluidbookDocument;
-use App\Models\FluidbookPublication;
-use App\Models\FluidbookTheme;
-use App\Models\FluidbookTranslate;
-use Cubist\Backpack\Console\Commands\CubistCommand;
-use Cubist\Backpack\Magic\Fields\Color;
-use Cubist\Backpack\Magic\Fields\Datetime;
-use Cubist\Util\ArrayUtil;
-use Cubist\Util\Json;
-use Cubist\Util\ObjectUtil;
-use Cubist\Util\PHP;
-use Cubist\Util\Text;
-use Illuminate\Contracts\Cache\Lock;
-use Illuminate\Support\Facades\Artisan;
-use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\DB;
-
-class WorkshopMigration extends CubistCommand
-{
-    protected $signature = 'ws:migrate {--publications=v2} {--documents=missing} {--quick} {--force}';
-    protected $description = 'Migrate data from Workshop V2';
-    protected $_wsRanks = [];
-    const OLD_DB = 'extranet_clean';
-    protected $_oldRoot = '/home/extranet/www/fluidbook/';
-    protected static $_admin = 5963;
-
-    /** @var Lock */
-    protected Lock $_lock;
-
-    const WS3_BOOK_ID = 30000;
-    const WS3_DOC_ID = 200000;
-
-    public function handle()
-    {
-        $this->_lock = Cache::lock('ws2_migrate', 3600);
-
-        if (!$this->option('force') && !$this->_lock->get()) {
-            $this->line('Migration is locked. Use --force to remove lock');
-            return;
-        }
-
-        $actions = [
-            //'Backup current database' => 'backup',
-            'Migrate magic models' => 'migrate',
-            'Import documents' => 'importDocuments',
-            'Import publications' => 'importPublications',
-            'Clean caches' => 'cleanCache'
-        ];
-
-        if ($this->option('quick')) {
-            $actions = ['Import publications' => 'importPublications'];
-        }
-
-        $this->progressBar = $this->output->createProgressBar(count($actions));
-
-        $this->line(' Data migration, please wait');
-        $this->progressBar->start();
-
-        try {
-            foreach ($actions as $comment => $action) {
-                $this->line($comment);
-                $this->$action();
-                $this->progressBar->advance();
-            }
-
-            $this->line('End of import');
-        } finally {
-            $this->_lock->release();
-        }
-    }
-
-    protected function migrate()
-    {
-        Artisan::call('cubist:magic:generate');
-        Artisan::call('cubist:magic:migrate');
-    }
-
-    protected function backup()
-    {
-        Artisan::call('backup:run');
-    }
-
-    protected function cleanCache()
-    {
-        Artisan::call('optimize:clear');
-    }
-
-    protected function importDocuments()
-    {
-        if ($this->option('documents') === 'none') {
-            return;
-        }
-
-        PHP::neverStop();
-
-        $q = DB::table(self::OLD_DB . '.documents')->orderBy('document_id', 'desc');
-
-        if ($this->option('documents') === 'missing') {
-            $maxID = FluidbookDocument::withoutGlobalScopes()->where('id', '<', self::WS3_DOC_ID)->orderBy('id', 'DESC')->first()->id;
-            $q = DB::table(self::OLD_DB . '.documents')->where('document_id', '>', $maxID)->orderBy('document_id', 'desc');
-
-        } else if ($this->option('documents') === 'v2') {
-            DB::update('DELETE FROM fluidbook_document WHERE id<' . self::WS3_DOC_ID);
-        } else {
-            $range = ArrayUtil::parseRange($this->option('documents'));
-            FluidbookDocument::withoutGlobalScopes()->whereIn('id', $range)->forceDelete();
-            $q->whereIn('document_id', $range);
-        }
-
-
-        foreach ($q->get() as $e) {
-            $this->line('Import ' . $e->document_id);
-            $c = new FluidbookDocument();
-            $c->setIncrementing(false);
-            $c->id = $e->document_id;
-            $date = new \DateTime();
-            $date->setTimestamp($e->date);
-            $c->created_at = $c->updated_at = $date;
-            $c->file = $e->file;
-            $c->owner = $e->proprietaire;
-            $c->pages = $e->pages;
-
-            $c->pdf_data = $this->_unserialize($e->generalInfos);
-            $c->file_data = $this->_unserialize($e->localInfos);
-            $c->bookmarks = $this->_migrateBookmarks($e->bookmarks);
-            $c->saveWithoutFlushingCache();
-        }
-
-    }
-
-    protected function _migrateBookmarks($bookmarks, $default = [])
-    {
-        $bookmarks = $this->_unserialize($bookmarks, $default);
-        $res = [];
-        foreach ($bookmarks as $bookmark) {
-            if (isset($bookmark['titre'])) {
-                $bookmark['title'] = $bookmark['titre'];
-                unset($bookmark['titre']);
-            } else {
-                $bookmark['title'] = '';
-            }
-            $res[] = $bookmark;
-        }
-        return $res;
-    }
-
-    protected function _unserialize($s, $default = [])
-    {
-        return ObjectUtil::safeUnserialize($s, $default);
-    }
-
-    protected function _unserializeAndJSON($s, $default = [])
-    {
-        return json_encode($this->_unserialize($s, $default));
-    }
-
-    public static function mapNames($flip = false)
-    {
-        $res = ['book_id' => 'id',
-            'nom' => 'name',
-            'proprietaire' => 'owner',
-            'date' => 'created_at',
-            'lang' => 'locale',
-            'compteur_visites' => 'visits_counter',
-            'date_status' => 'status_date',
-            'traductions' => 'translations',
-            'numerotation' => 'page_numbers',
-            'tache' => 'extranet_task',
-            'changedate' => 'updated_at',
-            'compiledate' => 'compilation_date',
-            'composition_update' => 'composition_updated_at',
-            'exportdatas' => 'export_data',
-        ];
-        if ($flip) {
-            $res = array_flip($res);
-        }
-        return $res;
-    }
-
-    public static function mapValues($flip = false)
-    {
-        $res = ['Open Sans (police du Fluidbook)' => 'OpenSans'];
-        if ($flip) {
-            $res = array_flip($res);
-        }
-        return $res;
-    }
-
-    protected function importPublications()
-    {
-        if ($this->option('publications') === 'none') {
-            return;
-        }
-
-        PHP::neverStop();
-
-        $map = self::mapNames();
-        $mapValues = self::mapValues();
-
-        $v3 = FluidbookPublication::withoutGlobalScopes()->where('version', 3)->pluck('id')->toArray();
-
-        $ignore = [];
-
-        $this->line('Begin publications migration');
-
-        FluidbookTheme::$updateWS2ViewOnChange = false;
-
-        $q = DB::table(self::OLD_DB . '.books')->orderBy('book_id', 'asc');
-
-        if ($this->option('publications') === 'v2') {
-            DB::update('DELETE FROM fluidbook_publication WHERE version <= 2 AND id<' . self::WS3_BOOK_ID);
-        } else if ($this->option('publications') === 'missing') {
-            // Get highest fluidbook on toolbox with a number less thant WS3_BOOK_ID
-            $f = FluidbookPublication::withoutGlobalScopes()->where('id', '<', self::WS3_BOOK_ID)->orderBy('id', 'DESC')->first();
-            $q->where('book_id', '>', $f->id);
-        } else {
-            $range = ArrayUtil::parseRange($this->option('publications'));
-            FluidbookPublication::withoutGlobalScopes()->where('version', '<=', 2)->whereIn('id', $range)->forceDelete();
-            $q->whereIn('book_id', $range);
-        }
-
-        foreach ($q->get() as $e) {
-            $this->line('Import ' . $e->book_id);
-            if (in_array($e->book_id, $v3)) {
-                continue;
-            }
-            $c = new FluidbookPublication();
-            $c->setIncrementing(false);
-            $c->id = $e->book_id;
-            $e->compiledate = max($e->compiledate, $e->compile1date, $e->compilehtml5date);
-            $e->version = 2;
-            foreach ($e as $k => $v) {
-                $new = $map[$k] ?? $k;
-                if (!$c->hasField($new)) {
-                    continue;
-                }
-                if ($new == 'visits_counter' && $v == 20) {
-                    $v = 0;
-                }
-                if ($new == 'status') {
-                    $v++;
-                }
-                if ($c->getField($new) instanceof Datetime) {
-                    $date = new \DateTime();
-                    $date->setTimestamp($v);
-                    $v = $date;
-                } else if ($k == 'chapters') {
-                    $v = $this->_normalizeChapters($v);
-                } else if ($new == 'translations') {
-                    $v = $this->_normalizeTranslations($v, $e->lang);
-                } else if (Json::isJson($v)) {
-                    $v = json_decode($v, true);
-                } else if ($new === 'locale') {
-                    $v = $this->_normalizeLang($v);
-                }
-                $c->setAttribute($new, $v);
-            }
-
-            $s = $this->_unserialize($e->parametres);
-
-            foreach ($s->datas as $k => $data) {
-                if (in_array($k, $ignore)) {
-                    continue;
-                }
-                if ($k === 'pages') {
-                    $c->setAttribute('c_pages', max($data, count(explode(',', $e->numerotation))));
-                }
-                if (!$c->hasField($k)) {
-                    continue;
-                }
-                $f = $c->getField($k);
-
-                if ($f instanceof Color) {
-                    $data = FluidbookTheme::_colorToWS3($data);
-                } else if ($f instanceof Datetime) {
-                    $date = new \DateTime();
-                    $date->setTimestamp($data);
-                    $data = $date;
-                } else if (Json::isJson($data)) {
-                    $data = json_decode($data, true);
-                }
-                if (is_scalar($data) && isset($mapValues[$data])) {
-                    $data = $mapValues[$data];
-                }
-
-                $c->setAttribute($k, $data);
-                if ($k === 'title') {
-                    $c->setAttribute('c_title', $data);
-                }
-
-            }
-
-            // Composition
-            $composition = [];
-            foreach (DB::table(self::OLD_DB . '.book_pages')->where('book_id', $e->book_id)->get() as $p) {
-                $composition[$p->book_page] = [$p->document_id, $p->document_page];
-            }
-            $c->setAttribute('composition', $composition);
-
-            try {
-                $c->saveQuietlyWithoutFlushingCache();
-            } catch (\Exception $e) {
-                dd($e);
-            }
-        }
-
-        Artisan::call('fluidbook:document:setregion');
-    }
-
-    protected function _normalizeLang($lang)
-    {
-        $e = preg_split('/[-_]+/', $lang);
-        if (count($e) === 1) {
-            return $lang;
-        }
-        return mb_strtolower($e[0]) . "_" . mb_strtoupper($e[1]);
-    }
-
-    protected function _normalizeTranslations($value, $lang)
-    {
-        if (!is_string($value) || !Json::isJson($value)) {
-            return [];
-        }
-        $translations = json_decode($value);
-        $res = [];
-
-        $l10n = FluidbookTranslate::getCompiledTranslations()[$this->_normalizeLang($lang)];
-
-        foreach ($translations as $base => $trans) {
-            if (!isset($l10n[$base]) || !$trans || $l10n[$base] === $trans) {
-
-            } else {
-                $res[$base] = $trans;
-            }
-        }
-
-        return $res;
-    }
-
-    public function _normalizeChapters($value)
-    {
-        if (!$value) {
-            return $value;
-        }
-        if (is_string($value)) {
-            $v = json_decode($value, true);
-        } else {
-            $v = $value;
-        }
-        if (!$v) {
-            return $value;
-        }
-        $res = [];
-        foreach ($v as $k => $chapter) {
-            $chapter['decoration'] = 'regular';
-            $chapter['label'] = trim($chapter['label']);
-            if ($chapter['label'] === '----') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'separator';
-            } else if ($chapter['label'] === '--') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'forcecut';
-            } else if ($chapter['label'] === '++') {
-                $chapter['label'] = '';
-                $chapter['decoration'] = 'nocut';
-            } else if (str_starts_with($chapter['label'], '!!!')) {
-                $chapter['label'] = substr($chapter['label'], 3);
-                $chapter['decoration'] = 'column_head';
-            }
-            $res[$k] = $chapter;
-        }
-        return $res;
-    }
-
-    public function __destruct()
-    {
-
-    }
-}
index f1b20289ecc727f6dc39c006c444b8d8fc64106a..4e92c7a5dd13039e8f11dfe3e567e62380dc938f 100644 (file)
@@ -38,11 +38,12 @@ class Kernel extends \Cubist\Backpack\Console\Kernel
             // Email config
             $schedule->command('job:dispatchNow Maintenance\\\\EmailServerRefresh')->twiceDailyAt();
             // WS to Toolbox migration
-            $schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00');
-            $schedule->command('syncfluidbooksv3toworkshop')->dailyAt('3:15');
-            $schedule->command('ws:migrate --publications=missing --documents=missing')->everyTwoHours();
+            //$schedule->command('ws:migrate --publications=v2 --documents=missing')->dailyAt('1:00');
+            //$schedule->command('syncfluidbooksv3toworkshop')->dailyAt('3:15');
+            //$schedule->command('ws:migrate --publications=missing --documents=missing')->everyTwoHours();
+            // Quotes
             $schedule->command('fluidbook:quote --reminder')->weekdays()->at('10:00');
-
+            // Mailjet
             $schedule->command('job:dispatchNow MailjetSyncList')->dailyAt('5:00');
         }
 
index 210016fdf4f340c681a029f3cd66b208d37ba20e..b2155919ed5cb927334f9b2ee2e925e5da813d6c 100644 (file)
@@ -305,7 +305,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
         $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion);
         $this->appcache = $appcache;
         $this->multiApp = $this->home = $home;
-        $this->devversion = $this->getFluidbook()->version < 3 ? "dev" : $this->getFluidbook()->mobileLVersion;
+        $this->devversion = /*$this->getFluidbook()->version < 3 ? "dev" : */$this->getFluidbook()->mobileLVersion;
         $this->scormVariant = $scormVariant;
 
         $this->hybrid = $hybrid;
index f35047edfe46bc13642ee558489bdbc32ebf628f..ee11d7a29f7a23ac9bf687ae2539b34d41e61ce9 100644 (file)
@@ -165,14 +165,14 @@ class Download extends DownloadBase
 
     protected function _compileandpackage($zip = true)
     {
-        if ($this->entry->version == 3) {
+       // if ($this->entry->version == 3) {
             $packager = Packager::package($this->entry->id, $this->version, $zip, true, $this->_params);
-        } else {
-            $packager = new WorkshopPackager($this->entry->id, $this->version, null, $this->_params);
-            $packager->zipPackage = $zip;
-            $packager->cleanOnDestruct = true;
-            $packager->setUser($this->getUser());
-        }
+//        } else {
+//            $packager = new WorkshopPackager($this->entry->id, $this->version, null, $this->_params);
+//            $packager->zipPackage = $zip;
+//            $packager->cleanOnDestruct = true;
+//            $packager->setUser($this->getUser());
+//        }
         $packager->makePackage($zip);
         $url = $packager->getFinalURL();
         if ($url) {
index a370c72aed17d5d7c7ee32f71060979c046302e7..6747eb4e556cdb185441aafc37fdcef99773c451 100644 (file)
@@ -354,19 +354,9 @@ class FluidbookCollectionDownload extends DownloadBase
     {
         if ($compilerVersion === 'auto') {
             $fb = FluidbookPublication::withoutGlobalScopes()->find($id);
-            $compilerVersion = $fb->version;
-        }
-        /** @var $job FluidbookPackage */
-        if ($compilerVersion == 2) {
-            $job = new FluidbookWS2Download();
-            if (null === $this->user) {
-                $job->setCredentials(['api@fluidbook.com', 'Dxsm2nqsvbV4ubH8KUEMRpbfsRrsDZagJkCZV2Nvuy83oPqsSEKC6ircWdC2']);
-            } else {
-                $job->setCredentials([$this->user->email, $this->user->api_token]);
-            }
-        } else if ($compilerVersion == 3) {
-            $job = new FluidbookPackage();
         }
+
+        $job = new FluidbookPackage();
         $job->setBookId($id);
         $job->setVersion($version);
         $job->setOptions($options);
diff --git a/app/Jobs/FluidbookWS2Download.php b/app/Jobs/FluidbookWS2Download.php
deleted file mode 100644 (file)
index 41e9084..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Services\WorkshopV2;
-
-class FluidbookWS2Download extends FluidbookPackage
-{
-
-    protected array $_credentials;
-    protected int $_tries = 1;
-
-    public function handle()
-    {
-        try {
-            $ws = new WorkshopV2();
-            $ws->login($this->getCredentials()[0], $this->getCredentials()[1]);
-            if (in_array($this->getVersion(), ['win_ins_html', 'win_inss_html'])) {
-                $res = $ws->downloadBookExport($this->getBookId(), $this->getDestination(), $this->getOptions(), $this->getVersion(), $this->getTries());
-            } else {
-                $res = $ws->installBook($this->getBookId(), $this->getDestination(), $this->getOptions(), $this->getVersion(), $this->getTries());
-            }
-            $this->setResult($res);
-        } catch (\Exception $e) {
-            $this->setException($e);
-        }
-        $this->setDone(true);
-    }
-
-    /**
-     * @return int
-     */
-    public function getTries(): int
-    {
-        return $this->_tries;
-    }
-
-    /**
-     * @param int $tries
-     */
-    public function setTries(int $tries): void
-    {
-        $this->_tries = $tries;
-    }
-
-    /**
-     * @return array
-     */
-    public function getCredentials(): array
-    {
-        return $this->_credentials;
-    }
-
-    /**
-     * @param array $credentials
-     */
-    public function setCredentials(array $credentials): void
-    {
-        $this->_credentials = $credentials;
-    }
-
-}
index a1c7f349849870d79b3f5330b697bd9d52542807..6f12bbbe2713860af3365b0936d3f6c2f6b3ef6e 100644 (file)
@@ -12,8 +12,8 @@ use Cubist\Util\Text;
 class HostingUpdate extends Base
 {
     protected static $_data = [
-        'hosting' => ['host' => 'godzilla.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting'],
-        'hosting2' => ['host' => 'godzilla.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting2'],
+        'hosting' => ['host' => 'cloudatlas.cubedesigners.com', 'basepath' => '/home/fluidbook/hosting'],
+        'hosting2' => ['host' => 'cloudatlas.cubedesigners.com', 'basepath' => '/home/fluidbook/hosting2'],
         'ushosting' => ['host' => 'kingkong.cubedesigners.com', 'basepath' => '/home/fluidbook/data/hosting'],
     ];
 
diff --git a/app/Jobs/UpdateWS2ThemeTable.php b/app/Jobs/UpdateWS2ThemeTable.php
deleted file mode 100644 (file)
index d6d48d1..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-<?php
-
-
-namespace App\Jobs;
-
-
-use App\Models\FluidbookTheme;
-use Cubist\Backpack\Magic\Fields\Color;
-use Cubist\Backpack\Magic\Fields\Files;
-use Cubist\Util\CommandLine\Imagemagick;
-use Cubist\Util\Graphics\Image;
-use Fluidbook\Tools\SVG\SVGTools;
-use Illuminate\Database\UniqueConstraintViolationException;
-use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\DB;
-use Mockery\Exception;
-use Spatie\MediaLibrary\MediaCollections\Models\Media;
-
-class UpdateWS2ThemeTable extends Base
-{
-    protected $id = 'all';
-
-    protected $_fileFields = [];
-    protected $_colorFields = [];
-    protected $_colorAlphaFields = [];
-    protected $_allFields = [];
-    protected $_ignore = [];
-    protected $_t3dir = '/home/extranet/www/fluidbook/themes3/';
-
-    protected static $_colorToWS2Cache = [];
-    protected static $_colorAlphaToWS2Cache = [];
-
-    public function __construct($id = 'all')
-    {
-        $this->id = $id;
-    }
-
-    public function uniqueId()
-    {
-        return 'updatews2themetable_' . $this->id;
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        $lock = Cache::lock('job_' . $this->uniqueId(), 10);
-        if ($lock->get()) {
-            $theme = new FluidbookTheme();
-
-            foreach ($theme->getFields() as $field) {
-                $name = $field->getAttribute('name');
-                $this->_allFields[] = $name;
-                if ($field instanceof Files) {
-                    $this->_fileFields[] = $name;
-                } else if ($field instanceof Color) {
-                    if ($field->getAttribute('allows_alpha')) {
-                        $this->_colorAlphaFields[] = $name;
-                    } else {
-                        $this->_colorFields[] = $name;
-                    }
-                }
-            }
-            $this->_ignore = ['id', 'name', 'owner', 'created_at', 'deleted_at', 'updated_at', 'slug', 'signature'];
-
-            $data = [];
-            $t = DB::table('extranet_clean.ws3_themes');
-            if ($this->id === 'all') {
-                foreach (FluidbookTheme::where('created_ok', 1)->get() as $theme) {
-                    $data[] = $this->_handleTheme($theme);
-                }
-                $t->truncate();
-            } else {
-                $theme = FluidbookTheme::find($this->id);
-                $data[] = $this->_handleTheme($theme);
-                $t->where('theme_id', '=', $this->id)->delete();
-            }
-            try {
-                $t->insert($data);
-            } catch (Exception|UniqueConstraintViolationException $e) {
-
-            }
-            $lock->release();
-        }
-    }
-
-    protected function _handleTheme($theme)
-    {
-        $res = $this->_getThemeData($theme);
-        $dest = $this->_t3dir . '/' . $theme->id . '.jpg';
-
-        $preview = storage_path('themes/' . $theme->id . '.jpg');
-        \Cubist\Util\Files\Files::copyFile($preview, $dest, false, true, false);
-
-        return $res;
-    }
-
-    protected function _getThemeData($theme)
-    {
-        $settings = [];
-        foreach ($this->_allFields as $k) {
-            if (in_array($k, $this->_ignore)) {
-                continue;
-            }
-            $v = (string)$theme->$k;
-
-            if (in_array($k, $this->_colorAlphaFields)) {
-                $v = self::colorAlphaToWS2($v);
-            } else if (in_array($k, $this->_colorFields)) {
-                $v = self::colorToWS2($v);
-            } else if (in_array($k, $this->_fileFields)) {
-                if (null === $v) {
-                    $v = '';
-                } else {
-                    /** @var Media $media */
-                    $media = $theme->getMedia($v)->get(0);
-                    if (null !== $media) {
-                        $v = $media->getAttribute('file_name');
-                        $dir = $this->_t3dir . $theme->id;
-                        \Cubist\Util\Files\Files::mkdir($dir);
-                        $dest = $dir . '/' . $v;
-                        $path = $media->getPath();
-
-                        \Cubist\Util\Files\Files::copyFile($path, $dest);
-
-                        if (stristr($v, '.svg')) {
-                            $png = str_replace('.svg', '.png', $dest);
-                            if (!file_exists($png) || filemtime($png) < filemtime($path)) {
-                                $im = new Imagemagick();
-                                $im->setDest($png);
-                                $im->setSrc($dest);
-                                $im->setManualArg('-background none');
-                                $im->execute();
-                            }
-                        }
-                    } else {
-                        $v = '';
-                    }
-                }
-            }
-            if (null === $v) {
-                continue;
-            }
-            $settings[$k] = $v;
-        }
-        return ['theme_id' => $theme->id, 'nom' => $theme->name, 'proprietaire' => $theme->owner, 'icones' => $theme->iconSet, 'date' => strtotime($theme->updated_at), 'parametres' => json_encode($settings)];
-    }
-
-
-    public static function colorAlphaToWS2($data)
-    {
-        if ($data === '') {
-            return null;
-        }
-        if (!isset(self::$_colorAlphaToWS2Cache[$data])) {
-            self::$_colorAlphaToWS2Cache[$data] = self::_colorToWS2($data, true);
-        }
-        return self::$_colorAlphaToWS2Cache[$data];
-    }
-
-    public static function colorToWS2($data)
-    {
-        if ($data === '') {
-            return '';
-        }
-        if (!isset(self::$_colorToWS2Cache[$data])) {
-            self::$_colorToWS2Cache[$data] = self::_colorToWS2($data, false);
-        }
-        return self::$_colorToWS2Cache[$data];
-    }
-
-    protected static function _colorToWS2($data, $alpha): string
-    {
-        $data = trim($data, '# ');
-        if (strlen($data) < 6) {
-            $res = str_repeat('0', 6 - mb_strlen($data)) . $data;
-        } else if (strlen($data) === 6) {
-            $res = $data;
-        } else if ($data === 'transparent') {
-            $res = '00000000';
-        } else if (preg_match('/rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(\s*,\s*([0-9.]*))?\)/', $data, $matches)) {
-            $res = self::dechex($matches[1]) . self::dechex($matches[2]) . self::dechex($matches[3]);
-            if (isset($matches[5])) {
-                $res = self::dechex($matches[5] * 255) . $res;
-            }
-        } else {
-            $res = $data;
-        }
-        if ($alpha && strlen($res) === 6) {
-            $res = 'ff' . $res;
-        }
-        return $res;
-    }
-
-    public static function dechex($e)
-    {
-        if ($e == 0) {
-            $res = '00';
-        } else {
-            $res = dechex(round($e));
-            if (strlen($res) == 1) {
-                $res = '0' . $res;
-            }
-        }
-        return $res;
-    }
-
-}
index 2f02eea061dcd3c2b1ca612c5a1245e6927d86e5..98ee5ce36cb854a17cc174d3a4e0a515e9e9782d 100644 (file)
@@ -722,9 +722,9 @@ class FluidbookPublication extends ToolboxStatusModel
         if (!parent::allowsDelete()) {
             return false;
         }
-        if ($this->version < 3) {
-            return false;
-        }
+//        if ($this->version < 3) {
+//            return false;
+//        }
 
         return true;
     }
@@ -734,9 +734,9 @@ class FluidbookPublication extends ToolboxStatusModel
         if (!parent::allowsUpdate()) {
             return false;
         }
-        if ($this->version < 3) {
-            return false;
-        }
+//        if ($this->version < 3) {
+//            return false;
+//        }
         return true;
     }
 
@@ -746,7 +746,8 @@ class FluidbookPublication extends ToolboxStatusModel
         if (!can(static::$_permissionBase . ':write')) {
             return false;
         }
-        if ($this->version >= 3) {
+
+        if (true || $this->version >= 3) {
             return false;
         }
         return true;
@@ -839,11 +840,12 @@ class FluidbookPublication extends ToolboxStatusModel
 
     public function syncFromWorkshop()
     {
-        if ($this->version >= 3) {
-            return false;
-        }
-        Artisan::call('ws:migrate --publications=' . $this->id . ' --documents=missing --quick');
-        return true;
+        return false;
+//        if ($this->version >= 3) {
+//            return false;
+//        }
+//        Artisan::call('ws:migrate --publications=' . $this->id . ' --documents=missing --quick');
+//        return true;
     }
 
     /**
@@ -852,6 +854,7 @@ class FluidbookPublication extends ToolboxStatusModel
      */
     public static function syncPublicationFromWorkshop($id)
     {
+        return;
         /** @var FluidbookPublication $fb */
         $fb = FluidbookPublication::withoutGlobalScopes()->find($id);
         $fb?->syncFromWorkshop();
@@ -1114,6 +1117,7 @@ class FluidbookPublication extends ToolboxStatusModel
 
     public function upgrade($version = "latest")
     {
+        return;
         if ($version === 'latest') {
             $version = 3;
         }
@@ -1203,9 +1207,9 @@ class FluidbookPublication extends ToolboxStatusModel
 
     public function allowsChangeStatus()
     {
-        if ($this->version < 3) {
-            return false;
-        }
+//        if ($this->version < 3) {
+//            return false;
+//        }
         return parent::allowsChangeStatus();
     }
 
index 395201f2249a2fd811b4c9176fe447e269a879a6..96ca7e21c387373d7e58164ae76856b7526c4266 100644 (file)
@@ -675,7 +675,6 @@ class FluidbookTheme extends ToolboxModel
     public function onSaved(): bool
     {
         $res = parent::onSaved();
-        self::updateWS2Table($this->id);
         $this->_generateThemePreview();
         return $res;
     }
@@ -688,64 +687,9 @@ class FluidbookTheme extends ToolboxModel
     public function onDeleted(): bool
     {
         $res = parent::onDeleted();
-        self::updateWS2Table();
         return $res;
     }
 
-    public static function updateWS2Table($id = null)
-    {
-
-        if (self::$updateWS2ViewOnChange) {
-            if (null !== $id) {
-                dispatch_sync(new UpdateWS2ThemeTable($id));
-            }
-            dispatch(new UpdateWS2ThemeTable('all'))->onQueue('theme');
-        }
-    }
-
-    public function fromWS2($data)
-    {
-        $map = ['theme_id' => 'id',
-            'nom' => 'name',
-            'proprietaire' => 'owner',
-            'date' => 'created_at',];
-
-        $ignore = ['extraXSpace', 'extraYSpace'];
-
-        $oldRoot = $this->_oldRoot . 'themes/' . $data->theme_id . '/';
-
-        foreach ($map as $old => $new) {
-            $v = $data->$old;
-            if ($old === 'date') {
-                $date = new \DateTime();
-                $date->setTimestamp($v);
-                $v = $date;
-            }
-            $this->setAttribute($new, $v);
-        }
-        $this->save();
-
-
-        $s = self::_unserialize($data->parametres);
-
-        foreach ($s->datas as $k => $v) {
-            if (in_array($k, $ignore)) {
-                continue;
-            }
-            $f = $this->getField($k);
-            if ($f instanceof Files) {
-                $this->_handleWS2File($f, $v, $oldRoot);
-            } else {
-                if ($f instanceof Color) {
-                    $data = self::_colorToWS3($data);
-                }
-                $this->setAttribute($k, $v);
-            }
-        }
-        $this->save();
-        return $this;
-    }
-
     /**
      * @param array $a
      * @return FluidbookTheme
index 54bd5a271207ccd6f3c3da595f16f0d25af35382..e661fbc10bbd2633cdcfd2fa5f5697145ef8f4f7 100644 (file)
@@ -5,7 +5,7 @@ if mountpoint -q "/mnt/hosting"; then
 else
     echo "mount /mnt/hosting"
     umount -l -q /mnt/hosting
-    sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@godzilla.cubedesigners.com:/data/fluidbook/hosting /mnt/hosting
+    sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@cloudatlas.cubedesigners.com:/home/fluidbook/hosting /mnt/hosting
 fi
 
 mkdir -p /mnt/hosting2
@@ -14,7 +14,7 @@ if mountpoint -q "/mnt/hosting2"; then
 else
     echo "mount /mnt/hosting2"
     umount -l -q /mnt/hosting2
-    sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@godzilla.cubedesigners.com:/data/fluidbook/hosting2 /mnt/hosting2
+    sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 -o uid=1001 -o gid=33 -o allow_other fluidbook@cloudatlas.cubedesigners.com:/home/fluidbook/hosting2 /mnt/hosting2
 fi
 
 mkdir -p /application/usstorage
index 2c25fb7f35f5ee7dc1139fca007e57ccc8c09108..8b46d41440ee3b7fe8e210bc32835ea21d8beea7 100644 (file)
@@ -2,15 +2,15 @@
 @php
     $actions=[];
     $suffixv3='';
-    if($entry->version==2){
-        $actions['compilev2']=['label'=>'<span class="context-menu-subtitle">'.__('Compilateur V2').'</span>','disabled'=>true,'url'=>'#'];
-        $actions['preview_v2'] = ['label'=>__('Version online'),'url'=>'https://workshop.fluidbook.com/viewerh/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
-        if($entry->isSCORMEnabled()){
-           $actions['scorm_v2'] = ['label'=>__('Version SCORM'),'url'=>'https://workshop.fluidbook.com/viewers/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
-        }
-        $actions['sep']='---------';
-        $actions['testv3']=['label'=>'<span class="context-menu-subtitle">'.__('Tester le compilateur V3').'</span>','disabled'=>true,'url'=>'#'];
-    }
+//    if($entry->version==2){
+//        $actions['compilev2']=['label'=>'<span class="context-menu-subtitle">'.__('Compilateur V2').'</span>','disabled'=>true,'url'=>'#'];
+//        $actions['preview_v2'] = ['label'=>__('Version online'),'url'=>'https://workshop.fluidbook.com/viewerh/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
+//        if($entry->isSCORMEnabled()){
+//           $actions['scorm_v2'] = ['label'=>__('Version SCORM'),'url'=>'https://workshop.fluidbook.com/viewers/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
+//        }
+//        $actions['sep']='---------';
+//        $actions['testv3']=['label'=>'<span class="context-menu-subtitle">'.__('Tester le compilateur V3').'</span>','disabled'=>true,'url'=>'#'];
+//    }
     $actions['preview']=['label'=>__('Version online'),'url'=>$crud->route.'/preview/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];
     if($entry->isSCORMEnabled()){
         $actions['scorm']=['label'=>__('Version SCORM'),'url'=>$crud->route.'/preview/scorm/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank'];