Explorar o código

support $wgMainPageIsDomainRoot

Markus-Rost %!s(int64=3) %!d(string=hai) anos
pai
achega
6c489bc6c8
Modificáronse 2 ficheiros con 7 adicións e 3 borrados
  1. 1 1
      RcGcDb
  2. 6 2
      util/wiki.js

+ 1 - 1
RcGcDb

@@ -1 +1 @@
-Subproject commit 639e6da6700cebffd2bdb3f80c36b1b700cf3c83
+Subproject commit d47fd6df5c9a0275c44c130719be519ac61958c6

+ 6 - 2
util/wiki.js

@@ -47,6 +47,7 @@ export default class Wiki extends URL {
 		}
 		this.articlepath = articlepath;
 		this.mainpage = '';
+		this.mainpageisdomainroot = false;
 		this.miraheze = this.hostname.endsWith( '.miraheze.org' );
 		this.wikimedia = wikimediaSites.includes( this.hostname.split('.').slice(-2).join('.') );
 		this.centralauth = ( ( this.isWikimedia() || this.isMiraheze() ) ? 'CentralAuth' : 'local' );
@@ -86,11 +87,12 @@ export default class Wiki extends URL {
 	 * @param {String} [siteinfo.gamepedia] - If the wiki is a Gamepedia wiki.
 	 * @returns {Wiki}
 	 */
-	updateWiki({servername, scriptpath, articlepath, mainpage, centralidlookupprovider, logo, gamepedia = 'false'}) {
+	updateWiki({servername, scriptpath, articlepath, mainpage, mainpageisdomainroot, centralidlookupprovider, logo, gamepedia = 'false'}) {
 		this.hostname = servername;
 		this.pathname = scriptpath + '/';
 		this.articlepath = articlepath;
 		this.mainpage = mainpage;
+		this.mainpageisdomainroot = ( mainpageisdomainroot !== undefined );
 		this.centralauth = centralidlookupprovider;
 		this.miraheze = /^(?:https?:)?\/\/static\.miraheze\.org\//.test(logo);
 		this.gamepedia = ( gamepedia === 'true' ? true : this.hostname.endsWith( '.gamepedia.com' ) );
@@ -175,6 +177,7 @@ export default class Wiki extends URL {
 	 * @returns {String}
 	 */
 	toLink(title = '', querystring = '', fragment = '', isMarkdown = false) {
+		if ( this.mainpageisdomainroot && title === this.mainpage && !querystring ) return this.origin + '/' + Wiki.toSection(fragment, true, this.spaceReplacement);
 		querystring = new URLSearchParams(querystring);
 		if ( !querystring.toString().length ) title = ( title || this.mainpage );
 		title = title.replace( / /g, this.spaceReplacement ).replace( /%/g, '%2525' );
@@ -283,7 +286,8 @@ export default class Wiki extends URL {
 			articlepath: this.articlepath,
 			articleURL: this.articleURL,
 			spaceReplacement: this.spaceReplacement,
-			mainpage: this.mainpage
+			mainpage: this.mainpage,
+			mainpageisdomainroot: this.mainpageisdomainroot,
 		}
 		return 'Wiki ' + inspect(wiki, opts);
 	}