X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/4a6d5330e5b9554f1bd25b9025dd96200c6519c7..a0dbdcad77a97ab1219beeb8a92305538500ba3a:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index af7e7eccd..b244a7431 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -433,7 +433,8 @@ sub editcomment ($$) { $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n"; - my $editcontent = $form->field('editcontent') || ''; + my $editcontent = $form->field('editcontent'); + $editcontent="" if ! defined $editcontent; $editcontent =~ s/\r\n/\n/g; $editcontent =~ s/\r/\n/g; $editcontent =~ s/"/\\"/g; @@ -742,7 +743,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 +860,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 +909,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 +926,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"); }