1 # A plugin for ikiwiki to implement adding a footer with a comment URL
2 # based on a template file and a key representing the current page
4 # Copyright © 2007 Thomas Schwinge <tschwinge@gnu.org>
5 # Copyright © 2008 David Bremner <bremner@unb.ca>
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2, or (at your option) any later
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 package IkiWiki::Plugin::postal;
26 use Convert::YText 'encode_ytext';
31 hook (type => "pagetemplate", id => "postal", call => \&pagetemplate);
37 my $page = IkiWiki::pagetitle($params{page});
38 my $destpage = $params{destpage};
39 my $template = $params{template};
41 my $key = encode_ytext($page);
43 my $pagespec=$config{postal_pagespec} || "!*/comments";
45 if (!pagespec_match($page,$pagespec)){
49 my $subpage_name=$config{postal_pagename} || "comments";
51 my $comment_page=$destpage . "/" . $subpage_name;
53 add_depends($params{page},$comment_page);
55 my $comment_link=undef;
56 if (exists $pagesources{$comment_page}){
57 $comment_link=htmllink($page,$destpage,$comment_page,
58 linktext=>gettext("Read Comments"));
61 debug("comment_link=".$comment_link) if (defined($comment_link));
63 $template->param(POSTAL_DIV=>1,
64 POSTAL_PREFIX=>$config{postal_prefix},
66 POSTAL_HOST=>$config{postal_host},
67 defined($comment_link) ? (POSTAL_COMMENT_LINK=>$comment_link) :());