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.
master
Joey Hess 2008-12-17 18:50:04 -05:00
parent 9b837fd5ed
commit 140c0bacba
2 changed files with 27 additions and 29 deletions

View File

@ -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}*)",

View File

@ -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