--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Jobs\GenerateSecondPagePreview;
+use Illuminate\Console\Command;
+use App\Models\FluidbookPublication;
+
+class DebugDeliveryJob extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'app:debug-delivery-job';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Command description';
+
+ /**
+ * Execute the console command.
+ */
+ public function handle()
+ {
+ //
+ $f = FluidbookPublication::find(30116);
+ GenerateSecondPagePreview::dispatchSync($f);
+ }
+}
namespace App\Jobs;
-use App\Models\FluidbookTheme;
+use App\Models\FluidbookPublication;
use Cubist\Util\CommandLine;
class GenerateSecondPagePreview extends Base
{
- public $width;
+ public $publication;
- public function __construct($width = 1920)
+ public function __construct(FluidbookPublication $publication)
{
- $this->width = $width;
+ $this->publication = $publication;
}
/**
* Execute the job.
*/
- public function handle(): void
+ 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('width', 1920);
$cl->setArg('height', 1080);
$cl->setArg('delay', 2);
$cl->setArg('scale', 1);
- $cl->setArg('dest', self::getPreviewPath($this->theme->getIdValue()));
+ $cl->setArg('dest', self::getPreviewPath($this->publication->id));
$cl->setArg('page', 2);
- $url = $this->theme->getPreviewURL(['shortLoading' => 1, 'transition' => 1, 'puppeteer' => 1]);
+ $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;
}
}
use App\Http\Controllers\Admin\Operations\FluidbookPublication\Services\SocialImageOperation;
use App\Http\Controllers\Admin\Operations\FluidbookPublication\StatsOperation;
use App\Jobs\FluidbookImagesPreprocess;
+use App\Jobs\GenerateSecondPagePreview;
use App\Models\Base\ToolboxSettingsModel;
use App\Models\Traits\CheckHash;
use App\Models\Traits\PublicationSettings;
{
$this->setComposedAttributes();
$this->checkHash();
+
+ dispatch(new GenerateSecondPagePreview($this))->onQueue('theme');
if ($this->_compositionUpdated) {
FluidbookImagesPreprocess::dispatch($this->id);
}
});
const page = await browser.newPage();
- page.on('console', async (msg) => {
- const msgArgs = msg.args();
- for (let i = 0; i < msgArgs.length; ++i) {
- console.log(await msgArgs[i].jsonValue());
- }
- });
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.screenshot({path: options.dest, type: 'jpeg', quality: 95});
+ await page.goto(options.url, {waitUntil: 'networkidle2'})
+ await page.waitForNavigation()
await new Promise(r => setTimeout(r, 1000 * (options.delay + 3)));
- await page.evaluate(() => console.log(document.body.innerHTML));
- // Move to page 2
+ //
await page.evaluate(() => window.fluidbook.setCurrentPage(2));
- // Wait 1s and take a screenshot
- await new Promise(r => setTimeout(r, 2000));
+ await new Promise(r => setTimeout(r, 1000));
+ await page.screenshot({path: options.dest, type: 'jpeg', quality: 95});
await browser.close();
})();
@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,
@echo off
cls
-C:\tools\cygwin\bin\ssh.exe -t root@dev.toolbox.fluidbook.com 'docker exec -it -u toolbox fluidbook-toolbox-dev /bin/bash'
+ssh -t root@dev.toolbox.fluidbook.com 'docker exec -it -u toolbox fluidbook-toolbox-dev /bin/bash'