From: Joey Hess Date: Thu, 12 Aug 2010 21:19:20 +0000 (-0400) Subject: insert flattr javascript via sanitize, not format hook X-Git-Tag: 3.20100831~83 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3ef8864122c2e665d41ed4d45baa50d4a5d21873;p=ikiwiki.git insert flattr javascript via sanitize, not format hook This makes the javascript be added to rss feeds, which allows the buttons to be displayed by aggregators. At least, if the aggregator does not sanitize javascript. --- diff --git a/IkiWiki/Plugin/flattr.pm b/IkiWiki/Plugin/flattr.pm index 3aee1eb93..9cf9dfb13 100644 --- a/IkiWiki/Plugin/flattr.pm +++ b/IkiWiki/Plugin/flattr.pm @@ -8,7 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "flattr", call => \&getsetup); hook(type => "preprocess", id => "flattr", call => \&preprocess); - hook(type => "format", id => "flattr", call => \&format); + hook(type => "sanitize", id => "flattr", call => \&sanitize, last => 1); } sub getsetup () { @@ -54,17 +54,16 @@ sub preprocess (@) { ''; } -sub format (@) { +sub sanitize (@) { my %params=@_; # Add flattr's javascript to pages with flattr buttons. if ($flattr_pages{$params{page}}) { - if (! ($params{content}=~s!^(]*>)!$1.flattrjs()!em)) { - # no tag, probably in preview mode - $params{content}=flattrjs().$params{content}; - } + return flattrjs().$params{content}; + } + else { + return $params{content}; } - return $params{content}; } my $js_cached;