X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/fd2b2f386f30cf2ba578da8a8174dd60ae024adc..296e5cb2fd3690e998b3824d54d317933c595873:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 851f4862e..00945b753 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -301,7 +301,7 @@ sub editcomment ($$) { required => [qw{editcontent}], javascript => 0, params => $cgi, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), header => 0, table => 0, template => { template('editcomment.tmpl') }, @@ -386,7 +386,7 @@ sub editcomment ($$) { if ($form->submitted eq CANCEL) { # bounce back to the page they wanted to comment on, and exit. # CANCEL need not be considered in future - IkiWiki::redirect($cgi, urlto($page, undef, 1)); + IkiWiki::redirect($cgi, urlto($page, undef)); exit; } @@ -552,7 +552,7 @@ sub editcomment ($$) { # Jump to the new comment on the page. # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - IkiWiki::redirect($cgi, urlto($page, undef, 1). + IkiWiki::redirect($cgi, urlto($page, undef). "?updated#".page_to_id($location)); } @@ -727,6 +727,10 @@ sub previewcomment ($$$) { my $page=shift; my $time=shift; + # Previewing a comment should implicitly enable comment posting mode. + my $oldpostcomment=$postcomment; + $postcomment=1; + my $preview = IkiWiki::htmlize($location, $page, '_comment', IkiWiki::linkify($location, $page, IkiWiki::preprocess($location, $page, @@ -745,6 +749,8 @@ sub previewcomment ($$$) { $template->param(have_actions => 0); + $postcomment=$oldpostcomment; + return $template->output; } @@ -941,14 +947,16 @@ sub match_comment ($$;@) { my $page = shift; my $glob = shift; - # 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"); + if (! $postcomment) { + # 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"); + } } return match_glob($page, "$glob/*", internal => 1, @_);