Merge "Rename addInterwiki to setInterwiki and add removeInterwiki complement"

This commit is contained in:
Catrope 2012-07-20 22:41:05 +00:00 committed by Gerrit Code Review
commit 6ca1b06641
2 changed files with 7 additions and 3 deletions

View file

@ -8,7 +8,7 @@
* @example * @example
* exports.setup = function( config, env ) { * exports.setup = function( config, env ) {
* config.defaultInterwiki = 'localhost'; * config.defaultInterwiki = 'localhost';
* env.addInterwiki( 'localhost', 'http://localhost/mediawiki' ); * env.setInterwiki( 'localhost', 'http://localhost/mediawiki' );
* }; * };
*/ */
@ -61,7 +61,7 @@ var env = new ParserEnv( {
} ); } );
// add mediawiki.org // add mediawiki.org
env.addInterwiki( 'mw', 'http://www.mediawiki.org/w' ); env.setInterwiki( 'mw', 'http://www.mediawiki.org/w' );
// add localhost default // add localhost default
env.addInterwiki( 'localhost', 'http://localhost/w' ); env.addInterwiki( 'localhost', 'http://localhost/w' );

View file

@ -31,10 +31,14 @@ var MWParserEnvironment = function(opts) {
$.extend(this, options); $.extend(this, options);
}; };
MWParserEnvironment.prototype.addInterwiki = function (prefix, wgScript) { MWParserEnvironment.prototype.setInterwiki = function (prefix, wgScript) {
this.interwikiMap[prefix] = wgScript; this.interwikiMap[prefix] = wgScript;
this.interwikiRegexp = Object.keys(this.interwikiMap).join('|'); this.interwikiRegexp = Object.keys(this.interwikiMap).join('|');
}; };
MWParserEnvironment.prototype.removeInterwiki = function (prefix) {
delete this.interwikiMap[prefix];
this.interwikiRegexp = Object.keys(this.interwikiMap).join('|');
};
// Outstanding page requests (for templates etc) // Outstanding page requests (for templates etc)
// Class-static // Class-static