<workItem from="1503492135605" duration="9205000" />
<workItem from="1503572393130" duration="1293000" />
<workItem from="1503582869459" duration="2692000" />
- <workItem from="1503667361871" duration="357000" />
+ <workItem from="1503667361871" duration="440000" />
</task>
<task id="LOCAL-00001" summary="wip #1111 @0.5">
<created>1487172253077</created>
<servers />
</component>
<component name="TimeTrackingManager">
- <option name="totallyTimeSpent" value="41503000" />
+ <option name="totallyTimeSpent" value="41586000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
- <editor active="true" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+++ /dev/null
-#!/usr/bin/php
-<?php
-$dir = $argv[1];
-$dr = opendir($dir);
-while ($file = readdir($dr)) {
- $f = $dir . '/' . $file;
- if (preg_match('|tp([0-9]*)\.svg|i', $file, $matches)) {
- $d = $dir . '/to' . $matches[1] . '.svg';
- } else if (preg_match('|fp([0-9]*)\.svg|i', $file, $matches)) {
- $d = $dir . '/fo' . $matches[1] . '.svg';
- } else {
- continue;
- }
-
- $cmd = "/usr/local/bin/svgcleaner --paths-coordinates-precision 3 --copy-on-error true $f $d";
-
- echo $cmd . "\n";
- echo `$cmd` . "\n";
-}
for ($i = 1; $i <= $this->generalInfos['pages']; $i++) {
$this->processOnePage($i);
}
- $this->optimizeSVG();
- }
-
- public function optimizeSVG() {
- $scour = new cubeCommandLine('scour.php');
- $scour->setPath(CONVERTER_PATH);
- $scour->setNohup(true);
- $scour->setArg(null, $this->html);
- $scour->execute();
}
public function processRange($pages) {
foreach ($pages as $i) {
$this->processOnePage($i);
}
- //$this->optimizeSVG();
}
public function getLinksAndTexts() {
$pdftocairo->setArg(null, $svgFile);
$pdftocairo->execute();
$this->addToLog($pdftocairo, true, $page);
- copy($svgFile, $this->out . '/html/tp' . $page . '.svg');
- $this->_cleanSVG($svgFile, $page);
}
- public static function cleanSVG($svgFile, $debug = false) {
+ public static function extractTexts($svgFile, $textFile, $force = false) {
+ $do = $force || !file_exists($textFile) || filemtime($svgFile) > filemtime($textFile) || filemtime($textFile) < filemtime(__FILE__);
+ if (!$do) {
+ return;
+ }
+
$svg = new DOMDocument();
$svg->preserveWhiteSpace = false;
$svg->load($svgFile, LIBXML_PARSEHUGE);
'//svg:use[starts-with(@xlink:href, "#image")]'
);
- global $svglog;
- $svglog = array('XPATH : ' . print_r($xpath, true));
+ //global $svglog;
+ //$svglog = array('XPATH : ' . print_r($xpath, true));
foreach ($toDelete as $q) {
$list = $xpath->query($q);
- $svglog[] = "Evaluate xpath query " . $q;
- $svglog[] = 'Give ' . $list->length . ' results';
- $svglog[] = 'Deleting Nodes in ' . print_r($list, true);
+ // $svglog[] = "Evaluate xpath query " . $q;
+ // $svglog[] = 'Give ' . $list->length . ' results';
+ // $svglog[] = 'Deleting Nodes in ' . print_r($list, true);
if (count($list)) {
foreach ($list as $node) {
-
/* @var $node DOMNode */
$parent = $node->parentNode;
$parent->removeChild($node);
}
}
}
- file_put_contents($svgFile, $svg->saveXML());
- return $svglog;
+ file_put_contents($textFile, $svg->saveXML());
+ //return $svglog;
}
protected function _cleanSVG($svgFile, $page) {
// SVG
- $time=max(filemtime(__FILE__),filemtime($svgRef));
+ $time = max(filemtime(__FILE__), filemtime($svgRef));
if (!file_exists($svgColorized) || filemtime($svgColorized) <= $time) {
$svg = file_get_contents($svgRef);
// Colorize it
// PNG
$png = $dirColorized . '/' . $icon . '.png';
- $time=max(filemtime(__FILE__),filemtime($svgColorized));
+ $time = max(filemtime(__FILE__), filemtime($svgColorized));
if (!file_exists($png) || filemtime($png) <= $time) {
$svg = simplexml_load_file($svgColorized);
$w = (string)$svg['width'];
}
}
+ public static function optimizeSVG($original, $optimized, $force = false) {
+ if (!file_exists($original)) {
+ return;
+ }
+
+ $optimize = $force ||
+ !file_exists($optimized) ||
+ filemtime($optimized) < filemtime('/usr/local/bin/svgcleaner') ||
+ filemtime($optimized) < filemtime($original);
+
+ if ($optimize) {
+ `/usr/local/bin/svgcleaner $original $optimized --paths-coordinates-precision 3 --copy-on-error`;
+ }
+ }
+
public static function copy($source, $dest) {
if (!file_exists($source)) {
return;
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;
}
}
protected function writeImages() {
+ global $core;
foreach ($this->getResolutions() as $r) {
mkdir($this->vdir . '/data/background/' . $r, 0777, true);
}
foreach ($this->pages as $page => $infos) {
$docdir = wsDocument::getDir($infos['document_id']);
if ($this->svg) {
+ $full = $docdir . 'html/fp' . $infos['document_page'] . '.svg';
$orig = $docdir . 'html/tp' . $infos['document_page'] . '.svg';
$opt = $docdir . 'html/to' . $infos['document_page'] . '.svg';
- $svg = $orig;
- if (file_exists($opt) && filesize($opt) > 0) {
- $svg = $opt;
+ 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) {
}
}
- public function makeThumbSprites(array $thumbs) {
+ public
+ function makeThumbSprites(array $thumbs) {
$cols = 10;
$rows = 10;
$perSprite = $cols * $rows;
return $res;
}
- protected function _makeCover($orig) {
+ protected
+ function _makeCover($orig) {
$size = getimagesize($orig);
$w = $size[0];
$h = $size[1];
unlink($tmp);
}
- protected function copy($s, $t) {
+ protected
+ function copy($s, $t) {
if (!file_exists($s)) {
fb($s . ' dont exists');
return false;
return true;
}
- protected function _lessBoolean($val) {
+ protected
+ function _lessBoolean($val) {
return $val ? 'true' : 'false';
}
- protected function writeCSS($file, $links) {
+ protected
+ function writeCSS($file, $links) {
$res = array();
$lessVariables = array();
return count($res);
}
- protected function _writeLess($variables) {
+ protected
+ function _writeLess($variables) {
if ($this->widget) {
$this->lessFiles[] = 'widget';
}
}
}
- protected function _cssBackground() {
+ protected
+ function _cssBackground() {
$body = '#background,#splash{';
$body .= 'background-color:#' . $this->theme->parametres->backgroundColor . ';';
switch ($this->theme->parametres->repeat) {
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;
return implode(';', $res);
}
- protected function base62($val) {
+ protected
+ function base62($val) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$base = strlen($chars);
$str = '';
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;
}
$this->copy($source, $dest);
}
- public function copyLinkFile($source, $dest, $video = false) {
+ public
+ function copyLinkFile($source, $dest, $video = false) {
if ($video && $this->book->parametres->mobileVideosPath != '') {
}
}
}
- public function __destruct() {
+ public
+ function __destruct() {
}