X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/bb93fccf0690344aa77f9538a508959a6de09847..140c0bacbadc35de93cc685313123e9e51b45704:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 6184c6031..6e257d1d9 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -34,29 +34,24 @@ 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/*', - default => '', - 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)', - default => '', - 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, }, comments_pagename => { type => 'string', - example => 'comment_', default => 'comment_', description => 'Base name for comments, e.g. "comment_" for pages like "sandbox/comment_12"', safe => 0, # manual page moving required @@ -64,7 +59,6 @@ sub getsetup () { }, comments_allowdirectives => { type => 'boolean', - default => 0, example => 0, description => 'Interpret directives in comments?', safe => 1, @@ -72,7 +66,6 @@ sub getsetup () { }, comments_allowauthor => { type => 'boolean', - default => 0, example => 0, description => 'Allow anonymous commenters to set an author name?', safe => 1, @@ -81,7 +74,6 @@ sub getsetup () { comments_commit => { type => 'boolean', example => 1, - default => 1, description => 'commit comments to the VCS', # old uncommitted comments are likely to cause # confusion if this is changed @@ -90,6 +82,17 @@ sub getsetup () { }, } +sub checkconfig () { + $config{comments_commit} = 1 + unless defined $config{comments_commit}; + $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}; +} + sub htmlize { my %params = @_; return $params{content}; @@ -208,12 +211,6 @@ sub preprocess { return $content; } -sub checkconfig () { - $config{comments_commit} = 1 unless defined $config{comments_commit}; - $config{comments_pagename} = 'comment_' - unless defined $config{comments_pagename}; -} - # This is exactly the same as recentchanges_link :-( sub linkcgi ($) { my $cgi=shift; @@ -372,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"), @@ -524,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}*)",