public $logtime = null;
public $beginBody = array();
public $seoArticles = [];
- public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com'];
+ public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com', '*.googletagmanager.com'];
public $writeLinksData = false;
public $content_lock = [];
protected $_indexVars = null;
public $_signature;
/**
- * @var wsHTML5Seo
+ * @var wsHTML5SeolinksData
*/
public $seo = null;
$this->log('Widget written');
$this->writeSounds();
$this->log('Sound written');
+ $this->writeAccessibility();
+ $this->log('Sound accessibility');
$this->writeTexts();
$this->log('Texts written');
$this->writeExtras();
}
$this->writeJs();
$this->log('Js written');
- $this->vdir->sync($delete);
+ $this->vdir->sync($delete, $this);
$this->log('Files Synced');
}
$this->vdir->copyDirectory(WS_SOUNDS . '/' . $this->book->parametres->soundTheme, 'data/sounds');
}
+ protected function writeAccessibility()
+ {
+ if ($this->book->parametres->audiodescriptionTexts == '' || $this->book->parametres->audiodescriptionVoice == '') {
+ return;
+ }
+ $file = $this->wdir . '/' . $this->book->parametres->audiodescriptionTexts;
+ new PHPExcel();
+ $reader = new PHPExcel_Reader_Excel2007();
+ $phpexcel = $reader->load($file);
+
+ $sheet = $phpexcel->getActiveSheet();
+ $maxRow = $sheet->getHighestRow(0);
+
+ for ($i = 0; $i <= $maxRow; $i++) {
+ $page = trim($sheet->getCellByColumnAndRow(0, $i)->getValue());
+ $text = trim($sheet->getCellByColumnAndRow(1, $i)->getValue());
+ if ($page == '' || $text == '') {
+ continue;
+ }
+
+ $replace = ['`' => "'",
+ '“' => '"',
+ '”' => '"',
+ '’' => "'",
+ '—' => " - ",
+ '‘' => "'",
+ ];
+
+ $text = str_replace(array_keys($replace), array_values($replace), $text);
+
+ $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text);
+ $fname = $hash . '.mp3';
+ $dir = WS_BOOKS . '/audiodescription/';
+ if (!file_exists($dir)) {
+ mkdir($dir, 0777, true);
+ }
+
+ $file = $dir . $fname;
+ if (!file_exists($file)) {
+ $e = explode(':', $this->book->parametres->audiodescriptionVoice);
+
+ $engine = $e[0];
+ $voice = $e[1];
+
+ if ($engine == 'festival') {
+ $tmp = CubeIT_Files::tempnam() . '.wav';
+ $tmptext = CubeIT_Files::tempnam() . '.txt';
+
+ file_put_contents($tmptext, $text);
+ $cmd = "text2wave -o $tmp $tmptext -eval \"($voice)\"";
+ `$cmd`;
+
+ `lame $tmp $file`;
+ unlink($tmp);
+ unlink($tmptext);
+ } else if ($engine == 'readspeaker') {
+ $e = explode('/', $voice);
+ $this->_readSpeaker($text, $e[1], $e[0], $file);
+ }
+ }
+
+ $this->config->audiodescription[$page] = $fname;
+ $this->vdir->copy($file, 'data/audiodescription/' . $fname);
+ }
+ }
+
+ protected function _readSpeaker($text, $language, $voice, $output)
+ {
+ $text_to_read = urlencode($text);
+ // Your API key here
+ $apikey = 'e9c321908f2dd016f6a0c34d2d786aff';
+
+ // File path and file name
+ $filepath = $output;
+
+ // API URL of text-to-speech enabler
+ $api_url = 'https://tts.readspeaker.com/a/speak';
+
+ // Compose API call url
+ $url = $api_url . '?key=' . $apikey . '&streaming=0&lang=' . $language . '&voice=' . $voice . '&text=' . $text_to_read;
+
+ // Initiating curl
+ $ch = curl_init($url);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+
+ $data = curl_exec($ch);
+
+ $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+ if ($status == 200 && !curl_errno($ch)) {
+ // Everything is fine, close curl and save file
+ curl_close($ch);
+ file_put_contents($filepath, $data);
+ } else {
+ // Cannot translate text to speech because of text-to-speech API error
+ error_log(__FILE__ . ': API error while text-to-speech. error code=' . $status);
+ curl_close($ch);
+ }
+
+ }
+
protected function _writeIndex($page)
{
$seo = $this->seo->pages[$page];
$html = $seo->getHTML();
- $iv = $this->getIndexVars();
-
- foreach ($iv as $k => $v) {
- $html = str_replace($k, $v, $html);
- }
-
if ($this->book->parametres->seoVersion) {
$seo->writePage($html, $this->vdir);
}
if ($page == 1) {
$seo->writePage($html, $this->vdir, 'index.html');
}
+
+ if ($page % 10 == 0) {
+ $this->log('Written page ' . $page);
+ }
}
public function getIndexVars()
protected function writeIndex()
{
+ $iv = $this->getIndexVars();
+ foreach ($iv as $k => $v) {
+ $this->seo->html = str_replace($k, $v, $this->seo->html);
+ }
if ($this->book->parametres->seoVersion) {
foreach ($this->pages as $page => $infos) {
$this->_writeIndex($page);
copy($tmp, $minimized);
}
- if (!file_exists($minimized)) {
+ if (!file_exists($minimized) || filesize($minimized) == 0) {
die('An error occured while uglifying : ' . $uglify->output);
}
}
$couleurM = $this->theme->parametres->subTextColor;
+ $bookmarksDisabledColors = array('star' => $this->theme->parametres->bookmarkStarDisabledColor, 'bookmark' => $this->theme->parametres->bookmarkBackgroundColor);
+ $bookmarksEnabledColors = array('star' => $this->theme->parametres->bookmarkStarEnabledColor, 'bookmark' => $this->theme->parametres->bookmarkBackgroundColor);
$subTextColor = $this->theme->parametres->subTextColor;
$arrowsColor = $this->theme->parametres->arrowsColor;
$this->_makeCover($docdir . 'html/t36-' . $infos['document_page'] . '.jpg');
}
+ if ($page % 10 == 0) {
$this->log('Copied image ' . $page);
}
+ }
$this->makeThumbSprites($thumbs);
'modernizr' =>
['js/libs/modernizr/modernizr.min.js',
'js/libs/modernizr/tests.js',],
+ 'modifier' => ['js/libs/threejs/modifier.min.js'],
'threejs' =>
- ['js/libs/threejs/three.min.js',
- 'js/libs/threejs/Projector.js',
- 'js/libs/threejs/CanvasRenderer.js',
- 'js/libs/threejs/modifier.js',
- 'js/libs/threejs/stats.js',],
+ ['js/libs/threejs/legacy/three.min.js',
+ 'js/libs/threejs/legacy/Projector.js',
+ 'js/libs/threejs/legacy/CanvasRenderer.js',
+ ],
+// 'threejs-latest' =>
+// ['js/libs/threejs/latest/three.min.js',
+// ],
'jquery' =>
['js/libs/jquery/jquery.min.js',
'js/libs/jquery/jquery.transform.js',
'js/libs/jquery/jquery.form.min.js',
'js/libs/jquery/jquery.mousewheel.min.js',
'js/libs/jquery/jquery.hashchange.min.js',],
- 'screenfull' => ['js/libs/screenfull.min.js',],
+ 'screenfull' => ['js/libs/screenfull.min.js'],
'storage' => ['js/libs/storage.js',],
'keymaster' => ['js/libs/keymaster.js',],
- 'perfectscrollbar' => ['js/libs/jquery/perfect-scrollbar.jquery.min.js',],
+ 'perfectscrollbar' => ['js/libs/perfect-scrollbar/perfect-scrollbar.min.js',
+ 'js/libs/perfect-scrollbar/perfect-scrollbar.jquery.js'],
'mmenu' =>
- ['js/libs/mmenu/jquery.mmenu.min.js',
- 'js/libs/mmenu/jquery.mmenu.rtl.min.js',
- 'js/libs/mmenu/jquery.mmenu.offcanvas.min.js',],
+ ['js/libs/mmenu/jquery.mmenu.all.js'],
'tweenmax' =>
['js/libs/gsap/TweenMax.min.js',
'js/libs/gsap/jquery.gsap.min.js',
$this->config->manifest = $this->writeManifest();
}
+ $this->writeGPUDatabase();
+
if ($this->config->form == 'bulle') {
$this->addJsLib('bulle', 'js/libs/fluidbook/forms/fluidbook.form.bulle.js');
} else if ($this->config->form == 'bourbon') {
$this->config->seoArticles = $this->seoArticles;
}
+ public function writeGPUDatabase()
+ {
+ global $core;
+ $r = $core->con->select('SELECT gpu,score FROM gpu');
+ $gpu = [];
+ while ($r->fetch()) {
+ $gpu[$r->gpu] = $r->score;
+ }
+ $this->config->gupsc = $gpu;
+ $this->config->gupse = wsServices::gpuSeparators();
+ }
+
public function log($step)
{
$currenttime = microtime(true);
if ($this->theme->parametres->iosicon != '') {
$hasIos = true;
$this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->iosicon, 'data/apple-touch-icon.png');
- $favicon .= '<link rel="apple-touch-icon" href="data/apple-touch-icon.png" />';
+ $favicon .= '<link rel="apple-touch-icon" href="data/apple-touch-icon.png" />' . "\n\t";
}
if ($this->theme->parametres->favicon != '') {
$pngFile = $this->themeRoot . '/' . $this->theme->parametres->favicon;
- $icoFile = $this->themeRoot . '/favicon.ico';
- if (!file_exists($icoFile) || filemtime($icoFile) < filemtime($pngFile) || filemtime(__FILE__) > filemtime($icoFile)) {
- $tmp = CubeIT_Files::tempnam() . '.png';
- $convert = "convert $pngFile -resize 64x64^ -gravity center $tmp";
- `$convert`;
-
- $icotool = new cubeCommandLine('icotool');
- $icotool->setArg('c');
- $icotool->setArg('o', $icoFile);
- $icotool->setArg(null, $tmp);
- $icotool->execute();
- unlink($tmp);
- }
$this->vdir->copy($pngFile, 'data/favicon.png');
- $this->vdir->copy($icoFile, 'data/favicon.ico');
- $favicon .= '<link rel="shortcut icon" href="data/favicon.ico" />';
- $favicon .= '<link rel="icon" type="image/vnd.microsoft.icon" href="data/favicon.ico" />';
- $favicon .= '<link rel="icon" type="image/png" href="data/favicon.png" />';
+ $datapng = 'data:image/png;base64,' . base64_encode(file_get_contents($pngFile));
+
+ $favicon .= '<link rel="icon" type="image/png" href="' . $datapng . '" />' . "\n\t";
if (!$hasIos) {
$favicon .= '<link rel="apple-touch-icon" href="data/favicon.png" />';
}
$svg = '';
foreach ($svgfiles as $svgfile) {
if (file_exists($svgfile)) {
- $svg .= file_get_contents($svgfile);
+ $svg .= str_replace('$bookmark-color', wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor), file_get_contents($svgfile));
} else {
die($svgfile . ' does not exist');
}
// Set the icon list with the color
$icons = array('interface-down' => $arrowsColor, 'interface-close' => $arrowsColor,
'interface-audio-description-on' => $arrowsColor, 'interface-audio-description-off' => $arrowsColor,
- 'help-fingers' => $couleurI, 'help-mouse' => $couleurI,
- 'bookmark-left-off' => $bookmarksDisabledColors, 'bookmark-left-on' => $bookmarksEnabledColors,
- 'bookmark-right-off' => $bookmarksDisabledColors, 'bookmark-right-on' => $bookmarksEnabledColors
+ 'help-fingers' => $couleurI, 'help-mouse' => $couleurI
);
$this->config->iconsDimensions = array();
$lessVariables['z'] = $this->z;
$lessVariables['book-page-width'] = $w;
+ if ($this->book->parametres->correctCenter) {
+ $lessVariables['book-page-correct-width'] = ceil($w + 1);
+ $lessVariables['book-page-correct-height'] = ceil($h + 1);
+ } else {
+ $lessVariables['book-page-correct-width'] = $w;
+ $lessVariables['book-page-correct-height'] = $h;
+ }
$lessVariables['book-page-height'] = $h;
$lessVariables['book-page-ratio'] = floatval($w) / floatval($h);
$left = $w;
- $centerOffset = 0;
- if ($this->book->parametres->correctCenter) {
- $centerOffset = 3;
- $left = ($cssWidth - $centerOffset) . 'px';
- $res[] = '.doublePage._3d .page.left{left:-' . ($centerOffset + 1) . 'px !important;}';
- }
- $lessVariables['correct-center'] = ($centerOffset * -1);
$res[] = '.doublePage._3d{left:' . $left . ';}';
$res[] = '#links.right{left:-' . $left . ';}';
$lessVariables['display-page-number'] = $this->_lessBoolean($this->theme->parametres->displayPageNumber);
$lessVariables['page-transition-duration'] = $this->book->parametres->mobileTransitionDuration . 's';
-
- $res[] = '.background{width:100%;height:100%}';
-
if ($this->cssSVGScale != 1) {
$texts = '.texts{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';';
$texts .= wsHTML5::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
if (!isset($this->book->parametres->bookmarkCornerSize)) {
$this->book->parametres->bookmarkCornerSize = 10;
}
+
+ $lessVariables['bookmark-star-disabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarDisabledColor);
+ $lessVariables['bookmark-star-enabled-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkStarEnabledColor);
+ $lessVariables['bookmark-color'] = wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor);
$lessVariables['bookmark-corner-size'] = round($this->width * $this->book->parametres->bookmarkCornerSize * 0.0075 * $this->z) . 'px';
$lessVariables['bookmark-corner-offset'] = $this->book->parametres->bookmarkOffset . 'px';