]> _ Git - cubeextranet.git/commitdiff
Merging compiler changes. WIP #1449 @1
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 9 Jun 2017 09:30:11 +0000 (09:30 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 9 Jun 2017 09:30:11 +0000 (09:30 +0000)
inc/ws/Util/html5/html5video/class.ws.html5.compiler.php
inc/ws/Util/html5/html5video/class.ws.html5.links.php

index a7ac6e21572a8c9a7027bee520e22f0576c30aa5..177f78ccfd2594ad9ce18acb9e8c905db1cb747e 100644 (file)
@@ -11,7 +11,6 @@ class wsHTML5Compiler {
                'js/libs/fix/detect-zoom.js',
                'js/libs/cube/fb.js',
                'js/libs/cube/util.js',
-               'js/libs/fastclick/fastclick.js',
                'js/libs/json.js',
                'js/libs/flashdetect.js',
                'js/libs/screenfull.js',
@@ -276,6 +275,7 @@ class wsHTML5Compiler {
        }
 
        public function compile() {
+
                $dirsToCreate = array('data/images', 'data/contents', 'data/background', 'data/thumbnails', 'data/style');
                if (in_array('flv', $this->getVideosFormats())) {
                        $dirsToCreate[] = 'swf';
@@ -462,7 +462,7 @@ class wsHTML5Compiler {
         $this->lessFilesExtras = array_unique(array_merge($this->lessFilesExtras, $extra_files));
        }
 
-    protected function writeIndex($numCSS) {
+       protected function writeIndex() {
                global $core;
 
                $html = file_get_contents($this->assets . '/_index.html');
@@ -866,15 +866,19 @@ class wsHTML5Compiler {
 
                foreach ($finals as $jsfinal => $files) {
                        $mintime = 0;
-                       $minimized = $this->assets . '/js/' . $jsfinal . '-min.js';
+                       $hash = hash('sha256', json_encode($files));
+                       $minimized = $this->assets . '/js/min/' . $jsfinal . '-' . $hash . '-min.js';
+                       if (!file_exists(dirname($minimized))) {
+                               mkdir(dirname($minimized));
+                       }
                        if (file_exists($minimized)) {
                                $mintime = filemtime($minimized);
-                       }
-
-                       $reminimize = false;
-                       if ($jsfinal == 'special') {
+                           $reminimize = false;
+                       } else {
+                               $mintime = 0;
                                $reminimize = true;
                        }
+
                        if (!$reminimize) {
                                foreach ($files as $file) {
                                        if (filemtime($this->assets . '/' . $file) > $mintime) {
@@ -891,7 +895,7 @@ class wsHTML5Compiler {
                        }
 
                        if ($reminimize) {
-                               $js = '';
+                               $js = 'var files=' . json_encode($files) . ';';
                                foreach ($files as $file) {
                                        $js .= file_get_contents($this->assets . '/' . $file);
                                        $js .= ";\n\n";
@@ -905,7 +909,9 @@ class wsHTML5Compiler {
                                $uglify->setArg('no-copyright');
                                $uglify->setArg(null, $tmp);
                                $uglify->execute();
-                               //$uglify->debug();
+                               $uglify->debug();
+
+
                        }
                        $dest = $this->vdir . '/data/' . $jsfinal . '.js';
                        copy($minimized, $dest);
@@ -1203,6 +1209,7 @@ class wsHTML5Compiler {
                $res[] = $shade;
 
                // SVG
+
                $res[] = 'svg .fill-c-menu-back{fill:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}';
                $res[] = 'svg .fill-c-menu-text{fill:' . wsHTML5::colorToCSS($this->theme->parametres->subTextColor) . ';}';
 
@@ -1282,8 +1289,6 @@ class wsHTML5Compiler {
                $res[] = '.portrait #fluidbook .bookmark.left{left:' . ($cssWidth - $size) . 'px;}';
 
                // Menus
-
-
                $menuColor = new CubeIT_Graphics_Color($this->theme->parametres->couleurB);
                $menuColor->setAlpha(1);
                $menuTextColor = wsHTML5::colorToCSS($this->theme->parametres->subTextColor);
@@ -1323,7 +1328,6 @@ class wsHTML5Compiler {
                        $this->stylesheets[] = 'data/style/style_' . $k . '.css';
                        file_put_contents(sprintf($file, $k), implode("\n", $css));
                }
-
                return count($res);
        }
 
@@ -1338,6 +1342,7 @@ class wsHTML5Compiler {
                $tmp = CubeIT_Files::tmpdir();
 
                copy($this->assets . '/style/variables.less', $tmp . '/variables.less');
+               copy($this->assets . '/style/mixins.less', $tmp . '/mixins.less');
 
                $bookVariables = array();
                foreach ($variables as $k => $v) {
@@ -1349,7 +1354,9 @@ class wsHTML5Compiler {
         // (eg. video-js-core.css is needed by videojs.less)
         foreach ($this->lessFilesExtras as $extra) {
             $destination_extra = $tmp . '/' . $extra;
-            if (!is_dir(dirname($destination_extra))) mkdir(dirname($destination_extra));
+                       if (!is_dir(dirname($destination_extra))) {
+                               mkdir(dirname($destination_extra), 0777, true);
+                       }
             copy($this->assets . '/style/' . $extra, $destination_extra);
         }
 
@@ -1359,12 +1366,18 @@ class wsHTML5Compiler {
             $destination_less = $tmp . '/' . $f . '.less';
             $destination_css = 'style/' . $f . '.css';
 
-            if (!file_exists($source_less)) continue;
+                       if (!file_exists($source_less)) {
+                               continue;
+                       }
 
             // LESS file might be in a subfolder, so create if it doesn't exist
-            if (!is_dir(dirname($destination_less))) mkdir(dirname($destination_less));
+                       if (!is_dir(dirname($destination_less))) {
+                               mkdir(dirname($destination_less), 0777, true);
+                       }
             // Generated CSS file might be in a subfolder, so create if it doesn't exist
-            if (!is_dir(dirname($this->vdir . '/' . $f . '.css'))) mkdir(dirname($this->vdir . '/' . $f . '.css'));
+                       if (!is_dir(dirname($this->vdir . '/' . $f . '.css'))) {
+                               mkdir(dirname($this->vdir . '/' . $f . '.css'), 0777, true);
+                       }
 
                        // Less files must be copied to temporary directory so they'll
             // have access to the variables generated in book-variables.less
index ac8fdfb2eb103fdada3938990e982f54f8729a30..84b80fced5f7943cd4d7b4ce96e9bf712ba1286e 100644 (file)
@@ -506,7 +506,6 @@ class internalLink extends normalLink {
 }
 
 class videoLink extends wsHTML5Link {
-
     public static function addVideoJS($compiler) {
         $compiler->addJs('js/libs/videojs/video.js');
         $compiler->addLess('videojs/videojs', ['videojs/video-js-core.css']);
@@ -518,7 +517,6 @@ class videoLink extends wsHTML5Link {
 
        public function getHTMLContent() {
 
-               static::addVideoJS($this->compiler);
 
                $this->copyExternalFile($this->to, true);
 
@@ -529,6 +527,7 @@ class videoLink extends wsHTML5Link {
        }
 
        public static function makeVideoTag($linkDatas, $w = null, $h = null, $compiler = null) {
+               static::addVideoJS($compiler);
 
                $attributes = static::getVideoAttributes($linkDatas, $w, $h, $compiler);
 
@@ -559,6 +558,7 @@ class videoLink extends wsHTML5Link {
                        $attr['width'] = $w;
                        $attr['height'] = $h;
                } else if (!is_null($compiler)) {
+
                        $path = WS_BOOKS . '/working/' . $compiler->book_id . '/' . $basename . '.jpg';
                        $dim = getimagesize($path);
                        $attr['width'] = $dim[0];
@@ -597,7 +597,6 @@ class videoPopupLink extends normalLink {
 
 }
 
-
 class audioPopupLink extends normalLink {
 
        public function getURL() {