]> sipb.mit.edu Git - ikiwiki.git/commitdiff
change around comments pagespecs
authorJoey Hess <joey@gnu.kitenet.net>
Wed, 17 Dec 2008 23:50:04 +0000 (18:50 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Wed, 17 Dec 2008 23:50:04 +0000 (18:50 -0500)
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.

IkiWiki/Plugin/comments.pm
doc/plugins/comments.mdwn

index 83f67869c06b6d68b58050373ea3e26b9dd9aa00..6e257d1d9b2d21d3da582639c07f5845d09f7fea 100644 (file)
@@ -34,20 +34,18 @@ sub getsetup () {
                        safe => 1,
                        rebuild => 1,
                },
                        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',
                        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,
                },
                        link => 'ikiwiki/PageSpec',
                        safe => 1,
                        rebuild => 1,
                },
-               comments_open_pagespec => {
+               comments_closed_pagespec => {
                        type => '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,
                        link => 'ikiwiki/PageSpec',
                        safe => 1,
                        rebuild => 1,
@@ -87,10 +85,10 @@ sub getsetup () {
 sub checkconfig () {
        $config{comments_commit} = 1
                unless defined $config{comments_commit};
 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};
 }
        $config{comments_pagename} = 'comment_'
                unless defined $config{comments_pagename};
 }
@@ -371,7 +369,7 @@ sub sessioncgi ($$) {
                        $page));
        }
 
                        $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"),
                location => $page)) {
                error(sprintf(gettext(
                        "comments on page '%s' are closed"),
@@ -523,22 +521,21 @@ sub pagetemplate (@) {
                my $comments = undef;
 
                my $open = 0;
                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;
                }
 
                                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}*)",
                if ($shown) {
                        $comments = IkiWiki::preprocess_inline(
                                pages => "internal($page/$config{comments_pagename}*)",
index a81cab127881d8c6c8ef25358fd60cf49c3937ca..afaf2c7ae66dfd60985590f4c5ee279f01e0c145 100644 (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:
 
 
 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
 * `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