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

Change subject: Let the page loader accept full project domains as params as 
well
......................................................................


Let the page loader accept full project domains as params as well

There are subtleties in difference in languages (and its variants) used
on WP projects, so allow clients to specify the full domain for which to
fetch and segment the page as well.

Also, update the Accept header to use the latest HTML spec version
(v1.5.0).

Bug: T107914
Change-Id: Idc5e2bd989fbf9a990f420943c9cc811fbd247e6
---
M pageloader/PageLoader.js
M spec.yaml
2 files changed, 14 insertions(+), 10 deletions(-)

Approvals:
  Mobrovac: Looks good to me, approved
  jenkins-bot: Verified
  Nikerabbit: Looks good to me, but someone else must approve



diff --git a/pageloader/PageLoader.js b/pageloader/PageLoader.js
index a5fb761..c29ed44 100644
--- a/pageloader/PageLoader.js
+++ b/pageloader/PageLoader.js
@@ -29,18 +29,22 @@
 }
 
 /**
- * @param {string} page
- * @param {string} sourceLanguage
- * @param {string} revision
+ * @param {string} page The page title
+ * @param {string} source The language code or the domain of the wiki
+ * @param {string} revision The revision id
  * @return {Promise}
  */
-PageLoader.prototype.load = function ( page, sourceLanguage, revision ) {
+PageLoader.prototype.load = function ( page, source, revision ) {
        var path, domain, restReq;
 
        path = 'page/html/' + encodeURIComponent( page );
-       // TODO: When we support projects other than wikipedia, probably
-       // the client need to pass domain instead of language.
-       domain = sourceLanguage + '.wikipedia.org';
+       if ( /.+\.org$/.test( source ) ) {
+               // We got an actual domain
+               domain = source;
+       } else {
+               // Assume the client means a WP project
+               domain = source + '.wikipedia.org';
+       }
 
        if ( revision ) {
                path += '/' + revision;
@@ -49,8 +53,8 @@
        restReq = {
                method: 'get',
                headers: {
-                       // See https://www.mediawiki.org/wiki/Specs/HTML/1.2.1
-                       Accept: 'text/html; charset=utf-8; 
profile="https://www.mediawiki.org/wiki/Specs/HTML/1.2.1";'
+                       // See https://www.mediawiki.org/wiki/Specs/HTML/1.5.0
+                       accept: 'text/html; charset=utf-8; 
profile="https://www.mediawiki.org/wiki/Specs/HTML/1.5.0";'
                }
        };
 
diff --git a/spec.yaml b/spec.yaml
index 85a69db..ab5766c 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -63,7 +63,7 @@
       parameters:
         - name: language
           in: path
-          description: The language code of the wiki
+          description: The language code or the domain of the wiki
           type: string
           required: true
         - name: title

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idc5e2bd989fbf9a990f420943c9cc811fbd247e6
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Mobrovac <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to