mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Make sure that all files are stored in the data directories.
Fixes #89.
This commit is contained in:
parent
3a7b9412ac
commit
27acc2420b
5 changed files with 22 additions and 18 deletions
|
@ -526,10 +526,10 @@ function check_subpage_parents($pagename)
|
||||||
|
|
||||||
$parent_pagename = substr($pagename, 0, strrpos($pagename, "/"));
|
$parent_pagename = substr($pagename, 0, strrpos($pagename, "/"));
|
||||||
$parent_page_filename = "$parent_pagename.md";
|
$parent_page_filename = "$parent_pagename.md";
|
||||||
if(!file_exists($parent_page_filename))
|
if(!file_exists($env->storage_prefix . $parent_page_filename))
|
||||||
{
|
{
|
||||||
// This parent page doesn't exist! Create it and add it to the page index.
|
// This parent page doesn't exist! Create it and add it to the page index.
|
||||||
touch($parent_page_filename, 0);
|
touch($env->storage_prefix . $parent_page_filename, 0);
|
||||||
|
|
||||||
$newentry = new stdClass();
|
$newentry = new stdClass();
|
||||||
$newentry->filename = $parent_page_filename;
|
$newentry->filename = $parent_page_filename;
|
||||||
|
@ -2340,7 +2340,7 @@ class search
|
||||||
|
|
||||||
self::merge_into_invindex($invindex, ids::getid($pagename), $index);
|
self::merge_into_invindex($invindex, ids::getid($pagename), $index);
|
||||||
}
|
}
|
||||||
|
error_log("Saving inverted index to $paths->searchindex");
|
||||||
self::save_invindex($paths->searchindex, $invindex);
|
self::save_invindex($paths->searchindex, $invindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3734,14 +3734,16 @@ DIFFSCRIPT;
|
||||||
exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content));
|
exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----~~~==~~~-----
|
||||||
|
|
||||||
// Update the inverted search index
|
// Update the inverted search index
|
||||||
|
|
||||||
// Construct an index for the old and new page content
|
// Construct an index for the old and new page content
|
||||||
$oldindex = [];
|
$oldindex = [];
|
||||||
$oldpagedata = ""; // We need the old page data in order to pass it to the preprocessor
|
$oldpagedata = ""; // We need the old page data in order to pass it to the preprocessor
|
||||||
if(file_exists("$env->page.md"))
|
if(file_exists("$env->storage_prefix$env->page.md"))
|
||||||
{
|
{
|
||||||
$oldpagedata = file_get_contents("$env->page.md");
|
$oldpagedata = file_get_contents("$env->storage_prefix$env->page.md");
|
||||||
$oldindex = search::index($oldpagedata);
|
$oldindex = search::index($oldpagedata);
|
||||||
}
|
}
|
||||||
$newindex = search::index($pagedata);
|
$newindex = search::index($pagedata);
|
||||||
|
@ -3751,13 +3753,13 @@ DIFFSCRIPT;
|
||||||
$removals = [];
|
$removals = [];
|
||||||
search::compare_indexes($oldindex, $newindex, $additions, $removals);
|
search::compare_indexes($oldindex, $newindex, $additions, $removals);
|
||||||
// Load in the inverted index
|
// Load in the inverted index
|
||||||
$invindex = search::load_invindex("./invindex.json");
|
$invindex = search::load_invindex($env->storage_prefix . "invindex.json");
|
||||||
// Merge the changes into the inverted index
|
// Merge the changes into the inverted index
|
||||||
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
|
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
|
||||||
// Save the inverted index back to disk
|
// Save the inverted index back to disk
|
||||||
search::save_invindex("invindex.json", $invindex);
|
search::save_invindex($env->storage_prefix . "invindex.json", $invindex);
|
||||||
|
|
||||||
|
|
||||||
|
// -----~~~==~~~-----
|
||||||
|
|
||||||
if(file_put_contents("$env->storage_prefix$env->page.md", $pagedata) !== false)
|
if(file_put_contents("$env->storage_prefix$env->page.md", $pagedata) !== false)
|
||||||
{
|
{
|
4
core.php
4
core.php
|
@ -227,10 +227,10 @@ function check_subpage_parents($pagename)
|
||||||
|
|
||||||
$parent_pagename = substr($pagename, 0, strrpos($pagename, "/"));
|
$parent_pagename = substr($pagename, 0, strrpos($pagename, "/"));
|
||||||
$parent_page_filename = "$parent_pagename.md";
|
$parent_page_filename = "$parent_pagename.md";
|
||||||
if(!file_exists($parent_page_filename))
|
if(!file_exists($env->storage_prefix . $parent_page_filename))
|
||||||
{
|
{
|
||||||
// This parent page doesn't exist! Create it and add it to the page index.
|
// This parent page doesn't exist! Create it and add it to the page index.
|
||||||
touch($parent_page_filename, 0);
|
touch($env->storage_prefix . $parent_page_filename, 0);
|
||||||
|
|
||||||
$newentry = new stdClass();
|
$newentry = new stdClass();
|
||||||
$newentry->filename = $parent_page_filename;
|
$newentry->filename = $parent_page_filename;
|
|
@ -68,7 +68,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": 1465757892,
|
"lastupdate": 1471592829,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
||||||
"id": "page-edit",
|
"id": "page-edit",
|
||||||
"lastupdate": 1471549914,
|
"lastupdate": 1471596690,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
|
@ -267,7 +267,7 @@ class search
|
||||||
|
|
||||||
self::merge_into_invindex($invindex, ids::getid($pagename), $index);
|
self::merge_into_invindex($invindex, ids::getid($pagename), $index);
|
||||||
}
|
}
|
||||||
|
error_log("Saving inverted index to $paths->searchindex");
|
||||||
self::save_invindex($paths->searchindex, $invindex);
|
self::save_invindex($paths->searchindex, $invindex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,14 +233,16 @@ DIFFSCRIPT;
|
||||||
exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content));
|
exit(page_renderer::render_main("Edit Conflict - $env->page - $settings->sitename", $content));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----~~~==~~~-----
|
||||||
|
|
||||||
// Update the inverted search index
|
// Update the inverted search index
|
||||||
|
|
||||||
// Construct an index for the old and new page content
|
// Construct an index for the old and new page content
|
||||||
$oldindex = [];
|
$oldindex = [];
|
||||||
$oldpagedata = ""; // We need the old page data in order to pass it to the preprocessor
|
$oldpagedata = ""; // We need the old page data in order to pass it to the preprocessor
|
||||||
if(file_exists("$env->page.md"))
|
if(file_exists("$env->storage_prefix$env->page.md"))
|
||||||
{
|
{
|
||||||
$oldpagedata = file_get_contents("$env->page.md");
|
$oldpagedata = file_get_contents("$env->storage_prefix$env->page.md");
|
||||||
$oldindex = search::index($oldpagedata);
|
$oldindex = search::index($oldpagedata);
|
||||||
}
|
}
|
||||||
$newindex = search::index($pagedata);
|
$newindex = search::index($pagedata);
|
||||||
|
@ -250,13 +252,13 @@ DIFFSCRIPT;
|
||||||
$removals = [];
|
$removals = [];
|
||||||
search::compare_indexes($oldindex, $newindex, $additions, $removals);
|
search::compare_indexes($oldindex, $newindex, $additions, $removals);
|
||||||
// Load in the inverted index
|
// Load in the inverted index
|
||||||
$invindex = search::load_invindex("./invindex.json");
|
$invindex = search::load_invindex($env->storage_prefix . "invindex.json");
|
||||||
// Merge the changes into the inverted index
|
// Merge the changes into the inverted index
|
||||||
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
|
search::merge_into_invindex($invindex, ids::getid($env->page), $additions, $removals);
|
||||||
// Save the inverted index back to disk
|
// Save the inverted index back to disk
|
||||||
search::save_invindex("invindex.json", $invindex);
|
search::save_invindex($env->storage_prefix . "invindex.json", $invindex);
|
||||||
|
|
||||||
|
|
||||||
|
// -----~~~==~~~-----
|
||||||
|
|
||||||
if(file_put_contents("$env->storage_prefix$env->page.md", $pagedata) !== false)
|
if(file_put_contents("$env->storage_prefix$env->page.md", $pagedata) !== false)
|
||||||
{
|
{
|
Loading…
Reference in a new issue