From c0f84bcd5713a9a74a051c442be9bbb6615d1165 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 20 Jun 2008 22:26:26 +0200 Subject: [PATCH] initial key construction, example configs --- IkiWiki/Plugin/postal.pm | 15 ++++++++++++--- examples/comments.mdwn | 3 +++ examples/page.tmpl.snippet | 7 +++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 examples/comments.mdwn create mode 100644 examples/page.tmpl.snippet diff --git a/IkiWiki/Plugin/postal.pm b/IkiWiki/Plugin/postal.pm index e5915afe8..57f879148 100644 --- a/IkiWiki/Plugin/postal.pm +++ b/IkiWiki/Plugin/postal.pm @@ -31,6 +31,9 @@ package IkiWiki::Plugin::postal; use warnings; use strict; use IkiWiki 2.00; +use Compress::LZF ; +use MIME::Base64::URLSafe; + sub import { @@ -48,17 +51,23 @@ sub pagetemplate (@) if ($template->query (name => "comments") && ! defined $template->param ('comments')) { - debug('got template'); + debug("adding comments to ".$page); + my $key = urlsafe_b64encode(compress($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) { - debug('got comment file'); + $content =~ s/%%KEY%%/$key/g; + + debug("comment blurb: ". $content); + $template->param (comments => IkiWiki::linkify ($page, $destpage, $content)) } diff --git a/examples/comments.mdwn b/examples/comments.mdwn new file mode 100644 index 000000000..65435eacd --- /dev/null +++ b/examples/comments.mdwn @@ -0,0 +1,3 @@ +Send Comment + +[[Read Comments|comments/%%KEY%%]] diff --git a/examples/page.tmpl.snippet b/examples/page.tmpl.snippet new file mode 100644 index 000000000..fd410ddfb --- /dev/null +++ b/examples/page.tmpl.snippet @@ -0,0 +1,7 @@ + +
+ + +
+
+ -- 2.26.2