aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-08-12 17:19:20 -0400
committerJoey Hess <joey@kitenet.net>2010-08-12 17:19:20 -0400
commit3ef8864122c2e665d41ed4d45baa50d4a5d21873 (patch)
tree554935f3dc8fff3f2ccd19e61dd8fed0fcf30fc5 /IkiWiki/Plugin
parent0099a9df8b2154d0b9ba62f6da4cd4bc926d1164 (diff)
downloadikiwiki-3ef8864122c2e665d41ed4d45baa50d4a5d21873.tar
ikiwiki-3ef8864122c2e665d41ed4d45baa50d4a5d21873.tar.gz
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.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/flattr.pm13
1 files changed, 6 insertions, 7 deletions
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 (@) {
'</a>';
}
-sub format (@) {
+sub sanitize (@) {
my %params=@_;
# Add flattr's javascript to pages with flattr buttons.
if ($flattr_pages{$params{page}}) {
- if (! ($params{content}=~s!^(<body[^>]*>)!$1.flattrjs()!em)) {
- # no <body> tag, probably in preview mode
- $params{content}=flattrjs().$params{content};
- }
+ return flattrjs().$params{content};
+ }
+ else {
+ return $params{content};
}
- return $params{content};
}
my $js_cached;