From 99fc189596aaf4bb605b39033a6bff88e02a2198 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Tue, 1 Jul 2008 10:53:40 +0200 Subject: [PATCH] make postal.pm use Convert::YText --- Convert/YText.pm | 2 +- IkiWiki/Plugin/postal.pm | 27 +++++++-------------------- examples/comments.mdwn | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Convert/YText.pm b/Convert/YText.pm index a2b2193f3..bdd155bbf 100644 --- a/Convert/YText.pm +++ b/Convert/YText.pm @@ -64,7 +64,7 @@ sub encode_num($){ my $str=""; while ($num>0){ - $remainder=$num % 64; + my $remainder=$num % 64; $num=$num >> 6; $str = $digits[$remainder].$str; diff --git a/IkiWiki/Plugin/postal.pm b/IkiWiki/Plugin/postal.pm index bc3410280..828786928 100644 --- a/IkiWiki/Plugin/postal.pm +++ b/IkiWiki/Plugin/postal.pm @@ -1,8 +1,8 @@ # A plugin for ikiwiki to implement adding a footer with a comment URL # based on a template file and a key representing the current page -# Copyright © 2007 Thomas Schwinge -# Copyright © 2008 David Bremner +# Copyright © 2007 Thomas Schwinge +# Copyright © 2008 David Bremner # # 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 @@ -31,7 +31,7 @@ package IkiWiki::Plugin::postal; use warnings; use strict; use IkiWiki 2.00; - +use Convert::YText 'encode_ytext'; sub import @@ -51,40 +51,27 @@ sub pagetemplate (@) ! defined $template->param ('comments')) { debug("adding comments to ".$page); - my $key = uri_escape_utf8($page); + my $key = encode_ytext($page); debug("using key ".$key); my $content; my $comment_page = bestlink ($page, "comments") || return; my $comment_file = $pagesources{$comment_page} || return; - #my $pagetype = pagetype ($comment_file); - # Check if ``$pagetype eq 'html'''? + $content = readfile (srcfile ($comment_file)); if (defined $content && length $content) { $content =~ s/%%KEY%%/$key/g; + $content =~ s/%%PAGE%%/$page/g; debug("comment blurb: ". $content); $template->param (comments => - IkiWiki::linkify ($page, $destpage, $content)) + IkiWiki::linkify ($page, $destpage, $content)) } } } - -sub strict_rfc2822_escape($){ -# according to rfc 2822, the following non-alphanumerics are OK for -# the local part of an address: "!#$%&'*+-/=?^_`{|}~". On the other -# hand, a fairly common exim configuration, for example, blocks -# addresses having "@%!/|`#&?" in the local part. '+' and '-' are -# pretty widely used to attach suffixes (although usually only one -# works on a given mail host). - my $str=shift; - - $str=s/[^a-zA-Z0-9+\-~_]/= ord($1)/; - -}; 1; diff --git a/examples/comments.mdwn b/examples/comments.mdwn index 9098179ad..f73cd1e76 100644 --- a/examples/comments.mdwn +++ b/examples/comments.mdwn @@ -1,3 +1,3 @@ Send Comment -[[Read Comments|comments/%%KEY%%]] +[[Read Comments|%%PAGE%%/comments]] -- 2.26.2