mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Add 'smart save' feature to page creator.
Never again will people loose their work.
This commit is contained in:
parent
ace3eb61ee
commit
d3b6b1c54e
3 changed files with 50 additions and 14 deletions
|
@ -1372,7 +1372,7 @@ if(isset($_GET["revision"]) and is_numeric($_GET["revision"]))
|
||||||
$env->page_filename = $env->storage_prefix;
|
$env->page_filename = $env->storage_prefix;
|
||||||
if($env->is_history_revision)
|
if($env->is_history_revision)
|
||||||
$env->page_filename .= $pageindex->{$env->page}->history[$env->history->revision_number]->filename;
|
$env->page_filename .= $pageindex->{$env->page}->history[$env->history->revision_number]->filename;
|
||||||
else
|
else if(isset($pageindex->{$env->page}))
|
||||||
$env->page_filename .= $pageindex->{$env->page}->filename;
|
$env->page_filename .= $pageindex->{$env->page}->filename;
|
||||||
|
|
||||||
$env->action = strtolower($_GET["action"]);
|
$env->action = strtolower($_GET["action"]);
|
||||||
|
@ -3845,6 +3845,24 @@ register_module([
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</form>";
|
</form>";
|
||||||
|
|
||||||
|
// ~
|
||||||
|
|
||||||
|
/// ~~~ Smart saving ~~~ ///
|
||||||
|
|
||||||
|
$content .= <<<SMARTSAVE
|
||||||
|
<!-- Smart saving script -->
|
||||||
|
<script>
|
||||||
|
function getSmartSaveKey() { return document.querySelector("main h1").innerHTML.replace("Creating ", "").trim(); }
|
||||||
|
// Saving
|
||||||
|
document.querySelector("textarea[name=content]").addEventListener("keyup", function(event) { window.localStorage.setItem(getSmartSaveKey(), event.target.value) });
|
||||||
|
// Loading
|
||||||
|
window.addEventListener("load", function(event) {
|
||||||
|
document.querySelector("textarea[name=content]").value = localStorage.getItem(getSmartSaveKey());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
SMARTSAVE;
|
||||||
|
|
||||||
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4743,14 +4761,14 @@ register_module([
|
||||||
|
|
||||||
register_module([
|
register_module([
|
||||||
"name" => "Update",
|
"name" => "Update",
|
||||||
"version" => "0.6.1",
|
"version" => "0.6.2",
|
||||||
"author" => "Starbeamrainbowlabs",
|
"author" => "Starbeamrainbowlabs",
|
||||||
"description" => "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
|
"description" => "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
|
||||||
"id" => "page-update",
|
"id" => "page-update",
|
||||||
"code" => function() {
|
"code" => function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} ?action=move[do=yes] Update the wiki
|
* @api {get} ?action=update[do=yes] Update the wiki
|
||||||
* @apiDescription Update the wiki by downloading a new version of Pepperminty Wiki from the URL specified in the settings. Note that unless you change the url from it's default, all custom modules installed will be removed. **Note also that this plugin is currently out of date. Use with extreme caution!**
|
* @apiDescription Update the wiki by downloading a new version of Pepperminty Wiki from the URL specified in the settings. Note that unless you change the url from it's default, all custom modules installed will be removed. **Note also that this plugin is currently out of date. Use with extreme caution!**
|
||||||
* @apiName Update
|
* @apiName Update
|
||||||
* @apiGroup Utility
|
* @apiGroup Utility
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds a 'raw' action that shows you the raw source of a page.",
|
"description": "Adds a 'raw' action that shows you the raw source of a page.",
|
||||||
"id": "action-raw",
|
"id": "action-raw",
|
||||||
"lastupdate": 1476813024,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.",
|
"description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.",
|
||||||
"id": "feature-guiconfig",
|
"id": "feature-guiconfig",
|
||||||
"lastupdate": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
||||||
"id": "feature-recent-changes",
|
"id": "feature-recent-changes",
|
||||||
"lastupdate": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,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": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
|
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
|
||||||
"id": "feature-upload",
|
"id": "feature-upload",
|
||||||
"lastupdate": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,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": 1476815055,
|
"lastupdate": 1477150472,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -176,16 +176,16 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds an action to allow administrators to move pages.",
|
"description": "Adds an action to allow administrators to move pages.",
|
||||||
"id": "page-move",
|
"id": "page-move",
|
||||||
"lastupdate": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Update",
|
"name": "Update",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
|
"description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
|
||||||
"id": "page-update",
|
"id": "page-update",
|
||||||
"lastupdate": 1466012454,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Allows you to view pages. You really should include this one.",
|
"description": "Allows you to view pages. You really should include this one.",
|
||||||
"id": "page-view",
|
"id": "page-view",
|
||||||
"lastupdate": 1476815512,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -212,7 +212,7 @@
|
||||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||||
"id": "parser-parsedown",
|
"id": "parser-parsedown",
|
||||||
"lastupdate": 1476815055,
|
"lastupdate": 1476906745,
|
||||||
"optional": false
|
"optional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -99,6 +99,24 @@ register_module([
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</form>";
|
</form>";
|
||||||
|
|
||||||
|
// ~
|
||||||
|
|
||||||
|
/// ~~~ Smart saving ~~~ ///
|
||||||
|
|
||||||
|
$content .= <<<SMARTSAVE
|
||||||
|
<!-- Smart saving script -->
|
||||||
|
<script>
|
||||||
|
function getSmartSaveKey() { return document.querySelector("main h1").innerHTML.replace("Creating ", "").trim(); }
|
||||||
|
// Saving
|
||||||
|
document.querySelector("textarea[name=content]").addEventListener("keyup", function(event) { window.localStorage.setItem(getSmartSaveKey(), event.target.value) });
|
||||||
|
// Loading
|
||||||
|
window.addEventListener("load", function(event) {
|
||||||
|
document.querySelector("textarea[name=content]").value = localStorage.getItem(getSmartSaveKey());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
SMARTSAVE;
|
||||||
|
|
||||||
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue