*
* @var string
*/
- protected $signature = 'fluidbook:preview-generate {id} {sync?}';
+ protected $signature = 'fluidbook:preview-generate {id} {--sync}';
/**
* The console command description.
{
//
$f = FluidbookPublication::find($this->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');
+ $f->generateThumbnailsPreview($this->option('sync', false));
}
}
use App\Jobs\GenerateDeliveryThumbnailsPreview;
use App\Models\FluidbookPublication;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Cubist\Util\Files\Files;
use Illuminate\Support\Facades\Route;
use Prologue\Alerts\Facades\Alert;
abort(404);
}
- $relayPath = '/fluidbookpublication/delivery/';
- $relayPath = protected_path($relayPath);
+ $relayPath = Files::mkdir(protected_path('/fluidbookpublication/delivery/'));
$relayPath .= $id;
$relayPath .= $type === "desktop" ? '' : '-mobile';
$relayPath .= '.jpg';
- if(!file_exists($relayPath)) {
- $f = FluidbookPublication::find($id);
- $f->generateThumbnailsPreview(true);
+ if (!file_exists($relayPath)) {
+ (new GenerateDeliveryThumbnailsPreview(FluidbookPublication::withoutGlobalScopes()->find($id), $type === 'mobile' ? 'mobile' : ''))->handle();
}
return XSendFileController::sendfile($relayPath);
}
use App\Models\FluidbookPublication;
use Cubist\Util\CommandLine;
use Cubist\Util\Files\Files;
+use Illuminate\Support\Facades\Log;
class GenerateDeliveryThumbnailsPreview extends Base
{
public $height;
public $v;
- public function __construct(FluidbookPublication $publication, $width, $height, $v = '')
+ public function __construct(FluidbookPublication $publication, $v = '')
{
$this->publication = $publication;
- $this->width = $width;
- $this->height = $height;
+ if(!$v) {
+ $this->width = 1920;
+ $this->height = 1201;
+ }else{
+ $this->width = 320;
+ $this->height = 683;
+ }
$this->v = $v;
}
public function handle()
{
$cl = new CommandLine('node');
- $cl->setArg(null, resource_path('fluidbooktheme/theme_preview/secondpage_preview.js'));
+ $cl->setArg(null, resource_path('fluidbookpublication/delivery/preview.js'));
$cl->setArg('width', $this->width);
$cl->setArg('height', $this->height);
$cl->setArg('delay', 2);
$url = $this->publication->getPreviewURL(['shortLoading' => 1, 'transition' => 1, 'puppeteer' => 1]);
$cl->setArg('url', $url);
$cl->execute();
+ $cl->debug();
}
public static function getPreviewPath($fluidbookId, $variant = '')
public function generateThumbnailsPreview($sync = false)
{
$mobilefirstFluidbookId = $this->mobilefirstFluidbookId;
- $fm = null;
+ $mobileFirst = null;
$fn = 'dispatch';
- if ($sync)
+ if ($sync) {
$fn = 'dispatchSync';
+ }
if ($mobilefirstFluidbookId) {
- $fm = self::find($mobilefirstFluidbookId);
+ $mobileFirst = self::withoutGlobalScopes()->find($mobilefirstFluidbookId);
}
- if ($fm) {
+ if ($mobileFirst) {
if ($sync) {
- GenerateDeliveryThumbnailsPreview::$fn($fm, 320, 683, 'mobile');
+ (new GenerateDeliveryThumbnailsPreview($mobileFirst, 'mobile'))->handle();
} else {
- dispatch(new GenerateDeliveryThumbnailsPreview($fm, 320, 683, 'mobile'))->onQueue('theme');
+ dispatch(new GenerateDeliveryThumbnailsPreview($mobileFirst, 'mobile'))->onQueue('theme');
}
}
if ($sync) {
- GenerateDeliveryThumbnailsPreview::$fn($this, 1920, 1201);
- GenerateDeliveryThumbnailsPreview::$fn($this, 320, 683, 'mobile');
+ (new GenerateDeliveryThumbnailsPreview($this))->handle();
+ (new GenerateDeliveryThumbnailsPreview($this, 'mobile'))->handle();
} else {
- dispatch(new GenerateDeliveryThumbnailsPreview($this, 1920, 1201))->onQueue('theme');
- dispatch(new GenerateDeliveryThumbnailsPreview($this, 320, 683, 'mobile'))->onQueue('theme');
+ dispatch(new GenerateDeliveryThumbnailsPreview($this, ))->onQueue('theme');
+ dispatch(new GenerateDeliveryThumbnailsPreview($this, 'mobile'))->onQueue('theme');
}
}
--- /dev/null
+const puppeteer = require('puppeteer');
+const commandLineArgs = require('command-line-args');
+const optionDefinitions = [
+ {name: 'url', type: String},
+ {name: 'dest', type: String},
+ {name: 'delay', type: Number, defaultOption: 10},
+ {name: 'scale', type: Number, defaultOption: 1},
+ {name: 'width', type: Number, defaultOption: 1920},
+ {name: 'height', type: Number, defaultOption: 1080},
+ {name: 'page', type: Number, defaultOption: 2}
+];
+
+(async () => {
+ const options = commandLineArgs(optionDefinitions);
+ const browser = await puppeteer.launch({
+ headless: true,
+ args: [
+ "--disable-setuid-sandbox",
+ "--no-sandbox",
+ ],
+ executablePath: 'google-chrome-stable',
+ });
+
+ 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,
+ });
+ await page.goto(options.url, {waitUntil: 'networkidle2'});
+ //await page.waitForNavigation();
+ await new Promise(r => setTimeout(r, 1000 * (options.delay + 3)));
+ //
+ await page.evaluate(() => window.fluidbook.setCurrentPage(2));
+ await new Promise(r => setTimeout(r, 1000));
+ await page.screenshot({path: options.dest, type: 'jpeg', quality: 95});
+
+ await browser.close();
+})();
+++ /dev/null
-const puppeteer = require('puppeteer');
-const commandLineArgs = require('command-line-args');
-const optionDefinitions = [
- {name: 'url', type: String},
- {name: 'dest', type: String},
- {name: 'delay', type: Number, defaultOption: 10},
- {name: 'scale', type: Number, defaultOption: 1},
- {name: 'width', type: Number, defaultOption: 1920},
- {name: 'height', type: Number, defaultOption: 1080},
- {name: 'page', type: Number, defaultOption: 2}
-];
-
-(async () => {
- const options = commandLineArgs(optionDefinitions);
- const browser = await puppeteer.launch({
- headless: true,
- args: [
- "--disable-setuid-sandbox",
- "--no-sandbox",
- ],
- executablePath: 'google-chrome-stable',
- });
-
- 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,
- });
- await page.goto(options.url, {waitUntil: 'networkidle2'})
- await page.waitForNavigation()
- await new Promise(r => setTimeout(r, 1000 * (options.delay + 3)));
- //
- await page.evaluate(() => window.fluidbook.setCurrentPage(2));
- await new Promise(r => setTimeout(r, 1000));
- await page.screenshot({path: options.dest, type: 'jpeg', quality: 95});
-
- await browser.close();
-})();
$enabledFeatures = array_filter($featuresSorted, function($n){ return $n['value'] !== "0" && !empty($n['value']); });
$disabledFeatures = array_filter($featuresSorted, function($n){ return $n['value'] !== "1" && empty($n['value']); });
- $icons = App\Models\FluidbookIconset::get('icons')->toArray();
+ $icons = App\Models\FluidbookIconset::withoutGlobalScopes()->get('icons')->toArray();
$statUrl = route('stats', ['fluidbook_id' => $fluidbook->id, 'hash' => $fluidbook->hash]);
$cid = $fluidbook->cid;
<div class="card position-sticky" style="top: 50px">
<div class="card-body">
<h2>{{ __('Publiez votre Fluidbook') }}</h2>
- <p>{{ __('L\'adresse d’hébergement a déjà été configurée, vous pouvez mettre votre Fluidbook
+ @if($fluidbook->install_online && isset($serverName))
+ <p>{{ __('L\'adresse d’hébergement a déjà été configurée, vous pouvez mettre votre Fluidbook
directement en ligne en cliquant ci-dessous :')}}</p>
- <div class="btn-install">
- <a href="{{ $prefixDownloadUrl.'/install/online' }}"
- class="btn btn-primary font-weight-normal text-left" rel="noopener">
- {!! __('Installer sur le serveur :server', ['server' => "<span class='font-weight-bold'>".$serverName."</span>"]) !!}
- <p class="m-0 font-xs font-weight-normal">{{ $installServerUrl }}</p>
- </a>
- </div>
+ <div class="btn-install">
+ <a href="{{ $prefixDownloadUrl.'/install/online' }}"
+ class="btn btn-primary font-weight-normal text-left" rel="noopener">
+ {!! __('Installer sur le serveur :server', ['server' => "<span class='font-weight-bold'>".$serverName."</span>"]) !!}
+ <p class="m-0 font-xs font-weight-normal">{{ $installServerUrl }}</p>
+ </a>
+ </div>
+ @endif
<div class="delivery-dropdown position-relative">
<div class="dropdown-control d-flex justify-content-between">
<span>{{ __('Téléchargez et installez votre Fluidbook') }}</span>