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

Update the pageindex when saving an edit.

This commit is contained in:
Starbeamrainbowlabs 2015-11-01 09:30:29 +00:00
parent 2b99cdec22
commit 7957b3ca2e
4 changed files with 41 additions and 5 deletions

View file

@ -273,8 +273,8 @@ label:not(.link-display-label) { display: inline-block; min-width: 7rem; }
input[type=text]:not(.link-display), input[type=password], textarea { margin: 0.5rem 0.8rem; }
input[type=text], input[type=password], textarea, #search-box { padding: 0.5rem 0.8rem; background: #d5cbf9; border: 0; border-radius: 0.3rem; font-size: 1rem; color: #442772; }
textarea { min-height: 35rem; font-size: 1.25rem; }
textarea ~ input[type=submit], #search-box { width: calc(100% - 0.3rem); }
textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
textarea, textarea ~ input[type=submit], #search-box { width: calc(100% - 0.3rem); box-sizing: border-box; }
textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
.page-tags-display { margin: 0.5rem 0 0 0; padding: 0; list-style-type: none; }
@ -2332,6 +2332,24 @@ register_module([
foreach($page_tags as &$tag)
$tag = trim($tag);
// Update the inverted search index
// Construct an index for the old and new page content
$oldindex = search::index(file_get_contents("$env->page.md"));
$newindex = search::index($pagedata);
// Compare the indexes of the old and new content
$additions = [];
$removals = [];
search::compare_indexes($oldindex, $newindex, $additions, $removals);
// Load in the inverted index
$invindex = search::load_invindex("./invindex.json");
// Merge the changes into the inverted index
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
// Save the inverted index back to disk
search::save_invindex("invindex.json", $invindex);
if(file_put_contents("$env->page.md", $pagedata) !== false)
{
$page = $env->page;

View file

@ -86,7 +86,7 @@
"author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit",
"lastupdate": 1446032086,
"lastupdate": 1446314649,
"optional": false
},
{

View file

@ -132,6 +132,24 @@ register_module([
foreach($page_tags as &$tag)
$tag = trim($tag);
// Update the inverted search index
// Construct an index for the old and new page content
$oldindex = search::index(file_get_contents("$env->page.md"));
$newindex = search::index($pagedata);
// Compare the indexes of the old and new content
$additions = [];
$removals = [];
search::compare_indexes($oldindex, $newindex, $additions, $removals);
// Load in the inverted index
$invindex = search::load_invindex("./invindex.json");
// Merge the changes into the inverted index
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
// Save the inverted index back to disk
search::save_invindex("invindex.json", $invindex);
if(file_put_contents("$env->page.md", $pagedata) !== false)
{
$page = $env->page;

View file

@ -270,8 +270,8 @@ label:not(.link-display-label) { display: inline-block; min-width: 7rem; }
input[type=text]:not(.link-display), input[type=password], textarea { margin: 0.5rem 0.8rem; }
input[type=text], input[type=password], textarea, #search-box { padding: 0.5rem 0.8rem; background: #d5cbf9; border: 0; border-radius: 0.3rem; font-size: 1rem; color: #442772; }
textarea { min-height: 35rem; font-size: 1.25rem; }
textarea ~ input[type=submit], #search-box { width: calc(100% - 0.3rem); }
textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
textarea, textarea ~ input[type=submit], #search-box { width: calc(100% - 0.3rem); box-sizing: border-box; }
textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
.page-tags-display { margin: 0.5rem 0 0 0; padding: 0; list-style-type: none; }