Permalink
Browse files

Item13898: fix foswiki.getScriptUrl for short urls

  • Loading branch information...
1 parent 7ebc93c commit ff2e27f64a85fae44abf5d7ad706d8bb9041e37e MichaelDaum committed with gac410 Jan 6, 2016
@@ -83,6 +83,12 @@ sub init {
Foswiki::Func::expandCommonVariables( '%' . $pref . '%' );
}
+ # add {ScriptUrlPaths}
+ if ( defined $Foswiki::cfg{ScriptUrlPaths} ) {
+ %{ $prefs{"SCRIPTURLPATHS"} } = %{ $Foswiki::cfg{ScriptUrlPaths} };
+ }
+ $prefs{"URLHOST"} = Foswiki::Func::getUrlHost();
+
my $text =
"<script class='\$zone \$id foswikiPreferences' type='text/json'>"
. JSON::to_json( \%prefs, { pretty => 1 } )
@@ -156,16 +156,20 @@ var foswiki = foswiki || {
* Get url path for a specific script
*/
function _getScriptUrl(absolute, script, web, topic, params) {
- var prefName = (absolute?"SCRIPTURL":"SCRIPTURLPATH"),
- suffix = foswiki.getPreference("SCRIPTSUFFIX") || "",
- url, arr = [];
+ var suffix = foswiki.getPreference("SCRIPTSUFFIX") || "",
+ scriptUrlPaths = foswiki.getPreference("SCRIPTURLPATHS"),
+ url = "", arr = [];
script = script || '';
- url = foswiki.getPreference(prefName+"_"+script.toUpperCase());
+ if (absolute) {
+ url = foswiki.getPreference("URLHOST");
+ }
- if (!url) {
- url = foswiki.getPreference(prefName) + "/" + script + suffix;
+ if (typeof(scriptUrlPaths[script]) === 'undefined') {
+ url += foswiki.getPreference("SCRIPTURLPATH") + "/" + script + suffix;
+ } else {
+ url += scriptUrlPaths[script];
}
if (typeof(web) !== 'undefined') {
@@ -184,6 +188,7 @@ var foswiki = foswiki || {
url += (arr.length?"?"+arr.join("&"):"");
}
+
return url;
}
@@ -236,7 +241,7 @@ var foswiki = foswiki || {
$('body').removeClass('foswikiNoJs').addClass("foswikiJs");
/* load foswiki preferences */
- $(".foswikiPreferences").each(function() {
+ $(".foswikiPreferences").livequery(function() {
$.extend(foswiki.preferences, $.parseJSON($(this).html()));
});

0 comments on commit ff2e27f

Please sign in to comment.