]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/comments.pm
avoid unnecessary variable
[git.ikiwiki.info.git] / IkiWiki / Plugin / comments.pm
index 8d333f05f9afa6ded382589489019b9231fdad04..f612f89475dd6450c8128b3a974c6c60bddc1936 100644 (file)
@@ -15,6 +15,8 @@ use constant PREVIEW => "Preview";
 use constant POST_COMMENT => "Post comment";
 use constant CANCEL => "Cancel";
 
 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);
 sub import { #{{{
        hook(type => "checkconfig", id => 'comments',  call => \&checkconfig);
        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') || '';
        $editcontent =~ s/\r\n/\n/g;
 
        my $editcontent = $form->field('editcontent') || '';
        $editcontent =~ s/\r\n/\n/g;
@@ -552,7 +558,7 @@ sub pagetemplate (@) { #{{{
                        eval q{use IkiWiki::Plugin::inline};
                        error($@) if $@;
 
                        eval q{use IkiWiki::Plugin::inline};
                        error($@) if $@;
 
-                       my @args = (
+                       $comments = IkiWiki::preprocess_inline(
                                pages => "internal($page/${comments_pagename}*)",
                                template => 'comments_display',
                                show => 0,
                                pages => "internal($page/${comments_pagename}*)",
                                template => 'comments_display',
                                show => 0,
@@ -562,7 +568,6 @@ sub pagetemplate (@) { #{{{
                                feedfile => 'comments',
                                emptyfeeds => 'no',
                        );
                                feedfile => 'comments',
                                emptyfeeds => 'no',
                        );
-                       $comments = IkiWiki::preprocess_inline(@args);
                }
 
                if (defined $comments && length $comments) {
                }
 
                if (defined $comments && length $comments) {
@@ -603,7 +608,7 @@ sub match_postcomment ($$;@) {
        my $page = shift;
        my $glob = shift;
 
        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);
                return IkiWiki::FailReason->new("not posting a comment");
        }
        return match_glob($page, $glob);