diff options
author | Joey Hess <joey@kitenet.net> | 2010-08-12 18:18:35 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-08-12 18:18:35 -0400 |
commit | efd8e93c5be79b1df0b92b2b5aee91308e4343dc (patch) | |
tree | 0a0f9a5aa0d6919aa57ec6f26191b381ee588d30 /IkiWiki/Plugin/flattr.pm | |
parent | 3ef8864122c2e665d41ed4d45baa50d4a5d21873 (diff) | |
download | ikiwiki-efd8e93c5be79b1df0b92b2b5aee91308e4343dc.tar ikiwiki-efd8e93c5be79b1df0b92b2b5aee91308e4343dc.tar.gz |
Revert "insert flattr javascript via sanitize, not format hook"
This reverts commit 3ef8864122c2e665d41ed4d45baa50d4a5d21873.
Most aggregators block javascript and so it would display uglily.
Need to find a way to fallback to static buttons instead.
Diffstat (limited to 'IkiWiki/Plugin/flattr.pm')
-rw-r--r-- | IkiWiki/Plugin/flattr.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/flattr.pm b/IkiWiki/Plugin/flattr.pm index 9cf9dfb13..3aee1eb93 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 => "sanitize", id => "flattr", call => \&sanitize, last => 1); + hook(type => "format", id => "flattr", call => \&format); } sub getsetup () { @@ -54,16 +54,17 @@ sub preprocess (@) { '</a>'; } -sub sanitize (@) { +sub format (@) { my %params=@_; # Add flattr's javascript to pages with flattr buttons. if ($flattr_pages{$params{page}}) { - return flattrjs().$params{content}; - } - else { - return $params{content}; + if (! ($params{content}=~s!^(<body[^>]*>)!$1.flattrjs()!em)) { + # no <body> tag, probably in preview mode + $params{content}=flattrjs().$params{content}; + } } + return $params{content}; } my $js_cached; |