jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383773 )

Change subject: CX2: Use cxserver v2 api
......................................................................


CX2: Use cxserver v2 api

Use the v2 path in the cxserver API URL when CX2 is the context.
Introduce mw.cx.getCXVersion utility method to know the CX
version at browser.

Follow up: I8ca37ce4884

Change-Id: I20334f08bda616732bbf192b9362ba180989a4f0
---
M ContentTranslation.hooks.php
M modules/base/ext.cx.sitemapper.js
M modules/util/mw.cx.util.js
3 files changed, 14 insertions(+), 2 deletions(-)

Approvals:
  jenkins-bot: Verified
  Nikerabbit: Looks good to me, approved



diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php
index f880cc3..00cba76 100644
--- a/ContentTranslation.hooks.php
+++ b/ContentTranslation.hooks.php
@@ -179,7 +179,8 @@
                        $wgContentTranslationDefaultSourceLanguage,
                        $wgContentTranslationTargetNamespace,
                        $wgContentTranslationUserGroupTargetNamespace,
-                       $wgRecommendToolAPIURL;
+                       $wgRecommendToolAPIURL,
+                       $wgContentTranslationVersion;
 
                $vars['wgContentTranslationTranslateInTarget'] = 
$wgContentTranslationTranslateInTarget;
                $vars['wgContentTranslationDomainCodeMapping'] = 
$wgContentTranslationDomainCodeMapping;
@@ -194,6 +195,7 @@
                $vars['wgContentTranslationUserGroupTargetNamespace']
                        = $wgContentTranslationUserGroupTargetNamespace;
                $vars['wgRecommendToolAPIURL'] = $wgRecommendToolAPIURL;
+               $vars['wgContentTranslationVersion'] = 
$wgContentTranslationVersion;
        }
 
        /**
diff --git a/modules/base/ext.cx.sitemapper.js 
b/modules/base/ext.cx.sitemapper.js
index cdd1d89..ee1de6c 100644
--- a/modules/base/ext.cx.sitemapper.js
+++ b/modules/base/ext.cx.sitemapper.js
@@ -96,13 +96,18 @@
         * @return {string}
         */
        mw.cx.SiteMapper.prototype.getCXServerUrl = function ( module, params ) 
{
+               var cxserverURL = this.config.cx;
                if ( params !== undefined ) {
                        $.each( params, function ( key, value ) {
                                module = module.replace( key, 
encodeURIComponent( value ) );
                        } );
                }
 
-               return this.config.cx + module;
+               if ( mw.cx.getCXVersion() === 2 ) {
+                       cxserverURL = cxserverURL.replace( 'v1', 'v2' );
+               }
+
+               return cxserverURL + module;
        };
 
        mw.cx.SiteMapper.prototype.getRestbaseUrl = function ( language, 
module, params ) {
diff --git a/modules/util/mw.cx.util.js b/modules/util/mw.cx.util.js
index bd8a6ec..dd61c5e 100644
--- a/modules/util/mw.cx.util.js
+++ b/modules/util/mw.cx.util.js
@@ -108,3 +108,8 @@
 mw.cx.getSectionNumberFromSectionId = function ( sectionId ) {
        return Number( sectionId.match( /^cx(Target|Source)Section([0-9]+)$/ )[ 
2 ] );
 };
+
+mw.cx.getCXVersion = function () {
+       var query = new mw.Uri().query;
+       return Number( query.version || mw.config.get( 
'wgContentTranslationVersion' ) );
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/383773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I20334f08bda616732bbf192b9362ba180989a4f0
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
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

Reply via email to