# based on a template file and a key representing the current page
# Copyright © 2007 Thomas Schwinge <tschwinge@gnu.org>
-# Copyright © 2008 David Bremner <tschwinge@gnu.org>
+# Copyright © 2008 David Bremner <bremner@unb.ca>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\f
-# A footer with comment information will be added to every rendered page
-# a file `comments.html' or 'comments.mdwn' is found (using the
-# same rules as for the sidebar plugin).
-
-# You'll need a full wiki-rebuild if your comment header file is changed.
-#
-# You can use wiki links in `comments.html'.
-\f
package IkiWiki::Plugin::postal;
use warnings;
my %params = @_;
my $page = IkiWiki::pagetitle($params{page});
my $destpage = $params{destpage};
-
my $template = $params{template};
- if ($template->query (name => "comments") &&
- ! defined $template->param ('comments'))
- {
- debug("adding comments to ".$page);
- my $key = encode_ytext($page);
- debug("using key ".$key);
+ my $key = encode_ytext($page);
+ my $pagespec=$config{postal_pagespec} || "!*/comments";
- my $content;
- my $comment_page = bestlink ($page, "comments") || return;
- my $comment_file = $pagesources{$comment_page} || return;
+ if (!pagespec_match($page,$pagespec)){
+ return;
+ }
- $content = readfile (srcfile ($comment_file));
- if (defined $content && length $content)
- {
- $content =~ s/%%KEY%%/$key/g;
- $content =~ s/%%PAGE%%/$page/g;
+ my $subpage_name=$config{postal_pagename} || "comments";
- debug("comment blurb: ". $content);
+ my $comment_page=$destpage . "/" . $subpage_name;
- $template->param (comments =>
- IkiWiki::linkify ($page, $destpage, $content))
- }
+ my $comment_link=undef;
+ if (exists $pagesources{$comment_page}){
+ $comment_link=htmllink($page,$destpage,$comment_page,
+ linktext=>gettext("Read Comments"));
}
+
+ debug("comment_link=".$comment_link) if (defined($comment_link));
+
+ $template->param(POSTAL_DIV=>1,
+ POSTAL_PREFIX=>$config{postal_prefix},
+ POSTAL_KEY=>$key,
+ POSTAL_HOST=>$config{postal_host},
+ defined($comment_link) ? (POSTAL_COMMENT_LINK=>$comment_link) :());
}