]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
use page template directly
authorDavid Bremner <bremner@unb.ca>
Mon, 1 Sep 2008 23:46:00 +0000 (20:46 -0300)
committerDavid Bremner <bremner@unb.ca>
Tue, 2 Sep 2008 00:54:04 +0000 (21:54 -0300)
IkiWiki/Plugin/postal.pm
examples/page.tmpl

index 9f3f231cbd201be1572f23d206cc399e59e80c18..1c3e92f182907b31a25459be84843d50efd235b6 100644 (file)
 # 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;
@@ -44,34 +36,29 @@ sub pagetemplate (@)
     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);
+
+    debug("key=".$key);
 
+    my $subpage_name=$config{postal_pagename} || "comments";
 
-       my $content;
-       my $comment_page = bestlink ($page, "_comments") || return;
-       my $comment_file = $pagesources{$comment_page} || return;
+    my $comment_page=$destpage . "/" . $subpage_name;
 
-       $content = readfile (srcfile ($comment_file));
-       if (defined $content && length $content)
-       {
-           $content =~ s/%%KEY%%/$key/g;
-           $content =~ s/%%PAGE%%/$page/g;
+    my $comment_link=undef;
+    if (exists $pagesources{$comment_page}){
+       $comment_link=htmllink($page,$destpage,$comment_page,
+                              linktext=>gettext("Read Comments"));
+    }
 
-           debug("comment blurb: ". $content);
+    debug("comment_link=".$comment_link) if (defined($comment_link));
 
-    $template->param(POSTAL_COMMENTS=>1,
+    $template->param(POSTAL_DIV=>1,
                     POSTAL_PREFIX=>$config{postal_prefix},
                     POSTAL_KEY=>$key,
                     POSTAL_HOST=>$config{postal_host},
-                    POSTAL_COMMENT_LINK=>$comment_link );
+                    defined($comment_link) ? (POSTAL_COMMENT_LINK=>$comment_link) :());
 }
 
 
index 2df38c4b54c9e470a89319ab6cea3ced1df49397..805f6ca4ac623b9e7d6e75e76d5ddbac0ccc5bf5 100644 (file)
@@ -87,12 +87,12 @@ Links:
 </div>
 </TMPL_IF>
 
-<TMPL_IF POSTAL_COMMENTS>
+<TMPL_IF POSTAL_DIV>
 <div class="pagecomments">
 <a name="pagecomments"></a>
 <a href="mailto:<TMPL_VAR NAME="POSTAL_PREFIX"><TMPL_VAR NAME="POSTAL_KEY">@<TMPL_VAR NAME="POSTAL_HOST">">Send Comment</a>
-<TMPL_IF POSTAL_COMMENTS_LINK>
-  <a href="<TMPL_VAR NAME="POSTAL_COMMENTS_LINK">">Read Comments</a>
+<TMPL_IF POSTAL_COMMENT_LINK>
+<TMPL_VAR NAME="POSTAL_COMMENT_LINK">
 </TMPL_IF>
 </div>
 </TMPL_IF>