Permalink
Browse files

Item13898: fix foswiki.getScriptUrl for short urls

  • Loading branch information...
1 parent daf3a04 commit 9e87a977ea13f5667bab0a19b0a12214f689ce7f MichaelDaum committed Jan 6, 2016
@@ -89,6 +89,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 9e87a97

Please sign in to comment.