From d4c78ae3f9ca0c4899fc1def7d1f5b9b3cbe9d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Sun, 13 Mar 2016 21:51:58 +0100 Subject: [PATCH] Finalize search feature for merge --- daux.phar | Bin 882506 -> 882919 bytes docs/01_Features/Search.md | 13 + global.json | 1 + gulpfile.js | 1 + libs/Console/Generate.php | 2 +- libs/Format/HTML/Generator.php | 42 +- libs/Server/Server.php | 7 +- templates/home.php | 13 +- templates/layout/00_layout.php | 7 +- templates/layout/05_page.php | 13 +- templates/partials/navbar_content.php | 11 +- themes/daux/css/theme-blue.min.css | 2 +- themes/daux/css/theme-green.min.css | 2 +- themes/daux/css/theme-navy.min.css | 2 +- themes/daux/css/theme-red.min.css | 2 +- themes/daux/css/theme.min.css | 2 +- themes/daux/less/bootstrap/bootstrap.less | 2 +- themes/daux/less/bootstrap/navbar.less | 5 +- themes/daux/less/components.less | 14 + tipuesearch/.gitignore | 1 - tipuesearch/img/search.png | Bin 368 -> 0 bytes tipuesearch/tipuesearch.css | 338 ++++++------- tipuesearch/tipuesearch.js | 565 ---------------------- tipuesearch/tipuesearch_set.js | 33 +- 24 files changed, 258 insertions(+), 820 deletions(-) create mode 100644 docs/01_Features/Search.md delete mode 100644 tipuesearch/.gitignore delete mode 100755 tipuesearch/img/search.png delete mode 100644 tipuesearch/tipuesearch.js diff --git a/daux.phar b/daux.phar index 6df9c6fcce477b571372422b7eba4248ba5dfa10..dbe17e107a8af77d4e0eb0a66977502f9cdde552 100755 GIT binary patch delta 5652 zcma)9d03R?7XJnqwwYlDhMi#(5oVBW5Qcrc+)Yj=Y8>=YRm z9vXw)qNzwnMP3S98OO1+LY|%(K5qin27Y*%WDux`5iWW9+}F-gu-ZU}mq!hvk%|ms zkR}*=2&tt}IMQsRIHbKs8Az`fB_N$5PDI)uo`Ur6VzThK*ayFV z7DpisG7dx9B+#A4WY3s!1fF}CkltA)WXDF6P&_|nLO8K0*_&cog6Bh~1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ntB$TJX15#qq`ovl8}~|o%kP%4cOcO diff --git a/docs/01_Features/Search.md b/docs/01_Features/Search.md new file mode 100644 index 0000000..5fb99e3 --- /dev/null +++ b/docs/01_Features/Search.md @@ -0,0 +1,13 @@ +Searching in a Daux.io documentation is possible, but only in static mode. + +We don't provide this feature in live rendering as it would be too slow. + +To enable the generated search, you can set `search` to true in the `html` section of your configuration + +```json +{ + "html": { + "search": true + } +} +``` diff --git a/global.json b/global.json index 617e56f..22fd103 100644 --- a/global.json +++ b/global.json @@ -30,6 +30,7 @@ "date_modified": false, "float": false, "auto_landing": true, + "search": true, "repo": "", "twitter": [], diff --git a/gulpfile.js b/gulpfile.js index d952b7d..bb72309 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,6 +19,7 @@ var unusedRules = [ //We only use one glyphicon ... ".glyphicon-", "!.glyphicon-chevron-right", + "!.glyphicon-search", //we dont need all buttons ".btn-", diff --git a/libs/Console/Generate.php b/libs/Console/Generate.php index 9ec08e9..7ca1c1c 100755 --- a/libs/Console/Generate.php +++ b/libs/Console/Generate.php @@ -21,7 +21,7 @@ class Generate extends SymfonyCommand ->addOption('source', 's', InputOption::VALUE_REQUIRED, 'Where to take the documentation from') ->addOption('delete', null, InputOption::VALUE_NONE, 'Delete pages not linked to a documentation page (confluence)') ->addOption('destination', 'd', InputOption::VALUE_REQUIRED, $description, 'static') - ->addOption('text_search', '-t', InputOption::VALUE_NONE, 'Generate full text search'); + ->addOption('search', null, InputOption::VALUE_NONE, 'Generate full text search'); } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/libs/Format/HTML/Generator.php b/libs/Format/HTML/Generator.php index fd675b5..292ed89 100755 --- a/libs/Format/HTML/Generator.php +++ b/libs/Format/HTML/Generator.php @@ -10,7 +10,6 @@ use Todaymade\Daux\DauxHelper; use Todaymade\Daux\Format\Base\LiveGenerator; use Todaymade\Daux\GeneratorHelper; use Todaymade\Daux\Tree\ComputedRaw; -use Todaymade\Daux\Tree\Content; use Todaymade\Daux\Tree\Directory; use Todaymade\Daux\Tree\Entry; use Todaymade\Daux\Tree\Raw; @@ -22,6 +21,8 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator /** @var Daux */ protected $daux; + protected $indexed_pages = []; + /** * @param Daux $daux */ @@ -60,17 +61,18 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator $output->writeLn("Generating ..."); - $text_search = ($input->getOption('text_search')); - $params['text_search'] = $text_search; - if ($text_search) { - $index_pages = []; - } - $this->generateRecursive($this->daux->tree, $destination, $params, $output, $width, $index_pages); + $params['html']['search'] = $input->getOption('search'); + $this->generateRecursive($this->daux->tree, $destination, $params, $output, $width, $params['html']['search']); - if ($text_search) { - $tipuesearch_directory = $this->daux->local_base . DIRECTORY_SEPARATOR . 'tipuesearch' . DIRECTORY_SEPARATOR; - file_put_contents($tipuesearch_directory . 'tipuesearch_content.json', json_encode(['pages' => $index_pages])); - GeneratorHelper::copyRecursive ($tipuesearch_directory, $destination . DIRECTORY_SEPARATOR . 'tipuesearch'); + if ($params['html']['search']) { + GeneratorHelper::copyRecursive( + $this->daux->local_base . DIRECTORY_SEPARATOR . 'tipuesearch' . DIRECTORY_SEPARATOR, + $destination . DIRECTORY_SEPARATOR . 'tipuesearch' + ); + file_put_contents( + $destination . DIRECTORY_SEPARATOR . 'tipuesearch' . DIRECTORY_SEPARATOR . 'tipuesearch_content.json', + json_encode(['pages' => $this->indexed_pages]) + ); } } @@ -110,8 +112,9 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", ), - $text ); - return trim (preg_replace('/\s+/', ' ', strip_tags($text))); + $text + ); + return trim(preg_replace('/\s+/', ' ', strip_tags($text))); } /** @@ -122,10 +125,11 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator * @param \Todaymade\Daux\Config $params * @param OutputInterface $output * @param integer $width + * @param boolean $index_pages * @param string $base_url * @throws \Exception */ - private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, &$index_pages, $base_url = '') + private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $index_pages, $base_url = '') { DauxHelper::rebaseConfiguration($params, $base_url); @@ -146,7 +150,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator "- " . $node->getUrl(), $output, $width, - function() use ($node, $output_dir, $key, $params, &$index_pages) { + function() use ($node, $output_dir, $key, $params, $index_pages) { if ($node instanceof Raw) { copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key); return; @@ -154,13 +158,13 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator $generated = $this->generateOne($node, $params); file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent()); - if (isset($index_pages)) { - array_push($index_pages, [ + if ($index_pages) { + $this->indexed_pages[] =[ 'title' => $node->getTitle(), - 'text' => utf8_encode($this->strip_html_tags($generated->getContent())), + 'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())), 'tags' => "", 'url' => $node->getUrl() - ]); + ]; } } ); diff --git a/libs/Server/Server.php b/libs/Server/Server.php index a08fe43..1d305b8 100755 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -99,6 +99,9 @@ class Server $params['base_page'] .= 'index.php/'; } + // Text search would be too slow on live server + $params['html']['search'] = false; + return $params; } @@ -144,9 +147,7 @@ class Server ); } - $params = $this->params; - $params['text_search'] = false; - return $this->daux->getGenerator()->generateOne($file, $params); + return $this->daux->getGenerator()->generateOne($file, $this->params); } public function getRequest() diff --git a/templates/home.php b/templates/home.php index d66ae19..b4dda1d 100755 --- a/templates/home.php +++ b/templates/home.php @@ -45,16 +45,13 @@
- + - - -
- -
+ +
+ +
diff --git a/templates/layout/00_layout.php b/templates/layout/00_layout.php index c1a1f1d..3af9c7e 100755 --- a/templates/layout/00_layout.php +++ b/templates/layout/00_layout.php @@ -23,10 +23,9 @@ echo ""; } ?> - + - - +