Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/132932
Change subject: Use cxserver apis for data instead of websockets ...................................................................... Use cxserver apis for data instead of websockets See I120cb20fe672565343d8223312947ee55e211a9c Change-Id: I61ae1f6eaa5ca426df5522f788aad014dd086f5f --- M Resources.php D modules/base/ext.cx.datamanager.js M modules/source/ext.cx.source.js M specials/SpecialContentTranslation.php 4 files changed, 10 insertions(+), 61 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/32/132932/1 diff --git a/Resources.php b/Resources.php index a702217..f8bbb8d 100644 --- a/Resources.php +++ b/Resources.php @@ -17,7 +17,6 @@ $wgResourceModules['ext.cx.model'] = array( 'scripts' => array( 'base/ext.cx.model.js', - 'base/ext.cx.datamanager.js', ), ) + $resourcePaths; diff --git a/modules/base/ext.cx.datamanager.js b/modules/base/ext.cx.datamanager.js deleted file mode 100644 index 79e815a..0000000 --- a/modules/base/ext.cx.datamanager.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * ContentTranslation extension - * A tool that allows editors to translate pages from one language - * to another with the help of machine translation and other translation tools - * - * @file - * @ingroup Extensions - * @copyright See AUTHORS.txt - * @license GPL-2.0+ - */ -( function ( $, mw ) { - 'use strict'; - - var socket; - - /* global io */ - function initConnection() { - if ( !window.io ) { - return false; - } - socket = io.connect( mw.config.get( 'wgContentTranslationServerURL' ) ); - mw.log( '[CX] Connected to server' ); - return true; - } - - function updateModel( data ) { - mw.log( '[CX] Received data from server' ); - mw.cx.data = data; - mw.hook( 'mw.cx.source.ready' ).fire(); - } - - mw.cx.connect = function () { - if ( !socket ) { - if ( !initConnection() ) { - // io not defined. Server is unreachable. - $( '.cx-header__infobar' ) - .text( mw.msg( 'cx-error-server-connection' ) ) - .show(); - return; - } - } - socket.emit( 'cx.init', { - // FIXME - sourcePage: 'http://en.wikipedia.org/wiki/' + mw.cx.sourceTitle, - sourceLanguage: mw.cx.sourceLanguage, - targetLanguage: mw.cx.targetLanguage, - channel: 'cx' - } ); - mw.log( '[CX] Sending context information to server' ); - socket.on( 'cx.data.update', updateModel ); - }; - -}( jQuery, mediaWiki ) ); diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js index 553f75e..a897fd1 100644 --- a/modules/source/ext.cx.source.js +++ b/modules/source/ext.cx.source.js @@ -11,6 +11,13 @@ ( function ( $, mw ) { 'use strict'; + mw.cx.fetchPage = function ( sourcePage, sourceLanguage ) { + $.get( mw.config.get( 'wgContentTranslationServerURL' ) + '/page/' + sourceLanguage + '/' + sourcePage, function ( response ) { + mw.cx.data = response; + mw.hook( 'mw.cx.source.ready' ).fire(); + } ); + }; + /** * ContentTranslationSource * @@ -27,8 +34,9 @@ ContentTranslationSource.prototype.init = function () { mw.cx.sourceTitle = new mw.Uri().query.page; mw.cx.targetLanguage = new mw.Uri().query.lang || ''; + mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' ); this.render(); - mw.cx.connect(); + mw.cx.fetchPage( mw.cx.sourceTitle, mw.cx.sourceLanguage ); this.listen(); }; @@ -37,8 +45,6 @@ */ ContentTranslationSource.prototype.render = function () { var $heading, $languageLabel, $articleLink, $subHeading, $loader; - - mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' ); this.$container.prop( { lang: mw.cx.sourceLanguage, @@ -60,7 +66,7 @@ 'cx-source-view-page', mw.util.getUrl( mw.cx.sourceTitle ) ).parse() - ); + ); $subHeading = $( '<div>' ) .addClass( 'cx-column__sub-heading' ) diff --git a/specials/SpecialContentTranslation.php b/specials/SpecialContentTranslation.php index 53382d5..68f4acc 100644 --- a/specials/SpecialContentTranslation.php +++ b/specials/SpecialContentTranslation.php @@ -41,9 +41,6 @@ 'mediawiki.page.startup', 'mediawiki.page.ready', ) ); - $out->addScript( - Html::linkedScript( "$wgContentTranslationServerURL/socket.io/socket.io.js" ) - ); } $out->addHTML( $out->headElement( $skin ) ); -- To view, visit https://gerrit.wikimedia.org/r/132932 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I61ae1f6eaa5ca426df5522f788aad014dd086f5f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits