jenkins-bot has submitted this change and it was merged.
Change subject: Handle transcluding templates outside of the template namespace
properly
......................................................................
Handle transcluding templates outside of the template namespace properly
Stop prefixing all requested titles with 'Template:', and don't try to use
colon prefixes when transcluding except when deliberately transcluding from the
main namespace.
(A title prefixed with a colon on MediaWiki is used to create a link to
something that would normally be included as a File/Category)
Bug: 52609
Change-Id: Ia67f9054a56e71153339f961bbbcadb565115748
---
M modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js
M modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
M modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
3 files changed, 10 insertions(+), 10 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js
b/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js
index a95e4df..ab899af 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js
@@ -89,12 +89,8 @@
ve.dm.MWTemplateModel.newFromName = function ( transclusion, name ) {
var href = name;
- if ( href.charAt( 0 ) !== ':' ) {
- href = mw.config.get( 'wgFormattedNamespaces' )[10] + ':' +
href;
- }
-
// TODO: Do we need to account for the title being invalid?
- href = new mw.Title( href ).getPrefixedText();
+ href = new mw.Title( href, mw.config.get( 'wgNamespaceIds' ).template
).getPrefixedText();
return new ve.dm.MWTemplateModel( transclusion, { 'href': href, 'wt':
name }, 'user' );
};
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
index 0fab8e0..ae49685 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
@@ -29,7 +29,7 @@
this.placeholder = placeholder;
this.addTemplateInput = new ve.ui.MWTitleInputWidget( {
- '$': this.$, '$overlay': this.$overlay, 'namespace': 10
+ '$': this.$, '$overlay': this.$overlay, 'namespace': 10,
'prefixColon': false
} )
.connect( this, {
'change': 'onTemplateInputChange',
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
b/modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
index 111ad5b..8974397 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
@@ -16,7 +16,10 @@
*
* @constructor
* @param {Object} [config] Configuration options
- * @cfg {number} [namespace] Namespace to prepend to queries not prefixed with
':'
+ * @cfg {number} [namespace] Namespace to prepend to queries
+ * @cfg {boolean} [prefixColon=true] Whether or not to prefix entries outside
the
+ * target namespace (if set) with a colon. Assumed to be true unless
+ * explicitly set to false.
*/
ve.ui.MWTitleInputWidget = function VeUiMWTitleInputWidget( config ) {
// Config intialization
@@ -30,6 +33,7 @@
// Properties
this.namespace = config.namespace || null;
+ this.prefixColon = config.prefixColon !== false;
// Events
this.lookupMenu.connect( this, { 'choose': 'onLookupMenuItemChoose' } );
@@ -69,8 +73,8 @@
var value = this.value;
// Prefix with default namespace name
- if ( this.namespace !== null && value.charAt( 0 ) !== ':' ) {
- value = mw.config.get( 'wgFormattedNamespaces'
)[this.namespace] + ':' + value;
+ if ( this.namespace !== null && mw.Title.newFromText( value,
this.namespace ) ) {
+ value = mw.Title.newFromText( value, this.namespace
).getPrefixedText();
}
// Dont send leading ':' to open search
@@ -111,7 +115,7 @@
if ( matchingPages && matchingPages.length ) {
for ( i = 0, len = matchingPages.length; i < len; i++ ) {
title = new mw.Title( matchingPages[i] );
- if ( this.namespace !== null ) {
+ if ( this.namespace !== null && ( this.prefixColon ||
title.namespace === 0 ) ) {
value = title.getNamespaceId() ===
this.namespace ?
title.getMainText() : ':' +
title.getPrefixedText();
} else {
--
To view, visit https://gerrit.wikimedia.org/r/140875
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia67f9054a56e71153339f961bbbcadb565115748
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits