X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/38c92e63bb012da98019faf9bc11037c5cbd5a99..18eeb068a6be7e45add2775a4014c85e3b41b465:/IkiWiki/Plugin/comments.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 8d333f05f..4999c3f24 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -15,6 +15,8 @@ use constant PREVIEW => "Preview"; use constant POST_COMMENT => "Post comment"; use constant CANCEL => "Cancel"; +my $postcomment; + sub import { #{{{ hook(type => "checkconfig", id => 'comments', call => \&checkconfig); hook(type => "getsetup", id => 'comments', call => \&getsetup); @@ -383,7 +385,11 @@ sub sessioncgi ($$) { #{{{ $page)); } - IkiWiki::check_canedit($page . "[postcomment]", $cgi, $session); + # Set a flag to indicate that we're posting a comment, + # so that postcomment() can tell it should match. + $postcomment=1; + IkiWiki::check_canedit($page, $cgi, $session); + $postcomment=0; my $editcontent = $form->field('editcontent') || ''; $editcontent =~ s/\r\n/\n/g; @@ -549,10 +555,7 @@ sub pagetemplate (@) { #{{{ } if ($shown) { - eval q{use IkiWiki::Plugin::inline}; - error($@) if $@; - - my @args = ( + $comments = IkiWiki::preprocess_inline( pages => "internal($page/${comments_pagename}*)", template => 'comments_display', show => 0, @@ -562,7 +565,6 @@ sub pagetemplate (@) { #{{{ feedfile => 'comments', emptyfeeds => 'no', ); - $comments = IkiWiki::preprocess_inline(@args); } if (defined $comments && length $comments) { @@ -603,7 +605,7 @@ sub match_postcomment ($$;@) { my $page = shift; my $glob = shift; - unless ($page =~ s/\[postcomment\]$//) { + if (! $postcomment) { return IkiWiki::FailReason->new("not posting a comment"); } return match_glob($page, $glob);