Add support for editing tags

This commit is contained in:
Starbeamrainbowlabs 2015-10-25 11:26:35 +00:00
parent 3e47422cc6
commit f04773a76b
4 changed files with 27 additions and 7 deletions

View File

@ -259,6 +259,7 @@ input[type=text]:not(.link-display), input[type=password], textarea { margin: 0.
input[type=text], input[type=password], textarea { padding: 0.5rem 0.8rem; background: #d5cbf9; border: 0; border-radius: 0.3rem; font-size: 1rem; color: #442772; }
textarea { width: calc(100% - 2rem); min-height: 35rem; font-size: 1.25rem; }
textarea ~ input[type=submit] { width: calc(100% - 0.3rem); margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
footer { padding: 2rem; }
/* #ffdb6d #36962c */";
@ -1752,12 +1753,14 @@ register_module([
}
$content = "<h1>$title</h1>";
$page_tags = implode(", ", (!empty($pageindex->{$env->page}->tags)) ? $pageindex->{$env->page}->tags : "");
if(!$env->is_logged_in and $settings->anonedits)
{
$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
}
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save'>
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save' class='editform'>
<textarea name='content'>$pagetext</textarea>
<input type='text' name='tags' value='$page_tags' placeholder='Enter some tags for the page here. Separate them with commas.' title='Enter some tags for the page here. Separate them with commas.' />
<p>$settings->editing_message</p>
<input type='submit' value='Save Page' />
</form>";
@ -1810,12 +1813,18 @@ register_module([
mkdir(dirname("$env->page.md"), null, true);
}
// Read in the new page content
$pagedata = $_POST["content"];
// Santise it if necessary
if($settings->clean_raw_html)
$pagedata = htmlentities($pagedata, ENT_QUOTES);
// Read in the new page tags
$page_tags = explode(",", $_POST["tags"]);
// Trim off all the whitespace
foreach($page_tags as &$tag)
$tag = trim($tag);
if(file_put_contents("$env->page.md", $pagedata) !== false)
{
$page = $env->page;
@ -1834,6 +1843,7 @@ register_module([
$pageindex->$page->lasteditor = utf8_encode($env->user);
else
$pageindex->$page->lasteditor = utf8_encode("anonymous");
$pageindex->$page->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have
// changed it. We need this because the preprocessors *must*

View File

@ -77,7 +77,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": 1445170746,
"lastupdate": 1445772370,
"optional": false
},
{

View File

@ -60,12 +60,14 @@ register_module([
}
$content = "<h1>$title</h1>";
$page_tags = implode(", ", (!empty($pageindex->{$env->page}->tags)) ? $pageindex->{$env->page}->tags : "");
if(!$env->is_logged_in and $settings->anonedits)
{
$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
}
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save'>
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save' class='editform'>
<textarea name='content'>$pagetext</textarea>
<input type='text' name='tags' value='$page_tags' placeholder='Enter some tags for the page here. Separate them with commas.' title='Enter some tags for the page here. Separate them with commas.' />
<p>$settings->editing_message</p>
<input type='submit' value='Save Page' />
</form>";
@ -118,12 +120,18 @@ register_module([
mkdir(dirname("$env->page.md"), null, true);
}
// Read in the new page content
$pagedata = $_POST["content"];
// Santise it if necessary
if($settings->clean_raw_html)
$pagedata = htmlentities($pagedata, ENT_QUOTES);
// Read in the new page tags
$page_tags = explode(",", $_POST["tags"]);
// Trim off all the whitespace
foreach($page_tags as &$tag)
$tag = trim($tag);
if(file_put_contents("$env->page.md", $pagedata) !== false)
{
$page = $env->page;
@ -142,6 +150,7 @@ register_module([
$pageindex->$page->lasteditor = utf8_encode($env->user);
else
$pageindex->$page->lasteditor = utf8_encode("anonymous");
$pageindex->$page->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have
// changed it. We need this because the preprocessors *must*

View File

@ -256,6 +256,7 @@ input[type=text]:not(.link-display), input[type=password], textarea { margin: 0.
input[type=text], input[type=password], textarea { padding: 0.5rem 0.8rem; background: #d5cbf9; border: 0; border-radius: 0.3rem; font-size: 1rem; color: #442772; }
textarea { width: calc(100% - 2rem); min-height: 35rem; font-size: 1.25rem; }
textarea ~ input[type=submit] { width: calc(100% - 0.3rem); margin: 0.5rem 0.8rem; padding: 0.5rem; font-weight: bolder; }
.editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; }
footer { padding: 2rem; }
/* #ffdb6d #36962c */";