Santhosh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374493 )

Change subject: Avoid hardcoding wikipedia.org domain for APIs
......................................................................

Avoid hardcoding wikipedia.org domain for APIs

Make the host configurable. Defaults to {lang}.wikipedia.org

Bug: T172075
Change-Id: I8196b70280a9d2b756c1a4b2e877288d79ce3fa7
---
M config.dev.yaml
M config.prod.yaml
M lib/mw/ApiRequest.js
M lib/pageloader/PageLoader.js
4 files changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/93/374493/1

diff --git a/config.dev.yaml b/config.dev.yaml
index be6c6b2..9988884 100644
--- a/config.dev.yaml
+++ b/config.dev.yaml
@@ -48,6 +48,10 @@
       #   - domain1.com
       #   - domain2.org
       user_agent: cxserver
+      # Mediawiki host name. Example {lang}.wikisource.org which get expanded 
internaly to
+      # es.wikisource.org in a spanish language context.
+      # Do not prefix with http or https://
+      # mw_host: '{lang}.wikipedia.org'
       mwapi_req:
         body: "{{request.body}}"
         query: "{{ default(request.query, {}) }}"
diff --git a/config.prod.yaml b/config.prod.yaml
index 9a3f876..19b2d5f 100644
--- a/config.prod.yaml
+++ b/config.prod.yaml
@@ -48,6 +48,10 @@
       #   - domain1.com
       #   - domain2.org
       user_agent: cxserver
+      # Mediawiki host name. Example {lang}.wikisource.org which get expanded 
internaly to
+      # es.wikisource.org in a spanish language context.
+      # Do not prefix with http or https://
+      # mw_host: '{lang}.wikipedia.org'
       mwapi_req:
         body: "{{request.body}}"
         query: "{{ default(request.query, {}) }}"
diff --git a/lib/mw/ApiRequest.js b/lib/mw/ApiRequest.js
index 7175157..fcd42d9 100644
--- a/lib/mw/ApiRequest.js
+++ b/lib/mw/ApiRequest.js
@@ -90,7 +90,7 @@
        }
 
        getDomain( language ) {
-               return this.getSiteCode( language ) + '.wikipedia.org';
+               return ( this.context.conf.mw_host || '{lang}.wikipedia.org' 
).replace( '{lang}', language );
        }
 
        /**
diff --git a/lib/pageloader/PageLoader.js b/lib/pageloader/PageLoader.js
index dde851a..a5c8f35 100644
--- a/lib/pageloader/PageLoader.js
+++ b/lib/pageloader/PageLoader.js
@@ -1,7 +1,7 @@
 'use strict';
 
-var apiUtil = require( '../api-util' );
-
+const apiUtil = require( '../api-util' );
+const ApiRequest = require( '../mw/ApiRequest.js' );
 /**
  * Cheap body extraction.
  *
@@ -43,7 +43,7 @@
                domain = source;
        } else {
                // Assume the client means a WP project
-               domain = source + '.wikipedia.org';
+               domain = new ApiRequest( { context: this.app } ).getDomain( 
source );
        }
 
        if ( revision ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8196b70280a9d2b756c1a4b2e877288d79ce3fa7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
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

Reply via email to