Display an ellipsis at the beginning of a search context if it doesn't start at the beginning of a page

This commit is contained in:
Starbeamrainbowlabs 2018-09-29 13:32:17 +01:00
parent 24775724d1
commit 39098ac0fb
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
4 changed files with 9 additions and 2 deletions

View File

@ -33,6 +33,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Improve help text description of image captions displayed alongside images - Improve help text description of image captions displayed alongside images
- Fixed the page history page - it should now display all page revisions in valid HTML - Fixed the page history page - it should now display all page revisions in valid HTML
- Fixed another bug in the search context generator - Fixed another bug in the search context generator
- Display an ellipsis at the beginning of a search context if it doesn't start at the beginning of a page
## Changed ## Changed
- Password hashing has been overhauled! A totally new-and-different system is being used now, so you'll need to rehash all your passwords. - Password hashing has been overhauled! A totally new-and-different system is being used now, so you'll need to rehash all your passwords.

View File

@ -407,7 +407,7 @@ if($settings->sessionprefix == "auto")
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */ /** The version of Pepperminty Wiki currently running. */
$version = "v0.17-dev"; $version = "v0.17-dev";
$commit = "284b4049460887b0b40b2f73e7db9158e5bc1ef0"; $commit = "24775724d14520b8007cf7f4cc0c1d8901980494";
/// Environment /// /// Environment ///
/** Holds information about the current request environment. */ /** Holds information about the current request environment. */
$env = new stdClass(); $env = new stdClass();
@ -4872,6 +4872,9 @@ class search
$result = implode("", $contexts_text); $result = implode("", $contexts_text);
end($contexts); // If there's at least one item in the list and were not at the very end of the page, add an extra ellipsis end($contexts); // If there's at least one item in the list and were not at the very end of the page, add an extra ellipsis
if(isset($contexts[0]) && $contexts[key($contexts)]["to"] < $sourceLength) $result .= ""; if(isset($contexts[0]) && $contexts[key($contexts)]["to"] < $sourceLength) $result .= "";
// Prepend an ellipsis if the context doesn't start at the beginning of a page
if(isset($contexts[0]) && $contexts[0]["from"] > 0) $result = "$result";
return $result; return $result;
} }

View File

@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs", "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.", "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.",
"id": "feature-search", "id": "feature-search",
"lastupdate": 1538223927, "lastupdate": 1538224279,
"optional": false "optional": false
}, },
{ {

View File

@ -993,6 +993,9 @@ class search
$result = implode("", $contexts_text); $result = implode("", $contexts_text);
end($contexts); // If there's at least one item in the list and were not at the very end of the page, add an extra ellipsis end($contexts); // If there's at least one item in the list and were not at the very end of the page, add an extra ellipsis
if(isset($contexts[0]) && $contexts[key($contexts)]["to"] < $sourceLength) $result .= ""; if(isset($contexts[0]) && $contexts[key($contexts)]["to"] < $sourceLength) $result .= "";
// Prepend an ellipsis if the context doesn't start at the beginning of a page
if(isset($contexts[0]) && $contexts[0]["from"] > 0) $result = "$result";
return $result; return $result;
} }