Bugfix moving pages with comments & the login to post a comment button

This commit is contained in:
Starbeamrainbowlabs 2017-11-23 15:16:08 +00:00
parent 59047af5eb
commit a15085d67d
6 changed files with 47 additions and 20 deletions

View File

@ -1,6 +1,18 @@
# Changelog # Changelog
This file holds the changelog for Pepperminty Wiki. This is the master list of things that have changed (second only to the commit history!) - though the information for any particular release can also be found in the description of it's page for every release made on Github too. This file holds the changelog for Pepperminty Wiki. This is the master list of things that have changed (second only to the commit history!) - though the information for any particular release can also be found in the description of it's page for every release made on Github too.
## v0.15-beta2
### Added
- Added "restore locally saved content" button to page editor
- [module api] Documented the remainder of the members of the `search` class
### Fixed
- Moving a page will now move all the comments associated with it
- The page names on the page move success page are now encoded correctly to avoid html and url issues
- Clicking _Login to post a comment_ will now take you back to the comments section of the page you were on upon completing the login process instead of the top of the page
## v0.15-beta1 ## v0.15-beta1
### Added ### Added
@ -15,7 +27,6 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- The `history` action now supports `format=json` and `format=csv` - The `history` action now supports `format=json` and `format=csv`
- Added tags next to the names of pages in the search results - Added tags next to the names of pages in the search results
- Added new `random_page_exclude` setting that allows you to exclude pages from the random action with a (PHP) regular expression - Added new `random_page_exclude` setting that allows you to exclude pages from the random action with a (PHP) regular expression
- Added "restore locally saved content" button to page editor
- [module api] Added new `get_page_parent($pagename)` method. - [module api] Added new `get_page_parent($pagename)` method.
- [module api] Added new remote file system to download additional required files. Use it with `register_remote_file` - [module api] Added new remote file system to download additional required files. Use it with `register_remote_file`
@ -35,6 +46,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Search now searches matching tags as well as pages - Search now searches matching tags as well as pages
- Updated the search ranking algorithm to put more weight against longer words than shorter ones. - Updated the search ranking algorithm to put more weight against longer words than shorter ones.
## v0.14 ## v0.14
### Changed ### Changed

View File

