use \Fluidbook\Tools\Compiler\FluidbookCompiler;
use Favicon;
use Secure;
+ use Images;
protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
return $res;
}
- protected function writeImages()
- {
- set_time_limit(0);
- switch ($this->fluidbookSettings->mobileVersion) {
- case 'html5-desktop':
- $this->backgroundsPrefix = array(true, false);
- $this->svg = true;
- break;
- case 'html5-images':
- $this->backgroundsPrefix = array(true);
- $this->svg = false;
- break;
- default:
- $this->backgroundsPrefix = array(false);
- $this->svg = true;
- break;
- }
-
- $rasterizePages = $this->config->rasterizePages;
- $this->config->pagesDimensions = [];
-
- if ($this->fluidbookSettings->mobileNavigationType === 'mobilefirst') {
- $imdir = 'mf';
- } else {
- $imdir = 'html';
- }
-
- $thumbs = array();
- foreach ($this->pages as $page => $infos) {
- $thisrasterize = in_array($page, $rasterizePages);
- $thisimagesvg = !$thisrasterize && $this->svg;
- $thisbackgroundPrefix = $thisrasterize ? [true] : $this->backgroundsPrefix;
-
- foreach ($this->getResolutions() as $r) {
- foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
- $source = $this->getFluidbook()->getFile($page, $this->imageFormat, $r, $backgroundsPrefix, true, $imdir);
- if ($r === $this->maxRes) {
- $this->getPageDimension($page);
- }
- $this->vdir->copy($source, 'data/background/' . $r . '/' . ($backgroundsPrefix ? 't' : 'p') . $page . '.' . $this->imageFormat);
- }
- }
-
- if ($thisimagesvg) {
- $this->vdir->copy(
- $this->getFluidbook()->getFile($page, 'svg', 150, true,
- in_array($page, $this->config->vectorPages), 'html')
- , 'data/contents/p' . $page . '.svg');
- }
-
- $t = $this->getFluidbook()->getThumbFile($page, $this->imageFormat);
- $this->vdir->copy($t, 'data/thumbnails/p' . $page . '.' . $this->imageFormat);
- $this->log('Made image page ' . $page);
- }
-
-
- $this->_makeCover($this->getFluidbook()->getFile(1, 'jpg', 150, true, true));
- $this->log('Made cover for apps');
-
- $this->log('Made images');
- }
-
/**
* @param $page
}
- protected function _makeCover($orig)
- {
- $cached = $this->wdir . '/_cover.jpg';
-
- if (!file_exists($cached) || filemtime($cached) < filemtime($orig)) {
- $size = Image::getimagesize($orig);
- $w = $size[0];
- $h = $size[1];
-
- $tmp = Files::tempnam() . '.png';
-
- $c = new CommandLine('convert');
- $c->setArg(null, resource_path('fluidbookpublication/cover/shade-cover-app.png'));
- $c->setManualArg('-resize ' . round($w / 3) . 'x' . $h);
- $c->setArg(null, $tmp);
- $c->execute();
- $convert = new CommandLine('composite');
- $cmd = '-compose Multiply ';
- $cmd .= $tmp . ' ' . $orig . ' ';
- $cmd .= $cached;
- $convert->setManualArg($cmd);
- $convert->execute();
-
- unlink($tmp);
- }
- $this->vdir->copy($cached, 'cover.jpg', true);
-
- }
protected function _lessBoolean($val)
{
--- /dev/null
+<?php
+
+namespace App\Fluidbook\Compiler;
+
+use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
+use Cubist\Util\Graphics\Image;
+
+trait Images
+{
+
+ protected function writeImages()
+ {
+ set_time_limit(0);
+ switch ($this->fluidbookSettings->mobileVersion) {
+ case 'html5-desktop':
+ $this->backgroundsPrefix = array(true, false);
+ $this->svg = true;
+ break;
+ case 'html5-images':
+ $this->backgroundsPrefix = array(true);
+ $this->svg = false;
+ break;
+ default:
+ $this->backgroundsPrefix = array(false);
+ $this->svg = true;
+ break;
+ }
+
+ $rasterizePages = $this->config->rasterizePages;
+ $this->config->pagesDimensions = [];
+
+ if ($this->fluidbookSettings->mobileNavigationType === 'mobilefirst') {
+ $imdir = 'mf';
+ } else {
+ $imdir = 'html';
+ }
+
+ $thumbs = array();
+ foreach ($this->pages as $page => $infos) {
+ $thisrasterize = in_array($page, $rasterizePages);
+ $thisimagesvg = !$thisrasterize && $this->svg;
+ $thisbackgroundPrefix = $thisrasterize ? [true] : $this->backgroundsPrefix;
+
+ foreach ($this->getResolutions() as $r) {
+ foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
+ $source = $this->getFluidbook()->getFile($page, $this->imageFormat, $r, $backgroundsPrefix, true, $imdir);
+ if ($r === $this->maxRes) {
+ $this->getPageDimension($page);
+ }
+ $this->vdir->copy($source, 'data/background/' . $r . '/' . ($backgroundsPrefix ? 't' : 'p') . $page . '.' . $this->imageFormat);
+ }
+ }
+
+ if ($thisimagesvg) {
+ $this->vdir->copy(
+ $this->getFluidbook()->getFile($page, 'svg', 150, true,
+ in_array($page, $this->config->vectorPages), 'html')
+ , 'data/contents/p' . $page . '.svg');
+ }
+
+ $t = $this->getFluidbook()->getThumbFile($page, $this->imageFormat);
+ $this->vdir->copy($t, 'data/thumbnails/p' . $page . '.' . $this->imageFormat);
+ $this->log('Made image page ' . $page);
+ }
+
+
+ $this->_makeCover($this->getFluidbook()->getFile(1, 'jpg', 150, true, true));
+ $this->log('Made cover for apps');
+
+ $this->log('Made images');
+ }
+
+ protected function _makeCover($orig)
+ {
+ $cached = $this->wdir . '/_cover.jpg';
+
+ if (!file_exists($cached) || filemtime($cached) < filemtime($orig)) {
+ $size = Image::getimagesize($orig);
+ $w = $size[0];
+ $h = $size[1];
+
+ $tmp = Files::tempnam() . '.png';
+
+ $c = new CommandLine('convert');
+ $c->setArg(null, resource_path('fluidbookpublication/cover/shade-cover-app.png'));
+ $c->setManualArg('-resize ' . round($w / 3) . 'x' . $h);
+ $c->setArg(null, $tmp);
+ $c->execute();
+
+ $convert = new CommandLine('composite');
+ $cmd = '-compose Multiply ';
+ $cmd .= $tmp . ' ' . $orig . ' ';
+ $cmd .= $cached;
+ $convert->setManualArg($cmd);
+ $convert->execute();
+
+ unlink($tmp);
+ }
+ $this->vdir->copy($cached, 'cover.jpg', true);
+
+ }
+
+}
use App\Models\FluidbookPublication;
use App\Models\FluidbookTheme;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Cubist\Util\PHP;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
trait PreviewOperation
{
use FluidbookPreviewOperation;
+
protected function setupPreviewRoutes($segment, $routeName, $controller)
{
Route::match(['get'], $segment . '/preview/{version}/{id}_{hash}', function ($version, $id, $hash) use ($segment) {
protected function _preview($segment, $version, $id, $hash, $time = null, $path = null)
{
+ PHP::neverStop(false);
$q = request()->getQueryString();
if ($q) {
$q = '?' . $q;
*/
public function loadingCompile($url, $id, $hash)
{
+ PHP::neverStop(false);
+
self::_getFluidbookAndTheme($id, $hash, $fluidbook, $theme);
$res = $this->_loadingCompile($theme, $fluidbook->title, $url);
return response($res);
*/
public function preview($version, $fluidbook, $theme, $path = 'index.html')
{
+ PHP::neverStop(false);
+
$isScorm = $version === 'scorm';
$dest = $fluidbook->getFinalPath($theme, $isScorm);