1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

Bugfix: Correctly calculate the end offset of search context snippets

This commit is contained in:
Starbeamrainbowlabs 2018-09-29 13:27:17 +01:00
parent 284b404946
commit 24775724d1
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 7 additions and 8 deletions

View file

@ -32,6 +32,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- The search redirector will now check both the specified page name and the page name in Title Case
- 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 another bug in the search context generator
## 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.

View file

@ -407,7 +407,7 @@ if($settings->sessionprefix == "auto")
/////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */
$version = "v0.17-dev";
$commit = "39c8f48019599cc00e919d5c699e0c01c7278ef4";
$commit = "284b4049460887b0b40b2f73e7db9158e5bc1ef0";
/// Environment ///
/** Holds information about the current request environment. */
$env = new stdClass();
@ -1478,7 +1478,7 @@ class page_renderer
{all-pages-datalist}";
/**
* A specially minified content template that doesn't include the navbar and
* other elements not suiltable for printing.
* other elements not suitable for printing.
* @var string
* @package core
*/
@ -4550,7 +4550,7 @@ class search
}
foreach($newindex as $nterm => $entry)
{
if(!isset($oldindex[$nterm]) or // If this world is new
if(!isset($oldindex[$nterm]) or // If this word is new
$newindex[$nterm] !== $oldindex[$nterm]) // If this word has changed
$changed[$nterm] = $newindex[$nterm];
}
@ -4783,7 +4783,6 @@ class search
// todo remove items if the rank is below a threshold
}
// todo sort by rank here
uasort($matching_pages, function($a, $b) {
if($a["rank"] == $b["rank"]) return 0;
return ($a["rank"] < $b["rank"]) ? +1 : -1;
@ -4836,7 +4835,7 @@ class search
for($i = 0; $i < $matches_count; $i++) {
$next_context = [
"from" => max(0, $matches[$i][1] - $settings->search_characters_context),
"to" => min($sourceLength, $matches[$i][1] + count($matches[0]) + $settings->search_characters_context)
"to" => min($sourceLength, $matches[$i][1] + mb_strlen($matches[$i][0]) + $settings->search_characters_context)
];
if(end($contexts) !== false && end($contexts)["to"] > $next_context["from"]) {

View file

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

View file

@ -904,7 +904,6 @@ class search
// todo remove items if the rank is below a threshold
}
// todo sort by rank here
uasort($matching_pages, function($a, $b) {
if($a["rank"] == $b["rank"]) return 0;
return ($a["rank"] < $b["rank"]) ? +1 : -1;
@ -957,7 +956,7 @@ class search
for($i = 0; $i < $matches_count; $i++) {
$next_context = [
"from" => max(0, $matches[$i][1] - $settings->search_characters_context),
"to" => min($sourceLength, $matches[$i][1] + count($matches[0]) + $settings->search_characters_context)
"to" => min($sourceLength, $matches[$i][1] + mb_strlen($matches[$i][0]) + $settings->search_characters_context)
];
if(end($contexts) !== false && end($contexts)["to"] > $next_context["from"]) {