From: soufiane Date: Thu, 29 Jun 2023 15:46:31 +0000 (+0200) Subject: wip #6606 @6:40 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=883d922825bea455d3b5e8a904b0ffb79e6df971;p=fluidbook-toolbox.git wip #6606 @6:40 --- diff --git a/app/Console/Commands/DebugDeliveryJob.php b/app/Console/Commands/DebugDeliveryJob.php deleted file mode 100644 index 305822ccc..000000000 --- a/app/Console/Commands/DebugDeliveryJob.php +++ /dev/null @@ -1,34 +0,0 @@ -argument('id')); + $mobilefirstFluidbookId = $f->mobilefirstFluidbookId; + $fm = null; + + $fn = 'dispatch'; + if($this->argument('sync')) + $fn = 'dispatchSync'; + + if($mobilefirstFluidbookId) { + $fm = FluidbookPublication::find($mobilefirstFluidbookId); + } + + if($fm) { + GenerateDeliveryThumbnailsPreview::$fn($fm,320, 600, 'mobile'); + } + + GenerateDeliveryThumbnailsPreview::$fn($f,1920, 1080); + GenerateDeliveryThumbnailsPreview::$fn($f,320, 600, 'mobile'); + } +} diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php index 4f3574c78..813128b44 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/DownloadOperation.php @@ -15,6 +15,7 @@ trait DownloadOperation protected function setupDownloadRoutes($segment, $routeName, $controller) { Route::match(['get'], $segment . '/{id}/delivery', $controller . '@delivery'); + Route::match(['get'], $segment . '/{id}/delivery/{type}', $controller . '@deliveryThumb')->name('deliveryThumb'); Route::match(['get'], $segment . '/{id}/package/{action}/{version}', $controller . '@package'); Route::match(['get'], $segment . '/{id}/package/{action}/scorm/{scormversion}', $controller . '@packageScorm'); Route::match(['get'], $segment . '/{id}_{hash}/download/{file}', $controller . '@download')->withoutMiddleware([CheckIfAdmin::class]);; @@ -33,6 +34,24 @@ trait DownloadOperation return view('fluidbook_publication.delivery', ['fluidbook' => FluidbookPublication::where('id', $id)->first()]); } + protected function deliveryThumb($id,$type) + { + $typeAvailable = ['desktop', 'mobile']; + if (!FluidbookPublication::hasPermission($id, 'read')) { + abort(401); + } + if (!$type || !in_array($type, $typeAvailable)) { + abort(404); + } + + $relayPath = '/fluidbookpublication/delivery/'; + $relayPath = protected_path($relayPath); + $relayPath .= $id; + $relayPath .= $type === "desktop" ? '' : '-mobile'; + $relayPath .= '.jpg'; + return XSendFileController::sendfile($relayPath); + } + protected function download($id, $hash, $file) { $e = explode('-', $file); diff --git a/app/Jobs/GenerateDeliveryThumbnailsPreview.php b/app/Jobs/GenerateDeliveryThumbnailsPreview.php new file mode 100644 index 000000000..fa2821841 --- /dev/null +++ b/app/Jobs/GenerateDeliveryThumbnailsPreview.php @@ -0,0 +1,51 @@ +publication = $publication; + $this->width = $width; + $this->height = $height; + $this->v = $v; + } + + /** + * Execute the job. + */ + public function handle() + { + $cl = new CommandLine('node'); + $cl->setArg(null, resource_path('fluidbooktheme/theme_preview/secondpage_preview.js')); + $cl->setArg('width', $this->width); + $cl->setArg('height', $this->height); + $cl->setArg('delay', 2); + $cl->setArg('scale', 1); + $cl->setArg('dest', self::getPreviewPath($this->publication->id, $this->v)); + $cl->setArg('page', 2); + $url = $this->publication->getPreviewURL(); + $cl->setArg('url', $url); + $cl->execute(); + } + + public static function getPreviewPath($fluidbookId, $variant = '') + { + $res = Files::mkdir(protected_path('fluidbookpublication/delivery')) . '/' . $fluidbookId; + if ($variant) { + $res .= '-' . $variant; + } + $res .= '.jpg'; + return $res; + } +} diff --git a/app/Jobs/GenerateSecondPagePreview.php b/app/Jobs/GenerateSecondPagePreview.php deleted file mode 100644 index af5df6a15..000000000 --- a/app/Jobs/GenerateSecondPagePreview.php +++ /dev/null @@ -1,61 +0,0 @@ -publication = $publication; - } - - /** - * Execute the job. - */ - public function handle() - { - $cl = new CommandLine('node'); - $cl->setArg(null, resource_path('fluidbooktheme/theme_preview/secondpage_preview.js')); - $cl->setArg('width', 1920); - $cl->setArg('height', 1080); - $cl->setArg('delay', 2); - $cl->setArg('scale', 1); - $cl->setArg('dest', self::getPreviewPath($this->publication->id)); - $cl->setArg('page', 2); - $url = $this->publication->getPreviewURL(); - $cl->setArg('url', $url); - - $cl2 = new CommandLine('node'); - $cl2->setArg(null, resource_path('fluidbooktheme/theme_preview/secondpage_preview.js')); - $cl2->setArg('width', 320); - $cl2->setArg('height', 600); - $cl2->setArg('delay', 2); - $cl2->setArg('scale', 1); - $cl2->setArg('dest', self::getPreviewPath($this->publication->id), "mobile"); - $cl2->setArg('page', 2); - $url = $this->publication->getPreviewURL(); - $cl2->setArg('url', $url); - - - $cl->execute(); - $cl2->execute(); - - - $cl->dd(); - } - - public static function getPreviewPath($fluidbookId, $variant = '') - { - $res = storage_path('delivery') . '/' . $fluidbookId; - if ($variant) { - $res .= '-' . $variant; - } - $res .= '.jpg'; - return $res; - } -} diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index b7442f717..063059634 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -26,6 +26,7 @@ use App\Http\Controllers\Admin\Operations\FluidbookPublication\Services\ExportPd use App\Http\Controllers\Admin\Operations\FluidbookPublication\Services\SocialImageOperation; use App\Http\Controllers\Admin\Operations\FluidbookPublication\StatsOperation; use App\Jobs\FluidbookImagesPreprocess; +use App\Jobs\GenerateDeliveryThumbnailsPreview; use App\Jobs\GenerateSecondPagePreview; use App\Models\Base\ToolboxSettingsModel; use App\Models\Traits\CheckHash; @@ -266,7 +267,7 @@ class FluidbookPublication extends ToolboxSettingsModel $this->setComposedAttributes(); $this->checkHash(); - dispatch(new GenerateSecondPagePreview($this))->onQueue('theme'); + $this->generateThumbnailsPreview(true); if ($this->_compositionUpdated) { FluidbookImagesPreprocess::dispatch($this->id); } @@ -846,9 +847,9 @@ class FluidbookPublication extends ToolboxSettingsModel } - public function getPreviewURL() + public function getPreviewURL($params = []) { - return route('fluidbook_preview', ['version' => 'online', 'id' => $this->id, 'hash' => $this->hash]); + return route('fluidbook_preview', ['version' => 'online', 'id' => $this->id, 'hash' => $this->hash, ...$params]); } public function getTranslations() @@ -857,4 +858,24 @@ class FluidbookPublication extends ToolboxSettingsModel $l10n['default'] = $this->getDefaultTranslations($l10n); return $l10n; } + + public function generateThumbnailsPreview($sync = false) { + $mobilefirstFluidbookId = $this->mobilefirstFluidbookId; + $fm = null; + + $fn = 'dispatch'; + if($sync) + $fn = 'dispatchSync'; + + if($mobilefirstFluidbookId) { + $fm = self::find($mobilefirstFluidbookId); + } + + if($fm) { + GenerateDeliveryThumbnailsPreview::$fn($fm,320, 683, 'mobile'); + } + + GenerateDeliveryThumbnailsPreview::$fn($this,1920, 1201); + GenerateDeliveryThumbnailsPreview::$fn($this,320, 683, 'mobile'); + } } diff --git a/public/packages/fluidbook/toolbox/css/delivery.css b/public/packages/fluidbook/toolbox/css/delivery.css index 68740d239..80a52d1f4 100644 --- a/public/packages/fluidbook/toolbox/css/delivery.css +++ b/public/packages/fluidbook/toolbox/css/delivery.css @@ -44,6 +44,14 @@ body { align-items: center; flex-direction: column; } +.delivery-glimpses .preview-desktop { + width: 100%; + max-width: 454px; +} +.delivery-glimpses .preview-mobile { + width: 100%; + max-width: 133px; +} .delivery-glimpses .btn { margin-top: 8px; } diff --git a/public/packages/fluidbook/toolbox/css/delivery.css.map b/public/packages/fluidbook/toolbox/css/delivery.css.map index 2bd4f01ba..4df6b063e 100644 --- a/public/packages/fluidbook/toolbox/css/delivery.css.map +++ b/public/packages/fluidbook/toolbox/css/delivery.css.map @@ -1 +1 @@ -{"version":3,"sources":["delivery.less"],"names":[],"mappings":"AAAA;AAAK;EACD,uBAAA;;AAGJ;EACI,qBAAA;;AAGJ,OAAQ;EACJ,iBAAA;;AAGJ;EACI,aAAA;;AACA,OAAC;EACG,4BAA4B,uBAA5B;;AAIR;EACI,QAAA;;AAGJ;EACI,gBAAA;;AAIA,SAAC;EACG,mBAAA;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A1B;EACA,YAAY,YAAe,uBAA3B;EACA,aAAa,YAAe,uBAA5B;EACA,aAAa,YAAe,uBAA5B;EACA,aAAa,eAAe,6BAA5B;;EAGA,iBAAiB,eAAe,8BAAhC;EACA,gBAAgB,cAAe,gCAA/B;EACA,cAAc,eAAe,4BAA7B;EACA,aAAa,YAAe,6BAA5B;EACA,aAAa,cAAe,2BAA5B;EACA,cAAc,YAAe,yBAA7B;EACA,gBAAgB,YAAe,yBAA/B;EACA,iBAAiB,YAAe,yBAAhC;;EAGA,eAAe,YAAe,gCAA9B","file":"delivery.css"} \ No newline at end of file +{"version":3,"sources":["delivery.less"],"names":[],"mappings":"AAAA;AAAK;EACD,uBAAA;;AAGJ;EACI,qBAAA;;AAGJ,OAAQ;EACJ,iBAAA;;AAGJ;EACI,aAAA;;AACA,OAAC;EACG,4BAA4B,uBAA5B;;AAIR;EACI,QAAA;;AAGJ;EACI,gBAAA;;AAIA,SAAC;EACG,mBAAA;;AADJ,SAAC,OAEG,GAAE,IAAI;EACF,cAAc,kBAAd;;AAHR,SAAC,OAKG,GAAE;EACE,YAAA;EACA,oBAAA;;AAPR,SAAC,OASG;EACI,OAAO,WAAP;;AAGR,SAAC;EACG,mBAAA;;AADJ,SAAC,SAEG;EACI,yCAAA;EACA,aAAA;EACA,aAAA;EACA,uBAAA;EACA,mBAAA;EACA,sBAAA;;AARR,SAAC,SAUG;EACI,WAAA;EACA,gBAAA;;AAZR,SAAC,SAcG;EACI,WAAA;EACA,gBAAA;;AAhBR,SAAC,SAkBG;EACI,eAAA;;AAnBR,SAAC,SAqBG;EACI,kBAAA;;AAGR,SAAC;EACG,gBAAA;EACA,WAAA;EACA,iBAAA;EACA,gBAAA;EACA,SAAA;EACA,wBAAA;EACA,aAAA;;AACA,SARH,aAQI;EACG,cAAA;;AATR,SAAC,aAWG;EACI,aAAA;EACA,kBAAkB,WAAlB;EACA,kBAAA;EACA,mBAAA;EACA,kBAAA;;AAGR,SAAC;EACG,yCAAA;EACA,WAAA;EACA,YAAA;EACA,kBAAA;;AACA,SALH,QAKI;EACG,yBAAA;;AADJ,SALH,QAKI,iBAEG;EACI,2BAAA;;AAHR,SALH,QAKI,iBAKG;EACI,4BAAA;;AAXZ,SAAC,QAcG;EACI,WAAA;EACA,WAAA;EACA,aAAA;EACA,kBAAA;EACA,QAAA;;AAnBR,SAAC,QAqBG;EACI,kBAAA;EACA,eAAA;EACA,cAAA;;AAIR,SAAC;EACG,aAAA;EACA,gBAAA;EACA,kBAAA;;AAHJ,SAAC,aAIG;EACI,WAAA;EACA,YAAA;EACA,kBAAA;EACA,mBAAA;EACA,SAAA;EACA,QAAA;EACA,WAAW,qBAAX;;AAIR,SAAC,aACG;EACI,WAAA;EACA,SAAA;;AAKZ;EACI,SAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,qBAAA;EACA,kBAAA;;AAGJ;EACI,aAAa,eAAe,6BAA5B;EACA,aAAa,cAAe,2BAA5B;EACA,YAAY,eAAe,6BAA3B;EACA,WAAW,YAAe,uBAA1B;EACA,WAAW,cAAe,2BAA1B;EACA,WAAW,YAAe,uBAA1B;EACA,YAAY,YAAe,uBAA3B;EACA,aAAa,YAAe,uBAA5B;EACA,aAAa,YAAe,uBAA5B;EACA,aAAa,eAAe,6BAA5B;;EAGA,iBAAiB,eAAe,8BAAhC;EACA,gBAAgB,cAAe,gCAA/B;EACA,cAAc,eAAe,4BAA7B;EACA,aAAa,YAAe,6BAA5B;EACA,aAAa,cAAe,2BAA5B;EACA,cAAc,YAAe,yBAA7B;EACA,gBAAgB,YAAe,yBAA/B;EACA,iBAAiB,YAAe,yBAAhC;;EAGA,eAAe,YAAe,gCAA9B","file":"delivery.css"} \ No newline at end of file diff --git a/public/packages/fluidbook/toolbox/css/delivery.less b/public/packages/fluidbook/toolbox/css/delivery.less index 95dfa995e..1526e853b 100644 --- a/public/packages/fluidbook/toolbox/css/delivery.less +++ b/public/packages/fluidbook/toolbox/css/delivery.less @@ -49,6 +49,14 @@ html,body { align-items: center; flex-direction: column; } + .preview-desktop { + width: 100%; + max-width: 454px; + } + .preview-mobile { + width: 100%; + max-width: 133px; + } .btn { margin-top: 8px; } diff --git a/resources/fluidbooktheme/theme_preview/secondpage_preview.js b/resources/fluidbooktheme/theme_preview/secondpage_preview.js index a0c3e23d3..f2ec9b2c6 100644 --- a/resources/fluidbooktheme/theme_preview/secondpage_preview.js +++ b/resources/fluidbooktheme/theme_preview/secondpage_preview.js @@ -22,6 +22,7 @@ const optionDefinitions = [ }); const page = await browser.newPage(); + await page.setDefaultNavigationTimeout(0); await page.setViewport({ width: options.width / options.scale, height: options.height / options.scale, deviceScaleFactor: options.scale, }); diff --git a/resources/views/fluidbook_publication/delivery.blade.php b/resources/views/fluidbook_publication/delivery.blade.php index 9643712ee..42ba9e014 100644 --- a/resources/views/fluidbook_publication/delivery.blade.php +++ b/resources/views/fluidbook_publication/delivery.blade.php @@ -1,7 +1,6 @@ @extends(backpack_view('blank')) @php -dd(storage_path('delivery') . '/'); $breadcrumbs = [ trans('backpack::crud.admin') => url(config('backpack.base.route_prefix'), 'dashboard'), trans('backpack::base.my_account') => false, @@ -9,10 +8,15 @@ dd(storage_path('delivery') . '/'); $statusText = $fluidbook->status ? 'prêt' : 'en cours de production'; $qrCodeMobile = QrCode::size(311)->color(27, 42, 78)->generate($fluidbook->getPreviewURL()); + + $fluidbookDesktopPreview = route('deliveryThumb', ['id' => $fluidbook->id, 'type' => 'desktop']); + $fluidbookMobilePreview = route('deliveryThumb', ['id' => $fluidbook->id, 'type' => 'mobile']); + $fluidbookMobileFirstId = $fluidbook->mobilefirstFluidbookId; if($fluidbookMobileFirstId){ $previewMobileFirstUrl = App\Models\FluidbookPublication::find($fluidbookMobileFirstId)->getPreviewURL(); $qrCodeMobileFirst = QrCode::size(311)->color(27, 42, 78)->generate($previewMobileFirstUrl); + $fluidbookMobileFirstPreview = route('deliveryThumb', ['id' => $fluidbookMobileFirstId, 'type' => 'mobile']); } $totalPages = $fluidbook->getPagesNumber(); @@ -108,12 +112,14 @@ dd(storage_path('delivery') . '/');

