hook(type => "preprocess", id => 'comments', call => \&preprocess);
hook(type => "sessioncgi", id => 'comment', call => \&sessioncgi);
hook(type => "htmlize", id => "_comment", call => \&htmlize);
+ hook(type => "pagetemplate", id => "comments", call => \&pagetemplate);
IkiWiki::loadplugin("inline");
IkiWiki::loadplugin("mdwn");
} # }}}
sub preprocess (@) { #{{{
my %params=@_;
- unless (length $config{cgiurl}) {
- error(gettext("[[!comments plugin requires CGI enabled]]"));
- }
+ return "";
my $page = $params{page};
$pagestate{$page}{comments}{comments} = defined $params{closed}
debug("page $params{page} => destpage $params{destpage}");
- my $posts = '';
unless (defined $params{inline} && !IkiWiki::yesno($params{inline})) {
+ my $posts = '';
eval q{use IkiWiki::Plugin::inline};
error($@) if ($@);
my @args = (
push @args, feedshow => $params{feedshow} if defined $params{feedshow};
push @args, timeformat => $params{timeformat} if defined $params{timeformat};
push @args, feedonly => $params{feedonly} if defined $params{feedonly};
- $posts = "\n" . IkiWiki::preprocess_inline(@args);
+ $posts = IkiWiki::preprocess_inline(@args);
+ $formtemplate->param("comments" => $posts);
}
- return $formtemplate->output . $posts;
+ return $formtemplate->output;
} # }}}
# FIXME: logic taken from editpage, should be common code?
} # }}}
# FIXME: logic adapted from recentchanges, should be common code?
+# returns (author URL, pretty-printed version)
sub linkuser ($) { # {{{
my $user = shift;
my $oiduser = eval { IkiWiki::openiduser($user) };
unless ($allow_directives) {
# don't allow new-style directives at all
- $body =~ s/(^|[^\\])\[\[!/$1\\[[!/g;
+ $body =~ s/(^|[^\\])\[\[!/$1[[!/g;
# don't allow [[ unless it begins an old-style
# wikilink, if prefix_directives is off
- $body =~ s/(^|[^\\])\[\[(?![^\n\s\]+]\]\])/$1\\[[!/g
+ $body =~ s/(^|[^\\])\[\[(?![^\n\s\]+]\]\])/$1[[!/g
unless $config{prefix_directives};
}
exit;
} #}}}
+sub pagetemplate (@) { #{{{
+ my %params = @_;
+
+ my $page = $params{page};
+ my $template = $params{template};
+
+ if ($template->query(name => 'comments')) {
+ my $comments = undef;
+
+ if (defined $comments && length $comments) {
+ $template->param(name => $comments);
+ }
+ }
+} # }}}
+
package IkiWiki::PageSpec;
sub match_postcomment ($$;@) {