1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 16:33:00 +00:00

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; } 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 { 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; } 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; } footer { padding: 2rem; }
/* #ffdb6d #36962c */"; /* #ffdb6d #36962c */";
@ -1752,12 +1753,14 @@ register_module([
} }
$content = "<h1>$title</h1>"; $content = "<h1>$title</h1>";
$page_tags = implode(", ", (!empty($pageindex->{$env->page}->tags)) ? $pageindex->{$env->page}->tags : "");
if(!$env->is_logged_in and $settings->anonedits) 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 .= "<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> <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> <p>$settings->editing_message</p>
<input type='submit' value='Save Page' /> <input type='submit' value='Save Page' />
</form>"; </form>";
@ -1810,12 +1813,18 @@ register_module([
mkdir(dirname("$env->page.md"), null, true); mkdir(dirname("$env->page.md"), null, true);
} }
// Read in the new page content
$pagedata = $_POST["content"]; $pagedata = $_POST["content"];
// Santise it if necessary
if($settings->clean_raw_html) if($settings->clean_raw_html)
$pagedata = htmlentities($pagedata, ENT_QUOTES); $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) if(file_put_contents("$env->page.md", $pagedata) !== false)
{ {
$page = $env->page; $page = $env->page;
@ -1834,6 +1843,7 @@ register_module([
$pageindex->$page->lasteditor = utf8_encode($env->user); $pageindex->$page->lasteditor = utf8_encode($env->user);
else else
$pageindex->$page->lasteditor = utf8_encode("anonymous"); $pageindex->$page->lasteditor = utf8_encode("anonymous");
$pageindex->$page->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have // A hack to resave the pagedata if the preprocessors have
// changed it. We need this because the preprocessors *must* // changed it. We need this because the preprocessors *must*

View file

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

View file

@ -60,12 +60,14 @@ register_module([
} }
$content = "<h1>$title</h1>"; $content = "<h1>$title</h1>";
$page_tags = implode(", ", (!empty($pageindex->{$env->page}->tags)) ? $pageindex->{$env->page}->tags : "");
if(!$env->is_logged_in and $settings->anonedits) 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 .= "<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> <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> <p>$settings->editing_message</p>
<input type='submit' value='Save Page' /> <input type='submit' value='Save Page' />
</form>"; </form>";
@ -118,12 +120,18 @@ register_module([
mkdir(dirname("$env->page.md"), null, true); mkdir(dirname("$env->page.md"), null, true);
} }
// Read in the new page content
$pagedata = $_POST["content"]; $pagedata = $_POST["content"];
// Santise it if necessary
if($settings->clean_raw_html) if($settings->clean_raw_html)
$pagedata = htmlentities($pagedata, ENT_QUOTES); $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) if(file_put_contents("$env->page.md", $pagedata) !== false)
{ {
$page = $env->page; $page = $env->page;
@ -142,6 +150,7 @@ register_module([
$pageindex->$page->lasteditor = utf8_encode($env->user); $pageindex->$page->lasteditor = utf8_encode($env->user);
else else
$pageindex->$page->lasteditor = utf8_encode("anonymous"); $pageindex->$page->lasteditor = utf8_encode("anonymous");
$pageindex->$page->tags = $page_tags;
// A hack to resave the pagedata if the preprocessors have // A hack to resave the pagedata if the preprocessors have
// changed it. We need this because the preprocessors *must* // 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; } 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 { 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; } 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; } footer { padding: 2rem; }
/* #ffdb6d #36962c */"; /* #ffdb6d #36962c */";