]> scripts.mit.edu Git - www/ikiwiki.git/blobdiff - IkiWiki/Plugin/comments.pm
isabug
[www/ikiwiki.git] / IkiWiki / Plugin / comments.pm
index af7e7eccd89603430c7b0f4d5cee65b07c4ae02f..86b60a2b2864037ac4644fed9e0d64d5fecd3812 100644 (file)
@@ -742,7 +742,6 @@ sub pagetemplate (@) {
                     $template->query(name => 'commentsurl') ||
                     $template->query(name => 'atomcommentsurl') ||
                     $template->query(name => 'comments')) &&
-                   length $page && # not dynamic
                    commentsshown($page);
 
        if ($template->query(name => 'comments')) {
@@ -860,7 +859,7 @@ sub num_comments ($$) {
        my $dir=shift;
 
        my @comments=glob("$dir/$page/$config{comments_pagename}*._comment");
-       return @comments;
+       return int @comments;
 }
 
 sub unique_comment_location ($$$$) {
@@ -909,11 +908,13 @@ sub match_comment ($$;@) {
        my $page = shift;
        my $glob = shift;
 
-       if (! IkiWiki::isinternal($page)) {
-               return IkiWiki::FailReason->new("$page is not a comment");
-       }
-       my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page});
-       if (defined $type && $type ne "_comment") {
+       # To see if it's a comment, check the source file type.
+       # Deal with comments that were just deleted.
+       my $source=exists $IkiWiki::pagesources{$page} ?
+               $IkiWiki::pagesources{$page} :
+               $IkiWiki::delpagesources{$page};
+       my $type=defined $source ? IkiWiki::pagetype($source) : undef;
+       if (! defined $type || $type ne "_comment") {
                return IkiWiki::FailReason->new("$page is not a comment");
        }
 
@@ -924,11 +925,11 @@ sub match_comment_pending ($$;@) {
        my $page = shift;
        my $glob = shift;
        
-       if (! IkiWiki::isinternal($page)) {
-               return IkiWiki::FailReason->new("$page is not a pending comment");
-       }
-       my $type=IkiWiki::pagetype($IkiWiki::pagesources{$page});
-       if (defined $type && $type ne "_comment_pending") {
+       my $source=exists $IkiWiki::pagesources{$page} ?
+               $IkiWiki::pagesources{$page} :
+               $IkiWiki::delpagesources{$page};
+       my $type=defined $source ? IkiWiki::pagetype($source) : undef;
+       if (! defined $type || $type ne "_comment_pending") {
                return IkiWiki::FailReason->new("$page is not a pending comment");
        }