diff options
author | Antoine Beaupré <anarcat@koumbit.org> | 2012-07-19 10:32:02 -0400 |
---|---|---|
committer | Antoine Beaupré <anarcat@koumbit.org> | 2012-07-19 10:32:02 -0400 |
commit | c42f992dc9a7d5962a0a98f734f5fa39d63349a6 (patch) | |
tree | 3dc832208fefe4465f6536a732608a76a2e42591 | |
parent | 12fa9c031f7a9dc25dba628aa91fc347586e4ab6 (diff) | |
download | ikiwiki-c42f992dc9a7d5962a0a98f734f5fa39d63349a6.tar ikiwiki-c42f992dc9a7d5962a0a98f734f5fa39d63349a6.tar.gz |
include manually the toggle js code
-rw-r--r-- | IkiWiki/Plugin/recentchangesdiff.pm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/recentchangesdiff.pm b/IkiWiki/Plugin/recentchangesdiff.pm index 418822793..eb358be67 100644 --- a/IkiWiki/Plugin/recentchangesdiff.pm +++ b/IkiWiki/Plugin/recentchangesdiff.pm @@ -9,10 +9,12 @@ use HTML::Entities; my $maxlines=200; sub import { + add_underlay("javascript"); hook(type => "getsetup", id => "recentchangesdiff", call => \&getsetup); hook(type => "pagetemplate", id => "recentchangesdiff", call => \&pagetemplate); + hook(type => "format", id => "recentchangesdiff.pm", call => \&format); } sub getsetup () { @@ -55,4 +57,24 @@ sub pagetemplate (@) { } } +sub format (@) { + my %params=@_; + + if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) { + # no <body> tag, probably in preview mode + $params{content}=include_javascript(undef).$params{content}; + } + return $params{content}; +} + +# taken verbatim from toggle.pm +sub include_javascript ($) { + my $from=shift; + + return '<script src="'.urlto("ikiwiki/ikiwiki.js", $from). + '" type="text/javascript" charset="utf-8"></script>'."\n". + '<script src="'.urlto("ikiwiki/toggle.js", $from). + '" type="text/javascript" charset="utf-8"></script>'; +} + 1 |