summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2008-11-23 17:11:14 +0000
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2008-12-11 21:14:04 +0000
commit4ff161ba0b4b2fbb027ee2077330c08bd3a38073 (patch)
tree4f7136249e3cd7b4597b9d81105703875d5e2664 /IkiWiki/Plugin
parent49eabc676a170bfbd31ee51c27e02c20355554dc (diff)
comments: render comments/commenturl in page.tmpl
Diffstat (limited to 'IkiWiki/Plugin')
-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);
}
}
} # }}}