From: David Bremner Date: Fri, 20 Jun 2008 20:26:26 +0000 (+0200) Subject: initial key construction, example configs X-Git-Tag: 0.1~52 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c0f84bcd5713a9a74a051c442be9bbb6615d1165;p=ikiwiki.git initial key construction, example configs --- 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 @@ + +
+ + +
+
+