From da5b3a5df8284d79850bc79afae73c35bc578bf6 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sat, 24 Aug 2019 19:56:14 +0100
Subject: [PATCH] Do some documentation work, and add missing help sections

---
 Changelog.md               |  6 ++++--
 docs/04-Getting-Started.md |  1 +
 module_index.json          |  8 ++++----
 modules/feature-search.php | 12 ++++++++++++
 modules/feature-stats.php  |  5 +++--
 5 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 7ef9e5f..0411230 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -6,11 +6,13 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
 
 ### Fixed
  - Fixed a bug in the search query performance metrics
+ - Fill out the statistics help text
 
 ### Changed
  - Made `build.sh` build script more robust, especially when generating the documentation.
- - Improved search index update performance - especially when rebuilding the entire index through the master control panel
-     - The search index is no longer sorted, but this shouldn't affect lookup performance at all
+ - Vastly improved search engine performance
+     - A new SQLite-based index format is now used, so search indexes will need to be rebuilt (migrating would probably take longer than a rebuild :-/)
+ - New search query syntax
 
 
 ## v0.19
diff --git a/docs/04-Getting-Started.md b/docs/04-Getting-Started.md
index 4a805c6..8c5b09b 100644
--- a/docs/04-Getting-Started.md
+++ b/docs/04-Getting-Started.md
@@ -9,6 +9,7 @@
     - `fileinfo` (for proper mime type checking of uploaded files)
     - `zip` (for compressing exports)
     - `intl` (for Unicode text normalization when searching and in the id index)
+    - `sqlite` (for search index storage; uses [PDO](https://www.php.net/manual/en/ref.pdo-sqlite.php))
 - Write access to Pepperminty Wiki's own folder (only for editing)
 - Recommended: Block access to `peppermint.json`, where it stores it's settings
 
diff --git a/module_index.json b/module_index.json
index 7da4a55..f2d4bc6 100755
--- a/module_index.json
+++ b/module_index.json
@@ -135,17 +135,17 @@
         "version": "0.10",
         "author": "Starbeamrainbowlabs",
         "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
-        "lastupdate": 1566520130,
+        "lastupdate": 1566672916,
         "optional": false,
         "extra_data": []
     },
     {
         "id": "feature-stats",
         "name": "Statistics",
-        "version": "0.2",
+        "version": "0.2.1",
         "author": "Starbeamrainbowlabs",
         "description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
-        "lastupdate": 1565741951,
+        "lastupdate": 1566671750,
         "optional": false,
         "extra_data": []
     },
@@ -165,7 +165,7 @@
         "version": "0.3.3",
         "author": "Starbeamrainbowlabs",
         "description": "Adds a user preferences page, letting people do things like change their email address and password.",
-        "lastupdate": 1526035213,
+        "lastupdate": 1566671167,
         "optional": false,
         "extra_data": []
     },
diff --git a/modules/feature-search.php b/modules/feature-search.php
index f65b1a0..56636a2 100644
--- a/modules/feature-search.php
+++ b/modules/feature-search.php
@@ -523,6 +523,18 @@ window.addEventListener("load", function(event) {
 });
 ');
 		}
+		
+		add_help_section("27-search", "Searching", "<p>$settings->sitename has an integrated full-text search engine, allowing you to search all of the pages on $settings->sitename and their content. To use it, simply enter your query into the page name box and press enter. If a page isn't found with the exact name of your query terms, a search will be performed instead.</p>
+		<p>Additionally, advanced users can take advantage of some extra query syntax that $settings->sitename supports, which is inspired by popular search engines:</p>
+		<table>
+		<tr><th style='width: 33%;'>Example</th><th style='width: 66%;'>Meaning</th></tr>
+		<tr><td><code>cat -dog</code></td><td>Search for pages containing \"cat\", but not \"dog\". This syntax does not make sense on it's own - other words must be present for it to take effect.</td>
+		<tr><td><code>+glass marble</code></td><td>Double the weighting of the word \"glass\".</td>
+		<tr><td><code>intitle:rocket</code></td><td>Search only page titles for \"rocket\".</td>
+		<tr><td><code>intags:bill</code></td><td>Search only tags for \"bill\".</td>
+		<tr><td><code>inbody:satellite</code></td><td>Search only the page body for \"satellite\".</td>
+		</table>
+		<p>More query syntax will be added in the future, so keep an eye on <a href='https://github.com/sbrl/Pepperminty-Wiki/releases/'>the latest releases</a> of <em>Pepperminty Wiki</em> to stay up-to-date (<a href='https://github.com/sbrl/Pepperminty-Wiki/releases.atom'>Atom / RSS feed available here</a>).</p>");
 	}
 ]);
 
diff --git a/modules/feature-stats.php b/modules/feature-stats.php
index fc58432..7657174 100644
--- a/modules/feature-stats.php
+++ b/modules/feature-stats.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Statistics",
-	"version" => "0.2",
+	"version" => "0.2.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
 	"id" => "feature-stats",
@@ -133,7 +133,8 @@ register_module([
 			echo(file_get_contents($paths->statsindex) . "\n");
 		});
 		
-		add_help_section("150-statistics", "Statistics", "<p></p>");
+		add_help_section("150-statistics", "Statistics", "<p>$settings->sitename records some statistics about itself, including the number of pages, the longest pages, the most wanted pages, the most linked-to pages, and more. They are updated roughly every " . human_time($settings->stats_update_interval) . ", though moderators may occasionally update them sooner.</p>
+		<p>You can see these statistics <a href='?action=stats'>here</a>.</p>");
 		
 		//////////////////////////
 		/// Built-in Statisics ///
