Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/140875
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. (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/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
M modules/ve-mw/ui/widgets/ve.ui.MWTitleInputWidget.js
2 files changed, 9 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/75/140875/1
diff --git a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
index ce46e5f..adfe72f 100644
--- a/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
+++ b/modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js
@@ -28,7 +28,7 @@
// Properties
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 137e7ed..e8c2a5d 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] 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 ) {
value = title.getNamespaceId() ===
this.namespace ?
title.getNameText() : ':' +
title.getPrefixedText();
} else {
--
To view, visit https://gerrit.wikimedia.org/r/140875
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia67f9054a56e71153339f961bbbcadb565115748
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits