get rid of the [postcomment] hack

I think that using a flag variable is sorta cleaner.

(This is untested.)
master
Joey Hess 2008-12-12 15:05:26 -05:00
parent e9797ee086
commit 0ced5995d5
1 changed files with 8 additions and 2 deletions

View File

@ -15,6 +15,8 @@ use constant PREVIEW => "Preview";
use constant POST_COMMENT => "Post comment"; use constant POST_COMMENT => "Post comment";
use constant CANCEL => "Cancel"; use constant CANCEL => "Cancel";
my $postcomment;
sub import { #{{{ sub import { #{{{
hook(type => "checkconfig", id => 'comments', call => \&checkconfig); hook(type => "checkconfig", id => 'comments', call => \&checkconfig);
hook(type => "getsetup", id => 'comments', call => \&getsetup); hook(type => "getsetup", id => 'comments', call => \&getsetup);
@ -383,7 +385,11 @@ sub sessioncgi ($$) { #{{{
$page)); $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') || ''; my $editcontent = $form->field('editcontent') || '';
$editcontent =~ s/\r\n/\n/g; $editcontent =~ s/\r\n/\n/g;
@ -603,7 +609,7 @@ sub match_postcomment ($$;@) {
my $page = shift; my $page = shift;
my $glob = shift; my $glob = shift;
unless ($page =~ s/\[postcomment\]$//) { if (! $postcomment) {
return IkiWiki::FailReason->new("not posting a comment"); return IkiWiki::FailReason->new("not posting a comment");
} }
return match_glob($page, $glob); return match_glob($page, $glob);