From 0bea5ced3fc3cfe423def89c013b50f052d36830 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 24 Apr 2012 17:54:09 +0000 Subject: [PATCH] --- inc/ws/Metier/class.ws.document.php | 8 +-- inc/ws/Util/html5/class.ws.html5.compiler.php | 72 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index ccc1f6fd3..e64261850 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -315,9 +315,9 @@ class wsDocument extends cubeMetier { } $this->optimizeSVG(); } - - public function optimizeSVG(){ - $scour=new cubeCommandLine('scour.php'); + + public function optimizeSVG() { + $scour = new cubeCommandLine('scour.php'); $scour->setPath(CONVERTER_PATH); $scour->setNohup(true); $scour->setArg(null, $this->html); @@ -546,7 +546,7 @@ class wsDocument extends cubeMetier { public function makeHTML5Files($page) { // Then make HD background shots - $resolutions = array(150 => 75); + $resolutions = array(150 => 75, 36 => 80); foreach ($resolutions as $r => $q) { $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false); $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true); diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 9943e23d5..861f23322 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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[] = ''; - } - $scripts[] = ''; - $script = implode("\n\t\t", $scripts); + $script = ''; $style = ''; $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() { -- 2.39.5