Merge "Recognize links to add a new topic that use Special:NewSection"

This commit is contained in:
jenkins-bot 2021-08-02 17:42:30 +00:00 committed by Gerrit Code Review
commit 1f4706a308
6 changed files with 36 additions and 3 deletions

View file

@ -71,6 +71,8 @@ class Data {
$data['specialContributionsName'] = MediaWikiServices::getInstance()
->getSpecialPageFactory()->getLocalNameFor( 'Contributions' );
$data['specialNewSectionName'] = MediaWikiServices::getInstance()
->getSpecialPageFactory()->getLocalNameFor( 'NewSection' );
$localTimezone = $config->get( 'Localtimezone' );
// Return all timezone abbreviations for the local timezone (there will often be two, for

View file

@ -1,4 +1,6 @@
var
// Data::getLocalData()
parserData = require( './parser/data.json' ),
utils = require( './utils.js' );
function ReplyLinksController( $pageContainer ) {
@ -77,13 +79,38 @@ ReplyLinksController.prototype.onAnyLinkClick = function ( e ) {
// T106244: URL encoded values using fallback 8-bit encoding (invalid UTF-8) cause mediawiki.Uri to crash
return;
}
if ( ( uri.query.action !== 'edit' && uri.query.veaction !== 'editsource' ) || uri.query.section !== 'new' ) {
var title = utils.getTitleFromUrl( href );
if ( !title ) {
return;
}
// Recognize links to add a new topic:
if (
// Special:NewSection/...
title.getNamespaceId() === mw.config.get( 'wgNamespaceIds' ).special &&
title.getMainText().split( '/' )[ 0 ] === parserData.specialNewSectionName
) {
// Get the real title from the subpage parameter
var param = title.getMainText().slice( parserData.specialNewSectionName.length + 1 );
title = mw.Title.newFromText( param );
if ( !title ) {
return;
}
} else if (
// ?title=...&action=edit&section=new
// ?title=...&veaction=editsource&section=new
( uri.query.action === 'edit' || uri.query.veaction === 'editsource' ) && uri.query.section === 'new'
) {
// Do nothing
} else {
// Not a link to add a new topic
return;
}
var title = utils.getTitleFromUrl( href );
if ( !title || title.getPrefixedDb() !== mw.config.get( 'wgRelevantPageName' ) ) {
if ( title.getPrefixedDb() !== mw.config.get( 'wgRelevantPageName' ) ) {
// Link to add a section on another page, not supported yet (T282205)
return;
}

View file

@ -18,6 +18,7 @@
},
"localTimezone": "UTC",
"specialContributionsName": "Contributions",
"specialNewSectionName": "NewSection",
"timezones": {
"ckb": {
"UTC": "UTC"

View file

@ -18,6 +18,7 @@
},
"localTimezone": "UTC",
"specialContributionsName": "Contributions",
"specialNewSectionName": "NewSection",
"timezones": {
"en": {
"UTC": "UTC"

View file

@ -44,6 +44,7 @@
},
"localTimezone": "UTC",
"specialContributionsName": "Contributions",
"specialNewSectionName": "NewSection",
"timezones": {
"sr": {
"UTC": "UTC"

View file

@ -18,6 +18,7 @@
},
"localTimezone": "Asia/Bangkok",
"specialContributionsName": "Contributions",
"specialNewSectionName": "NewSection",
"timezones": {
"th": {
"LMT": "LMT",