From 36e0f8988d1ce666017b1b9a8871a85771b09582 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 2 Apr 2018 17:34:51 +0100 Subject: [PATCH] Show redirect link in preview Bug: T191128 Change-Id: I08fc03dd869e6b074a24698f9037380b26e3dd2c --- modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js index 455efa0164..2973866437 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js @@ -189,7 +189,8 @@ ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( wikitextDiffPromise, * @param {HTMLDocument} [baseDoc] Base document against which to normalise links, if document provided */ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) { - var body, contents, $heading, + var body, contents, $heading, redirectMeta, + $redirect = $(), categories = [], modules = []; @@ -237,9 +238,21 @@ ve.ui.MWSaveDialog.prototype.showPreview = function ( docOrMsg, baseDoc ) { } ); } + // Redirect + redirectMeta = body.querySelector( 'link[rel="mw:PageProp/redirect"]' ); + if ( redirectMeta ) { + $redirect = ve.init.mw.ArticleTarget.static.buildRedirectMsg( + ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( + redirectMeta.getAttribute( 'href' ), + document + ).title + ); + } + this.$previewViewer.empty().append( // TODO: This won't work with formatted titles (T122976) $heading.text( docOrMsg.title || mw.Title.newFromText( ve.init.target.pageName ).getPrefixedText() ), + $redirect, $( '
' ).addClass( 'mw-content-' + mw.config.get( 'wgVisualEditor' ).pageLanguageDir ).append( contents )