mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Follow redirects in the link inspector API
Show redirect targets first, then any redirects to it immediately after. Change-Id: Ifde579410b4fbf42e0598e4b069963162333da55
This commit is contained in:
parent
df6a570f82
commit
702fc724d7
|
@ -1148,6 +1148,7 @@ $wgResourceModules += array(
|
|||
'messages' => array(
|
||||
'visualeditor-annotationbutton-linknode-tooltip',
|
||||
'visualeditor-linkinspector-description-new-page',
|
||||
'visualeditor-linkinspector-description-redirect',
|
||||
'visualeditor-linkinspector-illegal-title',
|
||||
'visualeditor-linknodeinspector-add-label',
|
||||
'visualeditor-linknodeinspector-title',
|
||||
|
|
|
@ -1174,6 +1174,7 @@
|
|||
"messages": [
|
||||
"visualeditor-annotationbutton-linknode-tooltip",
|
||||
"visualeditor-linkinspector-description-new-page",
|
||||
"visualeditor-linkinspector-description-redirect",
|
||||
"visualeditor-linkinspector-illegal-title",
|
||||
"visualeditor-linknodeinspector-add-label",
|
||||
"visualeditor-linknodeinspector-title"
|
||||
|
|
|
@ -242,6 +242,7 @@
|
|||
"visualeditor-formatdropdown-format-mw-heading6": "Sub-heading 4",
|
||||
"visualeditor-languages-tool": "Languages",
|
||||
"visualeditor-linkinspector-description-new-page": "Page does not exist yet",
|
||||
"visualeditor-linkinspector-description-redirect": "redirect to $1",
|
||||
"visualeditor-linkinspector-illegal-title": "Invalid page title",
|
||||
"visualeditor-linknodeinspector-add-label": "Add label",
|
||||
"visualeditor-linknodeinspector-title": "Simple link",
|
||||
|
|
|
@ -251,6 +251,7 @@
|
|||
"visualeditor-formatdropdown-format-mw-heading6": "Item in the MediaWiki formatting dropdown for a level 6 heading (sub-section)\n{{Related|Visualeditor-formatdropdown}}",
|
||||
"visualeditor-languages-tool": "Tool for opening the languages links section of the meta dialog.\n{{Identical|Language}}",
|
||||
"visualeditor-linkinspector-description-new-page": "Description label for a new page in the link inspector.",
|
||||
"visualeditor-linkinspector-description-redirect": "Description label for a redirect in the link inspector.",
|
||||
"visualeditor-linkinspector-illegal-title": "Warning that the entered text is not a valid page title.",
|
||||
"visualeditor-linknodeinspector-add-label": "Label of button that converts an auto-numbered, external, labelless link into a labeled external link",
|
||||
"visualeditor-linknodeinspector-title": "Title of inspector for editing auto-numbered, external, labelless links.\n\nSee also:\n* {{msg-mw|Visualeditor-annotationbutton-linknode-tooltip}}",
|
||||
|
|
|
@ -193,6 +193,7 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupRequest = function () {
|
|||
prop: 'info|pageprops|pageimages|pageterms',
|
||||
pithumbsize: 80,
|
||||
pilimit: 5,
|
||||
redirects: '',
|
||||
wbptterms: 'description',
|
||||
ppprop: 'disambiguation'
|
||||
} );
|
||||
|
@ -214,7 +215,7 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupRequest = function () {
|
|||
* @param {Mixed} data Response from server
|
||||
*/
|
||||
ve.ui.MWLinkTargetInputWidget.prototype.getLookupCacheDataFromResponse = function ( data ) {
|
||||
return data.query && data.query.pages || {};
|
||||
return data.query || {};
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -241,22 +242,42 @@ ve.ui.MWLinkTargetInputWidget.prototype.onLookupInputChange = function () {
|
|||
* @returns {OO.ui.MenuOptionWidget[]} Menu items
|
||||
*/
|
||||
ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuOptionsFromData = function ( data ) {
|
||||
var i, len, index, pageExists, pageExistsExact, suggestionPage, linkData,
|
||||
var i, len, index, pageExists, pageExistsExact, suggestionPage, linkData, redirect, redirects,
|
||||
items = [],
|
||||
suggestionPages = [],
|
||||
titleObj = mw.Title.newFromText( this.value ),
|
||||
redirectsTo = {},
|
||||
links = {};
|
||||
|
||||
for ( index in data ) {
|
||||
suggestionPage = data[index];
|
||||
if ( data.redirects ) {
|
||||
for ( i = 0, len = data.redirects.length; i < len; i++ ) {
|
||||
redirect = data.redirects[i];
|
||||
redirectsTo[redirect.to] = redirectsTo[redirect.to] || [];
|
||||
redirectsTo[redirect.to].push( redirect.from );
|
||||
}
|
||||
}
|
||||
|
||||
for ( index in data.pages ) {
|
||||
suggestionPage = data.pages[index];
|
||||
links[suggestionPage.title] = {
|
||||
missing: false,
|
||||
redirect: suggestionPage.redirect !== undefined,
|
||||
redirect: false,
|
||||
disambiguation: ve.getProp( suggestionPage, 'pageprops', 'disambiguation' ) !== undefined,
|
||||
imageUrl: ve.getProp( suggestionPage, 'thumbnail', 'source' ),
|
||||
description: ve.getProp( suggestionPage, 'terms', 'description' )
|
||||
};
|
||||
suggestionPages.push( suggestionPage.title );
|
||||
|
||||
redirects = redirectsTo[suggestionPage.title] || [];
|
||||
for ( i = 0, len = redirects.length; i < len; i++ ) {
|
||||
links[redirects[i]] = {
|
||||
missing: false,
|
||||
redirect: true,
|
||||
disambiguation: false,
|
||||
description: ve.msg( 'visualeditor-linkinspector-description-redirect', suggestionPage.title )
|
||||
};
|
||||
suggestionPages.push( redirects[i] );
|
||||
}
|
||||
}
|
||||
|
||||
// If not found, run value through mw.Title to avoid treating a match as a
|
||||
|
|
Loading…
Reference in a new issue