mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Merge "Mark disambiguation and redirect pages in the link inspector"
This commit is contained in:
commit
50b6de4866
|
@ -726,6 +726,8 @@ $wgResourceModules += array(
|
||||||
'visualeditor-linkinspector-illegal-title',
|
'visualeditor-linkinspector-illegal-title',
|
||||||
'visualeditor-linkinspector-suggest-external-link',
|
'visualeditor-linkinspector-suggest-external-link',
|
||||||
'visualeditor-linkinspector-suggest-matching-page',
|
'visualeditor-linkinspector-suggest-matching-page',
|
||||||
|
'visualeditor-linkinspector-suggest-disambig-page',
|
||||||
|
'visualeditor-linkinspector-suggest-redirect-page',
|
||||||
'visualeditor-linkinspector-suggest-new-page',
|
'visualeditor-linkinspector-suggest-new-page',
|
||||||
'visualeditor-media-input-placeholder',
|
'visualeditor-media-input-placeholder',
|
||||||
'visualeditor-meta-tool',
|
'visualeditor-meta-tool',
|
||||||
|
|
|
@ -116,6 +116,8 @@
|
||||||
"visualeditor-linkinspector-illegal-title": "Invalid page title",
|
"visualeditor-linkinspector-illegal-title": "Invalid page title",
|
||||||
"visualeditor-linkinspector-suggest-external-link": "External link",
|
"visualeditor-linkinspector-suggest-external-link": "External link",
|
||||||
"visualeditor-linkinspector-suggest-matching-page": "Matching page",
|
"visualeditor-linkinspector-suggest-matching-page": "Matching page",
|
||||||
|
"visualeditor-linkinspector-suggest-disambig-page": "Disambiguation page",
|
||||||
|
"visualeditor-linkinspector-suggest-redirect-page": "Redirect page",
|
||||||
"visualeditor-linkinspector-suggest-new-page": "New page",
|
"visualeditor-linkinspector-suggest-new-page": "New page",
|
||||||
"visualeditor-loadwarning": "Error loading data from server: $1. Would you like to retry?",
|
"visualeditor-loadwarning": "Error loading data from server: $1. Would you like to retry?",
|
||||||
"visualeditor-loadwarning-token": "Error loading edit token from server: $1. Would you like to retry?",
|
"visualeditor-loadwarning-token": "Error loading edit token from server: $1. Would you like to retry?",
|
||||||
|
|
|
@ -121,6 +121,8 @@
|
||||||
"visualeditor-linkinspector-illegal-title": "Warning that the entered text is not a valid page title.",
|
"visualeditor-linkinspector-illegal-title": "Warning that the entered text is not a valid page title.",
|
||||||
"visualeditor-linkinspector-suggest-external-link": "Label for an external (Web) link in the link inspector.\n{{Identical|External link}}",
|
"visualeditor-linkinspector-suggest-external-link": "Label for an external (Web) link in the link inspector.\n{{Identical|External link}}",
|
||||||
"visualeditor-linkinspector-suggest-matching-page": "Label for suggested matching local wiki page or pages in the link inspector",
|
"visualeditor-linkinspector-suggest-matching-page": "Label for suggested matching local wiki page or pages in the link inspector",
|
||||||
|
"visualeditor-linkinspector-suggest-disambig-page": "Label for suggested disambiguation pages in the link inspector",
|
||||||
|
"visualeditor-linkinspector-suggest-redirect-page": "Label for suggested redirect pages in the link inspector",
|
||||||
"visualeditor-linkinspector-suggest-new-page": "Label for a new page in the link inspector.\n{{Identical|New page}}",
|
"visualeditor-linkinspector-suggest-new-page": "Label for a new page in the link inspector.\n{{Identical|New page}}",
|
||||||
"visualeditor-loadwarning": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server, in English. e.g. \"parsoidserver-http-bad-status: 404\"",
|
"visualeditor-loadwarning": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server, in English. e.g. \"parsoidserver-http-bad-status: 404\"",
|
||||||
"visualeditor-loadwarning-token": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server.",
|
"visualeditor-loadwarning-token": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server.",
|
||||||
|
@ -193,4 +195,4 @@
|
||||||
"visualeditor-wikitext-warning": "Contents of notification displayed when Wikitext has been detected.\n\nRefers to:\n* {{msg-mw|Visualeditor-wikitext-warning-link}}\n* {{msg-mw|Visualeditor-ca-editsource}}",
|
"visualeditor-wikitext-warning": "Contents of notification displayed when Wikitext has been detected.\n\nRefers to:\n* {{msg-mw|Visualeditor-wikitext-warning-link}}\n* {{msg-mw|Visualeditor-ca-editsource}}",
|
||||||
"visualeditor-wikitext-warning-link": "Link to page describing what Wikitext is.\n\nUsed in:\n* {{msg-mw|Visualeditor-wikitext-warning}}.",
|
"visualeditor-wikitext-warning-link": "Link to page describing what Wikitext is.\n\nUsed in:\n* {{msg-mw|Visualeditor-wikitext-warning}}.",
|
||||||
"visualeditor-wikitext-warning-title": "Title of notification displayed when Wikitext has been detected"
|
"visualeditor-wikitext-warning-title": "Title of notification displayed when Wikitext has been detected"
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=existingPage],
|
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=existingPage],
|
||||||
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=matchingPage],
|
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=matchingPage],
|
||||||
|
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=disambigPage],
|
||||||
|
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=redirectPage],
|
||||||
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=externalLink] {
|
.ve-ui-mwLinkTargetInputWidget-menu .oo-ui-menuItemWidget[rel=externalLink] {
|
||||||
color: #0645AD;
|
color: #0645AD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,29 @@ ve.ui.MWLinkTargetInputWidget.prototype.onLookupMenuItemSelect = function ( item
|
||||||
* @returns {jqXHR} AJAX object without success or fail handlers attached
|
* @returns {jqXHR} AJAX object without success or fail handlers attached
|
||||||
*/
|
*/
|
||||||
ve.ui.MWLinkTargetInputWidget.prototype.getLookupRequest = function () {
|
ve.ui.MWLinkTargetInputWidget.prototype.getLookupRequest = function () {
|
||||||
return ve.init.mw.Target.static.apiRequest( {
|
var propsJqXhr,
|
||||||
'action': 'opensearch',
|
searchJqXhr = ve.init.mw.Target.static.apiRequest( {
|
||||||
'search': this.value,
|
'action': 'opensearch',
|
||||||
'namespace': 0,
|
'search': this.value,
|
||||||
'suggest': ''
|
'namespace': 0,
|
||||||
} );
|
'suggest': ''
|
||||||
|
} );
|
||||||
|
|
||||||
|
return searchJqXhr.then( function ( data ) {
|
||||||
|
propsJqXhr = ve.init.mw.Target.static.apiRequest( {
|
||||||
|
'action': 'query',
|
||||||
|
'prop': 'info|pageprops',
|
||||||
|
'titles': ( data[1] || [] ).join( '|' ),
|
||||||
|
'ppprop': 'disambiguation'
|
||||||
|
} );
|
||||||
|
return propsJqXhr;
|
||||||
|
} ).promise( { abort: function () {
|
||||||
|
searchJqXhr.abort();
|
||||||
|
|
||||||
|
if ( propsJqXhr ) {
|
||||||
|
propsJqXhr.abort();
|
||||||
|
}
|
||||||
|
} } );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +101,7 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupRequest = function () {
|
||||||
* @param {Mixed} data Response from server
|
* @param {Mixed} data Response from server
|
||||||
*/
|
*/
|
||||||
ve.ui.MWLinkTargetInputWidget.prototype.getLookupCacheItemFromData = function ( data ) {
|
ve.ui.MWLinkTargetInputWidget.prototype.getLookupCacheItemFromData = function ( data ) {
|
||||||
return data[1] || [];
|
return data.query && data.query.pages || {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,17 +111,34 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupCacheItemFromData = function (
|
||||||
* @returns {OO.ui.MenuItemWidget[]} Menu items
|
* @returns {OO.ui.MenuItemWidget[]} Menu items
|
||||||
*/
|
*/
|
||||||
ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuItemsFromData = function ( data ) {
|
ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuItemsFromData = function ( data ) {
|
||||||
var i, len, item,
|
var i, len, item, pageExistsExact, pageExists, index, matchingPage,
|
||||||
menu$ = this.lookupMenu.$,
|
menu$ = this.lookupMenu.$,
|
||||||
items = [],
|
items = [],
|
||||||
matchingPages = data,
|
existingPages = [],
|
||||||
// If not found, run value through mw.Title to avoid treating a match as a
|
matchingPages = [],
|
||||||
// mismatch where normalisation would make them matching (bug 48476)
|
disambigPages = [],
|
||||||
pageExistsExact = ve.indexOf( this.value, matchingPages ) !== -1,
|
redirectPages = [],
|
||||||
titleObj = mw.Title.newFromText( this.value ),
|
titleObj = mw.Title.newFromText( this.value );
|
||||||
pageExists = pageExistsExact || (
|
|
||||||
titleObj && ve.indexOf( titleObj.getPrefixedText(), matchingPages ) !== -1
|
for ( index in data ) {
|
||||||
);
|
matchingPage = data[index];
|
||||||
|
existingPages.push( matchingPage.title );
|
||||||
|
|
||||||
|
if ( matchingPage.redirect !== undefined ) {
|
||||||
|
redirectPages.push( matchingPage.title );
|
||||||
|
} else if ( matchingPage.pageprops !== undefined && matchingPage.pageprops.disambiguation !== undefined ) {
|
||||||
|
disambigPages.push( matchingPage.title );
|
||||||
|
} else {
|
||||||
|
matchingPages.push( matchingPage.title );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found, run value through mw.Title to avoid treating a match as a
|
||||||
|
// mismatch where normalisation would make them matching (bug 48476)
|
||||||
|
pageExistsExact = ve.indexOf( this.value, existingPages ) !== -1;
|
||||||
|
pageExists = pageExistsExact || (
|
||||||
|
titleObj && ve.indexOf( titleObj.getPrefixedText(), existingPages ) !== -1
|
||||||
|
);
|
||||||
|
|
||||||
// External link
|
// External link
|
||||||
if ( ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( this.value ) ) {
|
if ( ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( this.value ) ) {
|
||||||
|
@ -158,6 +192,34 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuItemsFromData = function (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disambiguation pages
|
||||||
|
if ( disambigPages.length ) {
|
||||||
|
items.push( new OO.ui.MenuSectionItemWidget(
|
||||||
|
'disambigPages',
|
||||||
|
{ '$': menu$, 'label': ve.msg( 'visualeditor-linkinspector-suggest-disambig-page' ) }
|
||||||
|
) );
|
||||||
|
for ( i = 0, len = disambigPages.length; i < len; i++ ) {
|
||||||
|
items.push( new OO.ui.MenuItemWidget(
|
||||||
|
this.getInternalLinkAnnotationFromTitle( disambigPages[i] ),
|
||||||
|
{ '$': menu$, 'rel': 'disambigPage', 'label': disambigPages[i] }
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect pages
|
||||||
|
if ( redirectPages.length ) {
|
||||||
|
items.push( new OO.ui.MenuSectionItemWidget(
|
||||||
|
'redirectPages',
|
||||||
|
{ '$': menu$, 'label': ve.msg( 'visualeditor-linkinspector-suggest-redirect-page' ) }
|
||||||
|
) );
|
||||||
|
for ( i = 0, len = redirectPages.length; i < len; i++ ) {
|
||||||
|
items.push( new OO.ui.MenuItemWidget(
|
||||||
|
this.getInternalLinkAnnotationFromTitle( redirectPages[i] ),
|
||||||
|
{ '$': menu$, 'rel': 'redirectPage', 'label': redirectPages[i] }
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue