]> _ Git - cubeextranet.git/commitdiff
wip #3872 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Sep 2020 14:17:47 +0000 (14:17 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Sep 2020 14:17:47 +0000 (14:17 +0000)
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 842ae0214c98b22b57307d0f74b66392b8487b73..ed7545e3f5628ddebae108ea071ff3a2a5370127 100644 (file)
@@ -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;
index af03c9129ab4434ab1bec2a4b419eec5432cdaa4..b96d77c7cc7ee30f88901fa09158d9a51f6fdd3d 100644 (file)
@@ -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];
index dda610aff85b45b89f7bde4926bd25131fcd58d1..e250a354f3a07b9dad52a47b9797ca436e001637 100644 (file)
@@ -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];