]> _ Git - cubeextranet.git/commitdiff
Merge video related fixes to compiler. WIP #897 @0.5
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Aug 2017 10:19:32 +0000 (10:19 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Aug 2017 10:19:32 +0000 (10:19 +0000)
inc/ws/Util/html5/html5video/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index e9f8fdc224e1a99c4dc9e5937a84c992fdb92f5e..97375a41c076c90ac5a2996885e9afeac38d31d6 100644 (file)
@@ -216,15 +216,15 @@ class wsHTML5Compiler {
                switch ($this->book->parametres->mobileVersion) {
                        case 'html5-desktop':
                                $this->backgroundsPrefix = array('t', 'p');
-                               $svg = true;
+                               $this->svg = true;
                                break;
                        case 'html5-images':
                                $this->backgroundsPrefix = array('t');
-                               $svg = false;
+                               $this->svg = false;
                                break;
                        default:
                                $this->backgroundsPrefix = array('p');
-                               $svg = true;
+                               $this->svg = true;
                                break;
                }
 
@@ -979,6 +979,9 @@ class wsHTML5Compiler {
 
                file_put_contents($this->vdir . '/data/search.index.js', $jsindex);
                file_put_contents($this->vdir . '/data/search.texts.js', $jstexts);
+               if ($this->book->parametres->highlightResults) {
+                       file_put_contents($this->vdir . '/data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
+               }
        }
 
        public function supportSVG() {
@@ -1009,6 +1012,9 @@ class wsHTML5Compiler {
                $this->config->retinaResolution = $this->maxRes;
                $this->config->pageLabels = $this->pageLabels;
                $this->config->pageZoomFactor = $this->z;
+               $this->config->multiply = $this->multiply;
+               $this->config->cssScale = $this->cssScale;
+               $this->config->pdfZoomFactor = $this->pdf2htmlRatio;
                if ($this->home) {
                        $this->config->home = 'http://home';
                }
@@ -1100,6 +1106,7 @@ class wsHTML5Compiler {
        }
 
        protected function writeImages() {
+               global $core;
                foreach ($this->getResolutions() as $r) {
                        mkdir($this->vdir . '/data/background/' . $r, 0777, true);
                }
@@ -1108,15 +1115,21 @@ class wsHTML5Compiler {
                foreach ($this->pages as $page => $infos) {
                        $docdir = wsDocument::getDir($infos['document_id']);
                        if ($this->svg) {
-                               $orig = $docdir . 'html/p' . $infos['document_page'] . '.svg';
-                               $opt = $docdir . 'html/o' . $infos['document_page'] . '.svg';
-
-                               $svg = $orig;
-                               if (file_exists($opt) && filesize($opt) > 0) {
-                                       $svg = $opt;
+                               $full = $docdir . 'html/fp' . $infos['document_page'] . '.svg';
+                               $orig = $docdir . 'html/tp' . $infos['document_page'] . '.svg';
+                               $opt = $docdir . 'html/to' . $infos['document_page'] . '.svg';
+
+                               if (!file_exists($full) || filemtime($full) < 1503671520) {
+                                       if (!isset($doc) || $doc->document_id != $infos['document_id']) {
+                                               $dao = new wsDAODocument($core->con);
+                                               $doc = $dao->selectById($infos['document_id']);
+                                       }
+                                       $doc->makeSVGFile($infos['document_page']);
                                }
+                               wsDocument::extractTexts($full, $orig);
+                               wsTools::optimizeSVG($orig, $opt);
 
-                               $this->copy($svg, $this->vdir . '/data/contents/p' . $page . '.svg');
+                               $this->copy($opt, $this->vdir . '/data/contents/p' . $page . '.svg');
                        }
 
                        foreach ($this->getResolutions() as $r) {
@@ -1263,7 +1276,7 @@ class wsHTML5Compiler {
                $lessVariables['book-page-height'] = $h;
 
                $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.doublePage._3d,#shadow>div{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
-               $res[] = '.doublePage,#pages,#links{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
+               $res[] = '.doublePage,#pages,#links,#searchHighlights{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
                $res[] = '.landscape .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}';
                $res[] = '.landscape .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}';
                $res[] = '.portrait .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}';
index 3170331072833cf05b8718310476e12c63b00b10..97375a41c076c90ac5a2996885e9afeac38d31d6 100644 (file)
@@ -1164,8 +1164,7 @@ class wsHTML5Compiler {
                }
        }
 
-       public
-       function makeThumbSprites(array $thumbs) {
+       public function makeThumbSprites(array $thumbs) {
                $cols = 10;
                $rows = 10;
                $perSprite = $cols * $rows;
@@ -1202,8 +1201,7 @@ class wsHTML5Compiler {
                return $res;
        }
 
-       protected
-       function _makeCover($orig) {
+       protected function _makeCover($orig) {
                $size = getimagesize($orig);
                $w = $size[0];
                $h = $size[1];
@@ -1227,8 +1225,7 @@ class wsHTML5Compiler {
                unlink($tmp);
        }
 
-       protected
-       function copy($s, $t) {
+       protected function copy($s, $t) {
                if (!file_exists($s)) {
                        fb($s . ' dont exists');
                        return false;
@@ -1448,8 +1445,7 @@ class wsHTML5Compiler {
                return count($res);
        }
 
-       protected
-       function _writeLess($variables) {
+       protected function _writeLess($variables) {
                if ($this->widget) {
                        $this->lessFiles[] = 'widget';
                }
@@ -1511,8 +1507,7 @@ class wsHTML5Compiler {
                }
        }
 
-       protected
-       function _cssBackground() {
+       protected function _cssBackground() {
                $body = '#background,#splash{';
                $body .= 'background-color:#' . $this->theme->parametres->backgroundColor . ';';
                switch ($this->theme->parametres->repeat) {
@@ -1573,8 +1568,7 @@ class wsHTML5Compiler {
                return $body;
        }
 
-       public
-       static function writeCSSUA($property, $value) {
+       public static function writeCSSUA($property, $value) {
                $res = array();
                foreach (self::$uaPrefixes as $prefix) {
                        $res[] = $prefix . $property . ':' . $value;
@@ -1582,8 +1576,7 @@ class wsHTML5Compiler {
                return implode(';', $res);
        }
 
-       protected
-       function base62($val) {
+       protected function base62($val) {
                $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
                $base = strlen($chars);
                $str = '';
@@ -1595,13 +1588,11 @@ class wsHTML5Compiler {
                return $str;
        }
 
-       public
-       function copyLinkDir($source, $dest) {
+       public function copyLinkDir($source, $dest) {
                `cp -a $source $this->vdir/$dest`;
        }
 
-       public
-       function simpleCopyLinkFile($source, $dest, $addVdir = true) {
+       public function simpleCopyLinkFile($source, $dest, $addVdir = true) {
                if ($addVdir) {
                        $dest = $this->vdir . '/' . $dest;
                }
@@ -1615,8 +1606,7 @@ class wsHTML5Compiler {
                $this->copy($source, $dest);
        }
 
-       public
-       function copyLinkFile($source, $dest, $video = false) {
+       public function copyLinkFile($source, $dest, $video = false) {
                if ($video && $this->book->parametres->mobileVideosPath != '') {
 
                }
@@ -1647,8 +1637,7 @@ class wsHTML5Compiler {
                }
        }
 
-       public
-       function __destruct() {
+       public function __destruct() {
 
        }
 
index b4a31233f6230fab71728d3bbfc3f365693390f5..88d000e4825b1e5383642895506e96f0f8a57baa 100644 (file)
@@ -527,6 +527,10 @@ class videoLink extends wsHTML5Link {
                $w = round($this->width * $this->getCssScale());
                $h = round($this->height * $this->getCssScale());
 
+               // Note: width and height for the video is normally measured from the
+        // preview frame for local files or set to 1280 x 720 for web videos.
+        // The $w and $h variables here seem to be null generally...
+
                return $this->makeVideoTag($this, $w, $h, $this->compiler);
        }
 
@@ -561,8 +565,9 @@ class videoLink extends wsHTML5Link {
                if (!is_null($w) && !is_null($h)) {
                        $attr['width'] = $w;
                        $attr['height'] = $h;
-               } else if (!is_null($compiler)) {
 
+               } else if (!is_null($compiler)) {
+            // Get video dimensions from thumbnail if possible (locally uploaded files)
                        $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg';
                        $dim = getimagesize($path);
                        $attr['width'] = $dim[0];