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