From: Vincent Vanwaelscappel Date: Mon, 18 Sep 2023 15:01:34 +0000 (+0200) Subject: wait #6188 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=79cd06a086557dc71991def37ee4f20815b8b692;p=fluidbook-toolbox.git wait #6188 @0.75 --- diff --git a/app/Fluidbook/Compiler/Search.php b/app/Fluidbook/Compiler/Search.php index 87840035e..996613754 100644 --- a/app/Fluidbook/Compiler/Search.php +++ b/app/Fluidbook/Compiler/Search.php @@ -18,20 +18,32 @@ trait Search FWSTK::lastUpdate() . '$$$' . $this->fluidbookSettings->search_mode . '=+=' ); + + $doIndex = $this->fluidbookSettings->search_mode !== 'robust'; + $cacheDir = Files::mkdir(protected_path('fluidbookpublication/index/' . $this->book_id . '/' . $cache . '/')); - $indexFile = $cacheDir . '/search.index.js'; + if ($doIndex) { + $indexFile = $cacheDir . '/search.index.js'; + } $textFile = $cacheDir . '/search.texts.js'; $hightlightsFile = $cacheDir . '/search.highlight.js'; - if (!file_exists($indexFile) || !file_exists($textFile)) { - SearchIndex::makeTextsIndexes($this, $cacheDir, $index, $texts, true); - file_put_contents($indexFile, 'var INDEX=' . $index . ';' . "\r"); + if (($doIndex && !file_exists($indexFile)) || !file_exists($textFile)) { + if ($doIndex) { + SearchIndex::makeTextsIndexes($this, $cacheDir, $index, $texts, true); + file_put_contents($indexFile, 'var INDEX=' . $index . ';' . "\r"); + } else { + SearchIndex::makeTexts($this, $cacheDir, $texts, true); + } file_put_contents($textFile, 'var TEXTS=' . $texts . ";\r"); } + if ($this->fluidbookSettings->highlightResults && !file_exists($hightlightsFile)) { file_put_contents($hightlightsFile, 'var HIGHLIGHTS=' . json_encode(SearchIndex::makeHighlightIndex($this)) . ";\r"); } - $this->vdir->copy($cacheDir . '/search.index.js', 'data/search.index.js'); + if ($doIndex) { + $this->vdir->copy($cacheDir . '/search.index.js', 'data/search.index.js'); + } if ($this->fluidbookSettings->highlightResults) { $this->vdir->copy($cacheDir . '/search.highlight.js', 'data/search.highlight.js'); } diff --git a/app/Fluidbook/Compiler/Secure.php b/app/Fluidbook/Compiler/Secure.php index e21c25f3e..84c079da6 100644 --- a/app/Fluidbook/Compiler/Secure.php +++ b/app/Fluidbook/Compiler/Secure.php @@ -58,6 +58,11 @@ trait Secure } else { $secure = file_get_contents($this->assets . '/_secure.html'); } + + if (!stristr($secure, 'data/noaccents.js')) { + $secure = str_replace('', '', $secure); + } + if ($this->fluidbookSettings->secureClientSideBackgroundImage) { $this->vdir->copy($this->wdir . '/' . $this->fluidbookSettings->secureClientSideBackgroundImage, 'data/secure/' . $this->fluidbookSettings->secureClientSideBackgroundImage); $variables['BACKGROUND_IMAGE'] = 'data/secure/' . $this->fluidbookSettings->secureClientSideBackgroundImage; diff --git a/app/Fluidbook/SearchIndex.php b/app/Fluidbook/SearchIndex.php index 42a7b8319..d5c3e67f9 100644 --- a/app/Fluidbook/SearchIndex.php +++ b/app/Fluidbook/SearchIndex.php @@ -21,25 +21,17 @@ class SearchIndex */ public static function makeTextsIndexes($compiler, $dir, &$index, &$textes, bool $simple = false, bool $force = false) { + self::makeTexts($compiler, $dir, $textes, $force); + if ($simple) { $ifilec = $dir . '/sindex.json'; } else { $ifilec = $dir . '/index.json'; } - $tfilec = $dir . '/textes.json'; + $index = []; - $index = array(); - $textes = array(); foreach ($compiler->pages as $page => $infos) { - $tfile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_PLAIN); $ifile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_INDEX);; - - - $text = PHP::retryOnError(function () use ($tfile) { - Gzip::compressIfNotCompressed($tfile); - return Gzip::file_get_contents($tfile); - }, 3, 0.5); - $ipage = PHP::retryOnError(function () use ($ifile) { Gzip::compressIfNotCompressed($ifile); return Gzip::file_get_contents($ifile); @@ -50,15 +42,28 @@ class SearchIndex } else { self::fillIndexWithWords($index, $page, $ipage); } - $textes[$page] = $text; + } ksort($index); - $textes = json_encode($textes); $index = json_encode($index); + Gzip::file_put_contents($ifilec, $index); + } + public static function makeTexts($compiler, $dir, &$textes, bool $force = false) + { + $tfilec = $dir . '/textes.json'; + $textes = []; + foreach ($compiler->pages as $page => $infos) { + $tfile = $compiler->getFluidbook()->getTextFile($page, FluidbookDocument::TEXT_PLAIN); + $text = PHP::retryOnError(function () use ($tfile) { + Gzip::compressIfNotCompressed($tfile); + return Gzip::file_get_contents($tfile); + }, 3, 0.5); + $textes[$page] = $text; + } + $textes = json_encode($textes); Gzip::file_put_contents($tfilec, $textes); - Gzip::file_put_contents($ifilec, $index); } /**