@ -2516,7 +2516,7 @@ function render_sidebar($pageindex, $root_pagename = "")
register_module([ register_module([
"name" => "Page Comments", "name" => "Page Comments",
"version" => "0.2.3", "version" => "0.3.1",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds threaded comments to the bottom of every page.", "description" => "Adds threaded comments to the bottom of every page.",
"id" => "feature-comments", "id" => "feature-comments",
@ -2729,7 +2729,7 @@ register_module([
else { else {
$comments_html .= "<form class='comment-reply-form disabled no-login'>\n" . $comments_html .= "<form class='comment-reply-form disabled no-login'>\n" .
"\t<textarea disabled name='message' placeholder='Type your comment here. You can use the same syntax you use when writing pages.'></textarea>\n" . "\t<textarea disabled name='message' placeholder='Type your comment here. You can use the same syntax you use when writing pages.'></textarea>\n" .
"\t<p class='not-logged-in'><a href='?action=login&returnto=" . rawurlencode("?action=view&page=" . rawurlencode($env->page)) . "'>Login</a> to post a comment.</p>\n" . "\t<p class='not-logged-in'><a href='?action=login&returnto=" . rawurlencode("?action=view&page=" . rawurlencode($env->page) . "#comments") . "'>Login</a> to post a comment.</p>\n" .
"\t<input type='hidden' name='replyto' />\n" . "\t<input type='hidden' name='replyto' />\n" .
"\t<input disabled type='submit' value='Post Comment' title='Login to post a comment.' />\n" . "\t<input disabled type='submit' value='Post Comment' title='Login to post a comment.' />\n" .
"</form>\n"; "</form>\n";
@ -6084,7 +6084,7 @@ register_module([
register_module([ register_module([
"name" => "Page editor", "name" => "Page editor",
"version" => "0.16", "version" => "0.17",
"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",
@ -6264,7 +6264,6 @@ window.addEventListener("load", function(event) {
// ~ // ~
/// ~~~ Smart saving ~~~ /// /// ~~~ Smart saving ~~~ ///
// TODO: Add a button to press that restores the content that you were working on before.
page_renderer::AddJSSnippet('window.addEventListener("load", function(event) { page_renderer::AddJSSnippet('window.addEventListener("load", function(event) {
"use strict"; "use strict";
// Smart saving // Smart saving
@ -7287,7 +7286,7 @@ register_module([
register_module([ register_module([
"name" => "Page mover", "name" => "Page mover",
"version" => "0.9.2", "version" => "0.9.3",
"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",
@ -7405,12 +7404,20 @@ register_module([
// Move the page in the id index // Move the page in the id index
ids::movepagename($page, $new_name); ids::movepagename($page, $new_name);
// Move the comments file as well, if it exists
if(file_exists("$env->storage_prefix$env->page.comments.json")) {
rename(
"$env->storage_prefix$env->page.comments.json",
"$env->storage_prefix$new_name.comments.json"
);
}
// Exit with a nice message // Exit with a nice message
exit(page_renderer::render_main("Moving $env->page", "<p><a href='index.php?page=$env->page'>$env->page</a> has been moved to <a href='index.php?page=$new_name'>$new_name</a> successfully.</p>")); exit(page_renderer::render_main("Moving " . htmlentities($env->page), "<p><a href='index.php?page=" . rawurlencode($env->page) . "'>" . htmlentities($env->page) . "</a> has been moved to <a href='index.php?page=" . rawurlencode($new_name) . "'>" . htmlentities($new_name) . "</a> successfully.</p>"));
}); });
// Register a help section // Register a help section
add_help_section("60-move", "Moving Pages", "<p>If you are logged in as an administrator, then you have the power to move pages. To do this, click &quot;Delete&quot; in the &quot;More...&quot; menu when browsing the pge you wish to move. Type in the new name of the page, and then click &quot;Move Page&quot;.</p>"); add_help_section("60-move", "Moving Pages", "<p>If you are logged in as an administrator, then you have the power to move pages. To do this, click &quot;Move&quot; in the &quot;More...&quot; menu when browsing the pge you wish to move. Type in the new name of the page, and then click &quot;Move Page&quot;.</p>");
} }
]); ]);

View File

@ -55,11 +55,11 @@
}, },
{ {
"name": "Page Comments", "name": "Page Comments",
"version": "0.2.3", "version": "0.3.1",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds threaded comments to the bottom of every page.", "description": "Adds threaded comments to the bottom of every page.",
"id": "feature-comments", "id": "feature-comments",
"lastupdate": 1511096059, "lastupdate": 1511450038,
"optional": false "optional": false
}, },
{ {
@ -163,11 +163,11 @@
}, },
{ {
"name": "Page editor", "name": "Page editor",
"version": "0.16", "version": "0.17",
"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": 1511294953, "lastupdate": 1511449791,
"optional": false "optional": false
}, },
{ {
@ -217,11 +217,11 @@
}, },
{ {
"name": "Page mover", "name": "Page mover",
"version": "0.9.2", "version": "0.9.3",
"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": 1482008539, "lastupdate": 1511449784,
"optional": false "optional": false
}, },
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page Comments", "name" => "Page Comments",
"version" => "0.2.3", "version" => "0.3.1",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds threaded comments to the bottom of every page.", "description" => "Adds threaded comments to the bottom of every page.",
"id" => "feature-comments", "id" => "feature-comments",
@ -214,7 +214,7 @@ register_module([
else { else {
$comments_html .= "<form class='comment-reply-form disabled no-login'>\n" . $comments_html .= "<form class='comment-reply-form disabled no-login'>\n" .
"\t<textarea disabled name='message' placeholder='Type your comment here. You can use the same syntax you use when writing pages.'></textarea>\n" . "\t<textarea disabled name='message' placeholder='Type your comment here. You can use the same syntax you use when writing pages.'></textarea>\n" .
"\t<p class='not-logged-in'><a href='?action=login&returnto=" . rawurlencode("?action=view&page=" . rawurlencode($env->page)) . "'>Login</a> to post a comment.</p>\n" . "\t<p class='not-logged-in'><a href='?action=login&returnto=" . rawurlencode("?action=view&page=" . rawurlencode($env->page) . "#comments") . "'>Login</a> to post a comment.</p>\n" .
"\t<input type='hidden' name='replyto' />\n" . "\t<input type='hidden' name='replyto' />\n" .
"\t<input disabled type='submit' value='Post Comment' title='Login to post a comment.' />\n" . "\t<input disabled type='submit' value='Post Comment' title='Login to post a comment.' />\n" .
"</form>\n"; "</form>\n";

View File

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page editor", "name" => "Page editor",
"version" => "0.16", "version" => "0.17",
"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",

View File

@ -1,7 +1,7 @@
<?php <?php
register_module([ register_module([
"name" => "Page mover", "name" => "Page mover",
"version" => "0.9.2", "version" => "0.9.3",
"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",
@ -119,12 +119,20 @@ register_module([
// Move the page in the id index // Move the page in the id index
ids::movepagename($page, $new_name); ids::movepagename($page, $new_name);
// Move the comments file as well, if it exists
if(file_exists("$env->storage_prefix$env->page.comments.json")) {
rename(
"$env->storage_prefix$env->page.comments.json",
"$env->storage_prefix$new_name.comments.json"
);
}
// Exit with a nice message // Exit with a nice message
exit(page_renderer::render_main("Moving $env->page", "<p><a href='index.php?page=$env->page'>$env->page</a> has been moved to <a href='index.php?page=$new_name'>$new_name</a> successfully.</p>")); exit(page_renderer::render_main("Moving " . htmlentities($env->page), "<p><a href='index.php?page=" . rawurlencode($env->page) . "'>" . htmlentities($env->page) . "</a> has been moved to <a href='index.php?page=" . rawurlencode($new_name) . "'>" . htmlentities($new_name) . "</a> successfully.</p>"));
}); });
// Register a help section // Register a help section
add_help_section("60-move", "Moving Pages", "<p>If you are logged in as an administrator, then you have the power to move pages. To do this, click &quot;Delete&quot; in the &quot;More...&quot; menu when browsing the pge you wish to move. Type in the new name of the page, and then click &quot;Move Page&quot;.</p>"); add_help_section("60-move", "Moving Pages", "<p>If you are logged in as an administrator, then you have the power to move pages. To do this, click &quot;Move&quot; in the &quot;More...&quot; menu when browsing the pge you wish to move. Type in the new name of the page, and then click &quot;Move Page&quot;.</p>");
} }
]); ]);