mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
feature-comments: add 2 new settings
This commit is contained in:
parent
4378f4f526
commit
edc1a694dd
3 changed files with 19 additions and 4 deletions
|
@ -21,6 +21,9 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
|||
- Added similar page suggestions between the bottom of the page content and the comments - control it with the new `similarpages_enabled` and `similarpages_count` settings.
|
||||
- Added absolute redirect support - use it like this: `# REDIRECT [display text](INSERT_REDIRECT_URL_HERE)`
|
||||
- It's disabled by default due to potential security issues with untrusted editors - enable it with the new `redirect_absolute_enable` setting (default: : `false`)
|
||||
- Added new settings to control the commenting system
|
||||
- `comment_enabled` controls whether _anyone_ is allowed to comment at all or not
|
||||
- `comment_hide_all` determines whether the commenting system displays anything at all (if disabled, it's (almost) like the `feature-comments` doesn't exist - consider using the downloader to exclude the commenting system instead of enabling this setting)
|
||||
|
||||
### Changed
|
||||
- Fiddled with Parsedown & ParsedownExtra versions
|
||||
|
|
|
@ -8,6 +8,10 @@ register_module([
|
|||
"code" => function() {
|
||||
global $env, $settings;
|
||||
|
||||
// Don't do anything if we're not wanted
|
||||
if($settings->comment_hide_all)
|
||||
return;
|
||||
|
||||
/**
|
||||
* @api {post} ?action=comment Comment on a page
|
||||
* @apiName Comment
|
||||
|
@ -35,6 +39,12 @@ register_module([
|
|||
$reply_to = $_POST["replyto"] ?? null;
|
||||
$message = $_POST["message"] ?? "";
|
||||
|
||||
if(!$settings->comment_enabled) {
|
||||
http_response_code(401);
|
||||
exit(page_renderer::render_main("Commenting disabled - $settings->sitename", "<p>Your comment couldn't be posted because $settings->sitename currently has commenting disabled. Here's the comment you tried to post:</p>
|
||||
<textarea readonly>".htmlentities($message)."</textarea>"));
|
||||
}
|
||||
|
||||
if(!$env->is_logged_in && !$settings->anoncomments) {
|
||||
http_response_code(401);
|
||||
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>Your comment couldn't be posted because you're not logged in. You can login <a href='?action=index'>here</a>. Here's the comment you tried to post:</p>
|
||||
|
@ -238,7 +248,7 @@ register_module([
|
|||
|
||||
if($env->action == "view") {
|
||||
page_renderer::register_part_preprocessor(function(&$parts) {
|
||||
global $env;
|
||||
global $env, $settings;
|
||||
$comments_filename = get_comment_filename($env->page);
|
||||
$comments_data = file_exists($comments_filename) ? json_decode(file_get_contents($comments_filename)) : [];
|
||||
|
||||
|
@ -246,7 +256,7 @@ register_module([
|
|||
$comments_html = "<aside class='comments'>" .
|
||||
"<h2 id='comments'>Comments</h2>\n";
|
||||
|
||||
if($env->is_logged_in) {
|
||||
if($env->is_logged_in && $settings->comment_enabled) {
|
||||
$comments_html .= "<form class='comment-reply-form' method='post' action='?action=comment&page=" . rawurlencode($env->page) . "'>\n" .
|
||||
"<h3>Post a Comment</h3>\n" .
|
||||
"\t<textarea name='message' placeholder='Type your comment here. You can use the same syntax you use when writing pages.'></textarea>\n" .
|
||||
|
@ -254,7 +264,7 @@ register_module([
|
|||
"\t<input type='submit' value='Post Comment' />\n" .
|
||||
"</form>\n";
|
||||
}
|
||||
else {
|
||||
elseif($settings->comment_enabled) {
|
||||
$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<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" .
|
||||
|
|
|
@ -198,7 +198,9 @@
|
|||
"index.php?action=help"
|
||||
]
|
||||
]},
|
||||
"anoncomments": { "type": "checkbox", "description": "Whether to allow anonymous user to make comments. Note that anonymous users are not able to delete their own comments (since they are not logged in, there's no way to know if they were the original poster or not)", "default": false },
|
||||
"comment_enabled": { "type": "checkbox", "description": "Whether commenting is enabled or not. If disabled, nobody will be able to post new comments, but existing comments will still be shown (if the <code>feature-comments</code> module is installed, of course - otherwise this setting will have no effect).", "default": true },
|
||||
"comment_hide_all": { "type": "checkbox ", "description": "Whether to hide all comments, as if the commenting feature never existed. If you want to enable this setting, consider using the downloader (link in the docs) to exclude the <code>feature-comments</code> module instead.", "default": false },
|
||||
"anoncomments": { "type": "checkbox", "description": "Whether to allow anonymous user to make comments. Note that anonymous users are not able to delete their own comments (since they are not logged in, there's no way to know if they were the original poster or not)", "default": false },
|
||||
"comment_max_length": { "type": "number", "description": "The maximum allowed length, in characters, for comments", "default": 5000 },
|
||||
"comment_min_length": { "type": "number", "description": "The minimum allowed length, in characters, for comments", "default": 10 },
|
||||
"comment_time_icon": { "type": "text", "description": "The icon to show next to the time that a comment was posted.", "default": "🕗" },
|
||||
|
|
Loading…
Reference in a new issue