mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 02:51:26 +00:00
Recognize links to add a new topic that use Special:NewSection
Bug: T277371 Change-Id: I40a13d8bf87bcd3ecea1427b444b6b7b621213c4
This commit is contained in:
parent
aa19431689
commit
4ebf05d802
|
@ -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
|
||||
|
|
|
@ -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§ion=new
|
||||
// ?title=...&veaction=editsource§ion=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;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"localTimezone": "UTC",
|
||||
"specialContributionsName": "Contributions",
|
||||
"specialNewSectionName": "NewSection",
|
||||
"timezones": {
|
||||
"ckb": {
|
||||
"UTC": "UTC"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"localTimezone": "UTC",
|
||||
"specialContributionsName": "Contributions",
|
||||
"specialNewSectionName": "NewSection",
|
||||
"timezones": {
|
||||
"en": {
|
||||
"UTC": "UTC"
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
},
|
||||
"localTimezone": "UTC",
|
||||
"specialContributionsName": "Contributions",
|
||||
"specialNewSectionName": "NewSection",
|
||||
"timezones": {
|
||||
"sr": {
|
||||
"UTC": "UTC"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"localTimezone": "Asia/Bangkok",
|
||||
"specialContributionsName": "Contributions",
|
||||
"specialNewSectionName": "NewSection",
|
||||
"timezones": {
|
||||
"th": {
|
||||
"LMT": "LMT",
|
||||
|
|
Loading…
Reference in a new issue