aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/comments.pm42
1 files changed, 41 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 01ee481f5..33d8ca8e2 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -399,8 +399,48 @@ sub pagetemplate (@) { #{{{
if ($template->query(name => 'comments')) {
my $comments = undef;
+ my $comments_pagename = $config{comments_pagename};
+
+ my $open = 0;
+ my $shown = pagespec_match($page,
+ $config{comments_shown_pagespec},
+ location => $page);
+
+ if (pagespec_match($page, "*/${comments_pagename}*",
+ location => $page)) {
+ $shown = 0;
+ $open = 0;
+ }
+
+ if (length $config{cgiurl}) {
+ $open = pagespec_match($page,
+ $config{comments_open_pagespec},
+ location => $page);
+ }
+
+ if ($shown) {
+ eval q{use IkiWiki::Plugin::inline};
+ error($@) if $@;
+
+ my @args = (
+ pages => "internal($page/${comments_pagename}*)",
+ template => 'comments_display',
+ show => 0,
+ reverse => 'yes',
+ page => $page,
+ destpage => $params{destpage},
+ );
+ $comments = IkiWiki::preprocess_inline(@args);
+ }
+
if (defined $comments && length $comments) {
- $template->param(name => $comments);
+ $template->param(comments => $comments);
+ }
+
+ if ($open) {
+ my $commenturl = IkiWiki::cgiurl(do => 'comment',
+ page => $page);
+ $template->param(commenturl => $commenturl);
}
}
} # }}}