r54071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54070‎ | r54071 | r54072 >
Date:05:23, 31 July 2009
Author:dale
Status:resolved (Comments)
Tags:
Comment:
get local api url function abstraction
Modified paths:
  • /trunk/phase3/js2/mwEmbed/mv_embed.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/mv_embed.js
@@ -1080,11 +1080,9 @@
10811081 if( typeof options.url == 'undefined' || options.url === false){
10821082 if(!wgServer || ! wgScriptPath){
10831083 return js_error('Error: no api url for api request');;
1084 - }
1085 - if (wgServer && wgScript)
1086 - options.url = wgServer + wgScript;
 1084+ }
10871085 //update to api.php (if index.php was in the wgScript path):
1088 - options.url = options.url.replace(/index.php/, 'api.php');
 1086+ options.url = mwGetLocalApiUrl();
10891087 }
10901088 if( typeof options.data == 'undefined' )
10911089 options.data = {};
@@ -1131,6 +1129,13 @@
11321130 loadExternalJs( req_url );
11331131 }
11341132 }
 1133+function mwGetLocalApiUrl(url){
 1134+ if (wgServer && wgScript){
 1135+ url = wgServer + wgScript;
 1136+ return url.replace(/index.php/, 'api.php');
 1137+ }
 1138+ return false;
 1139+}
11351140 //grab wiki form error for wiki html page proccessing (should be depricated)
11361141 function grabWikiFormError ( result_page ){
11371142 var res = {};

Comments

#Comment by Umherirrender (talk | contribs)   08:00, 31 July 2009

That fail on wikis with short 'index.php' like translatewiki.net (it used 'i.php'). Use '{{SERVER}}{{SCRIPTPATH}}/api.php' it is always right (//www.mediawiki.org/w/api.php)

#Comment by Mdale (talk | contribs)   08:23, 31 July 2009

hmm...how about r54077 return wgServer + wgScriptPath + '/api.php';

Status & tagging log