jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/378030 )
Change subject: CX2: Publish the translation ...................................................................... CX2: Publish the translation Bug: T162768 Change-Id: I1ae059f277aac47c8505b78c23a73244baad6880 --- M modules/mw.cx.TargetArticle.js 1 file changed, 23 insertions(+), 19 deletions(-) Approvals: Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/mw.cx.TargetArticle.js b/modules/mw.cx.TargetArticle.js index 6fe0a6f..c9aa7f6 100644 --- a/modules/mw.cx.TargetArticle.js +++ b/modules/mw.cx.TargetArticle.js @@ -37,8 +37,7 @@ from: this.sourceLanguage, to: this.targetLanguage, sourcetitle: this.sourceTitle, - html: this.getContent( true ), - categories: this.getCategories() + html: this.getContent( true ) } ); this.publishDeferred = $.Deferred(); @@ -315,16 +314,30 @@ /** * Get content for publishing * - * @param {boolean} deflate Whether the content need to deflated + * @param {boolean} deflate Whether the content should be deflated * @return {string} Content for publishing, may be deflated */ mw.cx.TargetArticle.prototype.getContent = function ( deflate ) { - var content; - content = this.translation.getTargetPage().getContent( this.translation ); - if ( deflate ) { - content = EasyDeflate.deflate( content ); - } - return content; + var html, + doc = this.view.getSurface().getDom(); + + // Strip placeholders + Array.prototype.forEach.call( doc.body.querySelectorAll( 'section[rel="cx:Placeholder"]' ), function ( placeholder ) { + placeholder.remove(); + } ); + // Strip segments + Array.prototype.forEach.call( doc.body.querySelectorAll( '[data-segmentid]' ), function ( segment ) { + var parent = segment.parentNode; + // move all children out of the element + while ( segment.firstChild ) { + parent.insertBefore( segment.firstChild, segment ); + } + segment.remove(); + } ); + + html = this.view.getHtml( doc ); + + return deflate ? EasyDeflate.deflate( html ) : html; }; /** @@ -363,15 +376,6 @@ } else { return 'User:' + username + '/' + title; } -}; - -/** - * Get categories for the target article - * - * @return {string[]} Category titles - */ -mw.cx.TargetArticle.prototype.getCategories = function () { - return this.translation.getTargetPage().getCategories(); }; /** @@ -564,5 +568,5 @@ }; mw.cx.TargetArticle.prototype.getTargetURL = function () { - return this.siteMapper.getPageUrl( this.targetLanguage, this.targetTitle ); + return this.siteMapper.getPageUrl( this.targetLanguage, this.getTargetTitle() ); }; -- To view, visit https://gerrit.wikimedia.org/r/378030 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1ae059f277aac47c8505b78c23a73244baad6880 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Catrope <r...@wikimedia.org> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits