jenkins-bot has submitted this change and it was merged. Change subject: Default to the correct main page ......................................................................
Default to the correct main page * Ex. https://als.wikiquote.org/wiki/Houptsyte https://pl.wikipedia.org/wiki/Wikipedia:Strona_g%C5%82%C3%B3wna https://pt.wikipedia.org/wiki/Wikip%C3%A9dia:P%C3%A1gina_principal Bug: T75909 Change-Id: Id524d1443197fed267a870ee5bdb7c7266085cbc --- M lib/mediawiki.WikiConfig.js M lib/mediawiki.parser.environment.js 2 files changed, 25 insertions(+), 25 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/mediawiki.WikiConfig.js b/lib/mediawiki.WikiConfig.js index 9eceaa1..530894e 100644 --- a/lib/mediawiki.WikiConfig.js +++ b/lib/mediawiki.WikiConfig.js @@ -61,7 +61,7 @@ this.namespaceIds = Object.create(this.canonicalNamespaces); // The interwiki prefix - this.iwp = prefix; + this.iwp = prefix || ""; // The URI for api.php on this wiki. this.apiURI = apiURI || null; @@ -75,6 +75,9 @@ } var general = resultConf.general; + // Store the wiki's main page. + this.mainpage = general.mainpage; + // The language this.lang = general.lang; this.rtl = general.rtl !== undefined; diff --git a/lib/mediawiki.parser.environment.js b/lib/mediawiki.parser.environment.js index 733ce52..b6815e8 100644 --- a/lib/mediawiki.parser.environment.js +++ b/lib/mediawiki.parser.environment.js @@ -21,7 +21,9 @@ * @param {ParsoidConfig/null} parsoidConfig * @param {WikiConfig/null} wikiConfig */ -var MWParserEnvironment = function ( parsoidConfig, wikiConfig ) { +var MWParserEnvironment = function( parsoidConfig, wikiConfig, options ) { + options = options || {}; + // page information this.page = { name: this.defaultPageName, @@ -34,7 +36,7 @@ }; // A passed-in cookie, if any - this.cookie = null; + this.cookie = options.cookie || null; // Configuration this.conf = {}; @@ -69,13 +71,13 @@ if ( !wikiConfig ) { // Local things, per-wiki - wikiConfig = new WikiConfig( null, '' ); + wikiConfig = new WikiConfig( null, options.prefix ); } this.conf.wiki = wikiConfig; this.performance = {}; - this.initializeForPageName( this.defaultPageName ); + this.initializeForPageName( options.pageName || this.defaultPageName ); this.pipelineFactory = new ParserPipelineFactory(this); @@ -191,19 +193,21 @@ * * @param {string} pageName */ -MWParserEnvironment.prototype.initializeForPageName = function( pageName ) { +MWParserEnvironment.prototype.initializeForPageName = function( pageName, dontReset ) { // Create a title from the pageName var title = Title.fromPrefixedText(this, pageName); this.page.ns = title.ns.id; this.page.title = title; - this.initUID(); this.page.name = pageName; // Always prefix a ./ so that we don't have to escape colons. Those // would otherwise fool browsers into treating namespaces (like File:) // as protocols. this.page.relativeLinkPrefix = "./"; - this.performance.start = new Date().getTime(); + if ( !dontReset ) { + this.initUID(); + this.performance.start = new Date().getTime(); + } }; MWParserEnvironment.prototype.getVariable = function( varname, options ) { @@ -232,26 +236,19 @@ * @param {MWParserEnvironment} cb.env The finished environment object */ MWParserEnvironment.getParserEnv = function ( parsoidConfig, wikiConfig, prefix, pageName, cookie, cb ) { - if ( !parsoidConfig ) { - parsoidConfig = new ParsoidConfig(); - parsoidConfig.setInterwiki( 'mediawikiwiki', 'http://www.mediawiki.org/w/api.php' ); - } - - if ( !wikiConfig ) { - wikiConfig = new WikiConfig( null, null ); - } - - var env = new MWParserEnvironment( parsoidConfig, wikiConfig ); - env.cookie = cookie; - - if ( pageName ) { - env.initializeForPageName( pageName ); - } + var env = new MWParserEnvironment(parsoidConfig, wikiConfig, { + pageName: pageName, + cookie: cookie, + prefix: prefix + }); // Get that wiki's config - env.switchToConfig( prefix, function ( err ) { + env.switchToConfig(prefix, function( err ) { + if ( !err && !pageName ) { + env.initializeForPageName( env.conf.wiki.mainpage, true ); + } cb( err, env ); - } ); + }); }; /** -- To view, visit https://gerrit.wikimedia.org/r/177878 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id524d1443197fed267a870ee5bdb7c7266085cbc Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <[email protected]> Gerrit-Reviewer: Arlolra <[email protected]> Gerrit-Reviewer: Cscott <[email protected]> Gerrit-Reviewer: Kelson <[email protected]> Gerrit-Reviewer: Marcoil <[email protected]> Gerrit-Reviewer: Subramanya Sastry <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
