diff --git a/daux.phar b/daux.phar
index 7af873c..6df9c6f 100755
Binary files a/daux.phar and b/daux.phar differ
diff --git a/libs/Console/Generate.php b/libs/Console/Generate.php
old mode 100644
new mode 100755
index 4e058c0..9ec08e9
--- a/libs/Console/Generate.php
+++ b/libs/Console/Generate.php
@@ -20,7 +20,8 @@ class Generate extends SymfonyCommand
->addOption('processor', 'p', InputOption::VALUE_REQUIRED, 'Manipulations on the tree')
->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('destination', 'd', InputOption::VALUE_REQUIRED, $description, 'static')
+ ->addOption('text_search', '-t', 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
old mode 100644
new mode 100755
index d67860f..fd675b5
--- a/libs/Format/HTML/Generator.php
+++ b/libs/Format/HTML/Generator.php
@@ -59,7 +59,59 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
);
$output->writeLn("Generating ...");
- $this->generateRecursive($this->daux->tree, $destination, $params, $output, $width);
+
+ $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);
+
+ 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');
+ }
+
+ }
+
+ /**
+ * Remove HTML tags, including invisible text such as style and
+ * script code, and embedded objects. Add line breaks around
+ * block-level tags to prevent word joining after tag removal.
+ * Also collapse whitespace to single space and trim result.
+ * modified from: http://nadeausoftware.com/articles/2007/09/php_tip_how_strip_html_tags_web_page
+ */
+ private function strip_html_tags($text)
+ {
+ $text = preg_replace(
+ array(
+ // Remove invisible content
+ '@
]*?>.*?@siu',
+ '@@siu',
+ '@@siu',
+ '@@siu',
+ '@@siu',
+ '@@siu',
+ '@]*?.*?@siu',
+ '@@siu',
+ '@]*?.*?@siu',
+ // Add line breaks before and after blocks
+ '@?((address)|(blockquote)|(center)|(del))@iu',
+ '@?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
+ '@?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
+ '@?((table)|(th)|(td)|(caption))@iu',
+ '@?((form)|(button)|(fieldset)|(legend)|(input))@iu',
+ '@?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
+ '@?((frameset)|(frame)|(iframe))@iu',
+ ),
+ array(
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ "\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)));
}
/**
@@ -73,7 +125,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
* @param string $base_url
* @throws \Exception
*/
- private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $base_url = '')
+ private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, &$index_pages, $base_url = '')
{
DauxHelper::rebaseConfiguration($params, $base_url);
@@ -85,7 +137,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
if ($node instanceof Directory) {
$new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
mkdir($new_output_dir);
- $this->generateRecursive($node, $new_output_dir, $params, $output, $width, '../' . $base_url);
+ $this->generateRecursive($node, $new_output_dir, $params, $output, $width, $index_pages, '../' . $base_url);
// Rebase configuration again as $params is a shared object
DauxHelper::rebaseConfiguration($params, $base_url);
@@ -94,7 +146,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
"- " . $node->getUrl(),
$output,
$width,
- function() use ($node, $output_dir, $key, $params) {
+ function() use ($node, $output_dir, $key, $params, &$index_pages) {
if ($node instanceof Raw) {
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
return;
@@ -102,6 +154,14 @@ 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, [
+ 'title' => $node->getTitle(),
+ 'text' => utf8_encode($this->strip_html_tags($generated->getContent())),
+ 'tags' => "",
+ 'url' => $node->getUrl()
+ ]);
+ }
}
);
}
diff --git a/libs/GeneratorHelper.php b/libs/GeneratorHelper.php
old mode 100644
new mode 100755
index 9e81e95..a5b99eb
--- a/libs/GeneratorHelper.php
+++ b/libs/GeneratorHelper.php
@@ -50,7 +50,7 @@ class GeneratorHelper
* @param string $source
* @param string $destination
*/
- protected static function copyRecursive($source, $destination)
+ public static function copyRecursive($source, $destination)
{
if (!is_dir($destination)) {
mkdir($destination);
diff --git a/libs/Server/Server.php b/libs/Server/Server.php
old mode 100644
new mode 100755
index 3440178..a08fe43
--- a/libs/Server/Server.php
+++ b/libs/Server/Server.php
@@ -144,7 +144,9 @@ class Server
);
}
- return $this->daux->getGenerator()->generateOne($file, $this->params);
+ $params = $this->params;
+ $params['text_search'] = false;
+ return $this->daux->getGenerator()->generateOne($file, $params);
}
public function getRequest()
diff --git a/templates/home.php b/templates/home.php
old mode 100644
new mode 100755
index b9dc80d..6bd4334
--- a/templates/home.php
+++ b/templates/home.php
@@ -45,7 +45,10 @@
- = $page['content']; ?>
+
+
+ = $page['content']; ?>
+
diff --git a/templates/layout/00_layout.php b/templates/layout/00_layout.php
old mode 100644
new mode 100755
index 2f5a4b6..c1a1f1d
--- a/templates/layout/00_layout.php
+++ b/templates/layout/00_layout.php
@@ -23,6 +23,12 @@
echo "";
} ?>
+
+
+
+
+
+
@@ -53,5 +59,23 @@
} ?>
+
+
+
+
+
+
+
+
+