Version Desktop

+ Voir

Version Mobile

+ Voir
@include('fluidbook_publication.qrcode_popup', ['id' => 'scanBoxMobile', 'text' => 'Mobile', 'qrcode' => $qrCodeMobile]) @@ -122,6 +128,7 @@ dd(storage_path('delivery') . '/');

Version Mobile-first

+ Voir
@include('fluidbook_publication.qrcode_popup', ['id' => 'scanBoxMobileFirst', 'text' => 'Mobile-first', 'qrcode' => $qrCodeMobileFirst]) diff --git a/scripts/restartworkers-dev.bat b/scripts/restartworkers-dev.bat index 45ee64e4f..8b63cbf48 100644 --- a/scripts/restartworkers-dev.bat +++ b/scripts/restartworkers-dev.bat @@ -1,6 +1,6 @@ @echo off cls -C:\tools\cygwin\bin\ssh.exe -t root@dev.toolbox.fluidbook.com 'docker exec -it -u toolbox fluidbook-toolbox-dev /application/scripts/restartworkers.sh' +ssh -t root@dev.toolbox.fluidbook.com 'docker exec -it -u toolbox fluidbook-toolbox-dev /application/scripts/restartworkers.sh' exit exit exit diff --git a/storage/delivery/30116.jpg b/storage/delivery/30116.jpg deleted file mode 100644 index 172d36499..000000000 Binary files a/storage/delivery/30116.jpg and /dev/null differ