From 0d10106ed48fdfe679508b419d7d23f004bbf9f6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 8 Sep 2020 14:17:47 +0000 Subject: [PATCH] wip #3872 @1.5 --- inc/ws/Controlleur/class.ws.services.php | 74 +++++++++---------- inc/ws/Controlleur/class.ws.url.php | 7 +- .../html5/master/class.ws.html5.compiler.php | 2 +- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 842ae0214..ed7545e3f 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -174,53 +174,47 @@ class wsServices extends cubeFlashGateway $this->outputXML = false; $dao = new wsDAOBook($this->con); - $book = $dao->selectById($this->args['id']); + if (isset($this->args['id']) && $this->args['id'] <= 18972) { + $book = $dao->selectById($this->args['id']); + } else if (isset($this->args['cid'])) { + $book = $dao->selectByCid($this->args['cid']); + } else { + return; + } + + $id = $book->book_id; if (isset($this->args['image'])) { - $cover = WS_BOOKS . '/working/' . $this->args['id'] . '/' . $this->args['image']; + $cover = WS_BOOKS . '/working/' . $id . '/' . $this->args['image']; } else { - if (isset($book->parametres->facebook_image) && $book->parametres->facebook_image != '') { - $c = WS_BOOKS . '/working/' . $this->args['id'] . '/' . $book->parametres->facebook_image; + $c = WS_BOOKS . '/working/' . $id . '/' . $book->parametres->facebook_image; if (file_exists($c)) { $cover = $c; } - } else if ($book->parametres->pdfThumbnails) { - $pdf = wsDAOBook::getWorkingFile($book->parametres->pdfThumbnails, $book->book_id); - - if (file_exists($pdf)) { - $dir = WS_CACHE . '/thumbs/' . sha1($pdf) . '/'; - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - $jpeg = $dir . '/cover.jpg'; - $mtime = filemtime($jpeg); - - if (!file_exists($jpeg) || $mtime < filemtime(__FILE__) || $mtime < filemtime($pdf)) { - wsPDFConvert::makeShot($pdf, $jpeg, 1, '', 150, 90, 4, 'PNM', 1200, -1); - } - $cover = $jpeg; - } - } - - if (!isset($cover)) { - $pages = $dao->getPagesOfBook($this->args['id']); - $dir = wsDocument::getDir($pages[1]['document_id']); - $cover = $dir . '/html/t150-' . $pages[1]['document_page'] . '.jpg'; - if (!file_exists($cover)) { - $cover = $dir . '/p' . $pages[1]['document_page'] . '.jpg'; - } - $i = WS_FILES . '/cover/' . $this->args['id'] . '.jpg'; - - if (!file_exists($i) || filemtime(__FILE__) > filemtime($i) || filemtime($cover) > filemtime($i)) { - $it = new imageTools(); - $it->loadImage($cover); - - $it->resize(1200, 1000000, 'ratio', false); - $it->output('jpeg', $i, 85); - $it->close(); + } else { + $cover = WS_FILES . '/social_image/' . $id . '.jpg'; + $limit = TIME - (3600 * 24 * 3); + if (isset($_GET['force']) || !file_exists($cover) || filemtime($cover) < $limit) { + $w = 1200; + $h = 628; + $tmp = CubeIT_Files::tempnam() . '.svg'; + $cl = new CubeIT_CommandLine('xvfb-run'); + $cl->setArg('server-args', '-screen 0, ' . $w . 'x' . $h . 'x24'); + $cl->setArg(null, '/usr/bin/cutycapt'); + $cl->setArg('min-width', $w); + $cl->setArg('min-height', $h); + $cl->setArg('zoom-factor', 0.5); + $cl->setArg('url', 'https://workshop.fluidbook.com/viewerh/' . $id . '_' . $book->hash . '_' . TIME . '/?nointerface=1#/page/0'); + $cl->setArg('delay', 10000); + $cl->setArg('out', $tmp); + $cl->execute(); + $cl->debug(); + + $geo=$w.'x'.$h; + `convert $tmp -crop $geo+0+0 +repage -resize $geo -flatten $cover`; + unlink($tmp); } - $cover = $i; } } @@ -1484,7 +1478,7 @@ class wsServices extends cubeFlashGateway $c->page = $search['body']; $c->url = $search['url']; $c->version = $version; - if(isset($res)) { + if (isset($res)) { $c->benchmark = serialize($res); } $c->score = $score; diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index af03c9129..b96d77c7c 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -1105,6 +1105,7 @@ html.tall{height:150%}' . "\n"; { global $core; + $nointerface = isset($_GET['nointerface']); $args = cubePage::getArgs($args); $e = explode('_', $args[0]); @@ -1140,8 +1141,10 @@ html.tall{height:150%}' . "\n"; exit; } - $book->parametres->scorm_enable = false; - $dao->compile($book_id, 'html5', false, false, false, $book, false); + if (!$nointerface) { + $book->parametres->scorm_enable = false; + $dao->compile($book_id, 'html5', false, false, false, $book, false); + } $book_id = $e[0]; $hash = $e[1]; diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index dda610aff..e250a354f 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -962,7 +962,7 @@ class wsHTML5Compiler $socialTitle = html::escapeHTML($this->book->parametres->facebook_title ? $this->book->parametres->facebook_title : $titre); $socialDescription = html::escapeHTML($this->book->parametres->facebook_description ? $this->book->parametres->facebook_description : $this->book->parametres->seoDescription); - $socialImage = 'https://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $this->book_id . '&j=' . TIME; + $socialImage = 'https://workshop.fluidbook.com/services/facebook_thumbnail?cid=' . $this->book->cid . '&j=' . TIME; $dim = CubeIT_Image::getimagesize($socialImage); $socialImageWidth = $dim[0]; $socialImageHeight = $dim[1]; -- 2.39.5