Use local paths when including Javascript

master
Simon McVittie 2010-11-23 00:06:07 +00:00
parent d2e3741a6f
commit 78c595736e
3 changed files with 14 additions and 17 deletions

View File

@ -28,18 +28,17 @@ sub format (@) {
if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) {
# no <body> tag, probably in preview mode
$params{content}=include_javascript($params{page}, 1).$params{content};
$params{content}=include_javascript(undef).$params{content};
}
return $params{content};
}
sub include_javascript ($;$) {
my $page=shift;
my $absolute=shift;
sub include_javascript ($) {
my $from=shift;
return '<script src="'.urlto("ikiwiki/ikiwiki.js", $page, $absolute).
return '<script src="'.urlto("ikiwiki/ikiwiki.js", $from).
'" type="text/javascript" charset="utf-8"></script>'."\n".
'<script src="'.urlto("ikiwiki/relativedate.js", $page, $absolute).
'<script src="'.urlto("ikiwiki/relativedate.js", $from).
'" type="text/javascript" charset="utf-8"></script>';
}

View File

@ -70,19 +70,18 @@ sub format (@) {
$params{content}=~s/<div class="toggleableend">//g;
if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) {
# no <body> tag, probably in preview mode
$params{content}=include_javascript($params{page}, 1).$params{content};
$params{content}=include_javascript(undef).$params{content};
}
}
return $params{content};
}
sub include_javascript ($;$) {
my $page=shift;
my $absolute=shift;
sub include_javascript ($) {
my $from=shift;
return '<script src="'.urlto("ikiwiki/ikiwiki.js", $page, $absolute).
return '<script src="'.urlto("ikiwiki/ikiwiki.js", $from).
'" type="text/javascript" charset="utf-8"></script>'."\n".
'<script src="'.urlto("ikiwiki/toggle.js", $page, $absolute).
'<script src="'.urlto("ikiwiki/toggle.js", $from).
'" type="text/javascript" charset="utf-8"></script>';
}

View File

@ -31,14 +31,13 @@ sub formbuilder_setup (@) {
$form->field("do") eq "comment";
$form->tmpl_param("wmd_preview", "<div class=\"wmd-preview\"></div>\n".
include_javascript(undef, 1));
include_javascript(undef));
}
sub include_javascript ($;$) {
my $page=shift;
my $absolute=shift;
sub include_javascript ($) {
my $from=shift;
my $wmdjs=urlto("wmd/wmd.js", $page, $absolute);
my $wmdjs=urlto("wmd/wmd.js", $from);
return <<"EOF"
<script type="text/javascript">
wmd_options = {