From 0ced5995d531ed108a2eec8cee7a3586cd757add Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Dec 2008 15:05:26 -0500 Subject: get rid of the [postcomment] hack I think that using a flag variable is sorta cleaner. (This is untested.) --- IkiWiki/Plugin/comments.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 8d333f05f..0de7a6743 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; @@ -603,7 +609,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); -- cgit v1.2.3