]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 24 Apr 2012 17:54:09 +0000 (17:54 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 24 Apr 2012 17:54:09 +0000 (17:54 +0000)
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index ccc1f6fd3e2c85216cdae16f4ffbf13b0aa1ec21..e642618508e6aa0f0b8da251efe48995076a5b8d 100644 (file)
@@ -315,9 +315,9 @@ class wsDocument extends cubeMetier {
                }\r
                $this->optimizeSVG();\r
        }\r
-       \r
-       public function optimizeSVG(){\r
-               $scour=new cubeCommandLine('scour.php');\r
+\r
+       public function optimizeSVG() {\r
+               $scour = new cubeCommandLine('scour.php');\r
                $scour->setPath(CONVERTER_PATH);\r
                $scour->setNohup(true);\r
                $scour->setArg(null, $this->html);\r
@@ -546,7 +546,7 @@ class wsDocument extends cubeMetier {
 \r
        public function makeHTML5Files($page) {\r
                // Then make HD background shots\r
-               $resolutions = array(150 => 75);\r
+               $resolutions = array(150 => 75, 36 => 80);\r
                foreach ($resolutions as $r => $q) {\r
                        $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false);\r
                        $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true);\r
index 9943e23d5b1394f41f4704c928f3ad43e92cbd93..861f23322317fce78dc797ca4e394ed47cd95a3c 100644 (file)
@@ -2,7 +2,7 @@
 
 class wsHTML5Compiler {
 
-       protected static $resolutions = array(150);
+       protected static $resolutions = array(150,36);
        protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
        protected static $jsFiles = array(
                'js/libs/cube/fb.js',
@@ -353,12 +353,7 @@ class wsHTML5Compiler {
 
                // Write widget html
                $whtml = file_get_contents(WS_COMPILE_ASSETS . '/_html5/widget.html');
-               $scripts = array();
-               foreach (self::$widgetJsFiles as $js) {
-                       $scripts[] = '<script type="text/javascript" src="' . $js . '"></script>';
-               }
-               $scripts[] = '<script type="text/javascript" src="data/datas.js"></script>';
-               $script = implode("\n\t\t", $scripts);
+               $script = '<script type="text/javascript" src="data/widget.js"></script>';
 
                $style = '<link type="text/css" rel="stylesheet" href="style/widget.css">';
                $vars = array('titre', 'style', 'script');
@@ -414,42 +409,47 @@ class wsHTML5Compiler {
        }
 
        protected function writeJs() {
-               $mintime = 0;
-               $minimized = WS_COMPILE_ASSETS . '/_html5/js/min.js';
-               if (file_exists($minimized)) {
-                       $mintime = filemtime($minimized);
-               }
-               $reminimize = false;
-               foreach (self::$jsFiles as $file) {
-                       if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) {
-                               $reminimize = true;
-                               break;
+               $config = $this->writeConfig();
+               $finals = array('fluidbook' => self::$jsFiles, 'widget' => self::$widgetJsFiles);
+
+               foreach ($finals as $jsfinal => $files) {
+                       $mintime = 0;
+                       $minimized = WS_COMPILE_ASSETS . '/_html5/js/' . $jsfinal . '-min.js';
+                       if (file_exists($minimized)) {
+                               $mintime = filemtime($minimized);
+                       }
+                       $reminimize = false;
+                       foreach ($files as $file) {
+                               if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) {
+                                       $reminimize = true;
+                                       break;
+                               }
                        }
-               }
 
-               if ($reminimize) {
-                       $js = '';
-                       foreach (self::$jsFiles as $file) {
-                               $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file);
-                               $js.="\n\n";
+                       if ($reminimize) {
+                               $js = '';
+                               foreach ($files as $file) {
+                                       $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file);
+                                       $js.="\n\n";
+                               }
+                               $tmp = cubeFiles::tempnam();
+                               file_put_contents($tmp, $js);
+
+                               $uglify = new cubeCommandLine('uglifyjs');
+                               $uglify->setPath(CONVERTER_PATH);
+                               $uglify->setArg('o', $minimized);
+                               $uglify->setArg('mangle-toplevel');
+                               $uglify->setArg('no-copyright');
+                               $uglify->setArg('unsafe');
+                               $uglify->setArg(null, $tmp);
+                               $uglify->execute();
                        }
-                       $tmp = cubeFiles::tempnam();
-                       file_put_contents($tmp, $js);
 
-                       $compressor = new cubeCommandLine('yuicompressor');
-                       $compressor->setPath(CONVERTER_PATH);
-                       $compressor->setArg('charset', 'UTF-8');
-                       $compressor->setArg('type', 'js');
-                       $compressor->setArg('line-break', 1024);
-                       $compressor->setArg('o', $minimized);
-                       $compressor->setArg(null, $tmp);
-                       $compressor->execute();
+                       $js = $config . file_get_contents($minimized);
+                       file_put_contents($this->vdir . '/data/' . $jsfinal . '.js', $js);
                }
 
-               $config = $this->writeConfig();
-               $js = $config . file_get_contents($minimized);
                file_put_contents($this->vdir . '/data/datas.js', $config);
-               file_put_contents($this->vdir . '/data/fluidbook.js', $js);
        }
 
        protected function writeConfig() {