2 package IkiWiki::Plugin::relativedate;
9 add_underlay("javascript");
10 hook(type => "getsetup", id => "relativedate", call => \&getsetup);
11 hook(type => "format", id => "relativedate", call => \&format);
14 sub getsetup () { #{{{
25 if (! ($params{content}=~s!^(<body>)!$1.include_javascript($params{page})!em)) {
26 # no </body> tag, probably in preview mode
27 $params{content}=include_javascript($params{page}, 1).$params{content};
29 return $params{content};
32 sub include_javascript ($;$) { #{{{
36 return '<script src="'.urlto("ikiwiki.js", $page, $absolute).
37 '" type="text/javascript" charset="utf-8"></script>'."\n".
38 '<script src="'.urlto("relativedate.js", $page, $absolute).
39 '" type="text/javascript" charset="utf-8"></script>';