aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-17 18:50:04 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-17 18:50:04 -0500
commit140c0bacbadc35de93cc685313123e9e51b45704 (patch)
treec73abfe7a7ef6a348d8b538ccc97ba6d5b76cac2
parent9b837fd5ed984f0947bc3e1f4478384b3b1691fd (diff)
downloadikiwiki-140c0bacbadc35de93cc685313123e9e51b45704.tar
ikiwiki-140c0bacbadc35de93cc685313123e9e51b45704.tar.gz
change around comments pagespecs
I think it is clearer to have one pagespec that controls all pages with comments, and a separate pagespec that can be used to close new comments on a subset of those pages.
-rw-r--r--IkiWiki/Plugin/comments.pm43
-rw-r--r--doc/plugins/comments.mdwn13
2 files changed, 27 insertions, 29 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 83f67869c..6e257d1d9 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -34,20 +34,18 @@ sub getsetup () {
safe => 1,
rebuild => 1,
},
- # Pages where comments are shown, but new comments are not
- # allowed, will show "Comments are closed".
- comments_shown_pagespec => {
+ comments_pagespec => {
type => 'pagespec',
- example => 'blog/*',
- description => 'PageSpec for pages where comments will be shown inline',
+ example => 'blog/* and *!/Discussion',
+ description => 'PageSpec of pages where comments are allowed',
link => 'ikiwiki/PageSpec',
safe => 1,
rebuild => 1,
},
- comments_open_pagespec => {
+ comments_closed_pagespec => {
type => 'pagespec',
- example => 'blog/* and created_after(close_old_comments)',
- description => 'PageSpec for pages where new comments can be posted',
+ example => 'blog/controversial or blog/flamewar',
+ description => 'PageSpec of pages where posting new comments is not allowed',
link => 'ikiwiki/PageSpec',
safe => 1,
rebuild => 1,
@@ -87,10 +85,10 @@ sub getsetup () {
sub checkconfig () {
$config{comments_commit} = 1
unless defined $config{comments_commit};
- $config{comments_shown_pagespec} = ''
- unless defined $config{comments_shown_pagespec};
- $config{comments_open_pagespec} = ''
- unless defined $config{comments_open_pagespec};
+ $config{comments_pagespec} = ''
+ unless defined $config{comments_pagespec};
+ $config{comments_closed_pagespec} = ''
+ unless defined $config{comments_closed_pagespec};
$config{comments_pagename} = 'comment_'
unless defined $config{comments_pagename};
}
@@ -371,7 +369,7 @@ sub sessioncgi ($$) {
$page));
}
- if (not pagespec_match($page, $config{comments_open_pagespec},
+ if (pagespec_match($page, $config{comments_closed_pagespec},
location => $page)) {
error(sprintf(gettext(
"comments on page '%s' are closed"),
@@ -523,22 +521,21 @@ sub pagetemplate (@) {
my $comments = undef;
my $open = 0;
- my $shown = pagespec_match($page,
- $config{comments_shown_pagespec},
- location => $page);
+ my $shown = 0;
+ if (pagespec_match($page,
+ $config{comments_pagespec},
+ location => $page)) {
+ $shown = 1;
+ $open = length $config{cgiurl} > 0;
+ }
- if (pagespec_match($page, "*/$config{comments_pagename}*",
+ if (pagespec_match($page,
+ "$config{comments_closed_pagespec} or */$config{comments_pagename}*",
location => $page)) {
$shown = 0;
$open = 0;
}
- if (length $config{cgiurl}) {
- $open = pagespec_match($page,
- $config{comments_open_pagespec},
- location => $page);
- }
-
if ($shown) {
$comments = IkiWiki::preprocess_inline(
pages => "internal($page/$config{comments_pagename}*)",
diff --git a/doc/plugins/comments.mdwn b/doc/plugins/comments.mdwn
index a81cab127..afaf2c7ae 100644
--- a/doc/plugins/comments.mdwn
+++ b/doc/plugins/comments.mdwn
@@ -23,12 +23,13 @@ Individual comments are stored as internal-use pages named something like
There are some global options for the setup file:
-* `comments_open_pagespec`: pages where new comments can be posted, e.g.
- `blog/* and created_after(close_old_comments)` or `!*/discussion`.
- You need to set this, since the default is to not add comments to any
- pages.
-* `comments_shown_pagespec`: pages where comments will be displayed inline,
- e.g. `blog/*` or `!*/discussion`.
+* `comments_pagespec`: [[ikiwiki/PageSpec]] of pages where comments are
+ allowed. The default is not to allow comments on any pages. To allow
+ comments to all posts to a blog, you could use `blog/* and !*/Discussion`.
+* `comments_closed_pagespec`: [[ikiwiki/PageSpec]] of pages where
+ posting of new comments is closed, but any existing comments will still
+ be displayed. Often you will list a set of individual pages here.
+ For example: `blog/controversial or blog/flamewar`
* `comments_pagename`: if this is e.g. `comment_` (the default), then
comment pages will be named something like `page/comment_12`
* `comments_allowdirectives`: if true (default false), comments may