Marcoil has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/187591

Change subject: T86902: Add new local setting for CSS modules load URI
......................................................................

T86902: Add new local setting for CSS modules load URI

Set parsoidConfig.modulesLoadURI to true to use bits.wikimedia.org,
any string to use it as the URI or undefined to use the MW API URI.

Change-Id: I4390bfc8afa4167ec7db788c9ec2a468afbb776b
---
M api/localsettings.js.example
M lib/mediawiki.DOMPostProcessor.js
M lib/mediawiki.ParsoidConfig.js
3 files changed, 27 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/91/187591/1

diff --git a/api/localsettings.js.example b/api/localsettings.js.example
index 7308af3..4a543e9 100644
--- a/api/localsettings.js.example
+++ b/api/localsettings.js.example
@@ -47,4 +47,10 @@
        // Require SSL certificates to be valid (default true)
        // Set to false when using self-signed SSL certificates
        //parsoidConfig.strictSSL = false;
+
+       // Use a different server for CSS style modules.
+       // Set to true to use bits.wikimedia.org, or to a string with the URI.
+       // Leaving it indefined (the default) will use the same URI as the MW 
API,
+       // changing api.php for load.php.
+       //parsoidConfig.modulesLoadURI = true;
 };
diff --git a/lib/mediawiki.DOMPostProcessor.js 
b/lib/mediawiki.DOMPostProcessor.js
index 7063fec..95bc39e 100644
--- a/lib/mediawiki.DOMPostProcessor.js
+++ b/lib/mediawiki.DOMPostProcessor.js
@@ -348,10 +348,8 @@
                                modules.push(module);
                        });
                }
-               var styleURI = env.conf.wiki.apiURI
-                               .replace(/^http:\/\//, '//') // proto-relative
-                               .replace(/\/api.php$/, '/load.php')
-                       + '?modules=' + modules.join('|') + 
'&only=styles&debug=true&skin=vector';
+               var styleURI = 
env.conf.parsoid.getModulesLoadURI(env.conf.wiki.apiURI) +
+                       '?modules=' + modules.join('|') + 
'&only=styles&debug=true&skin=vector';
                appendToHead( document, 'link', { rel: 'stylesheet', href: 
styleURI } );
        }
 
diff --git a/lib/mediawiki.ParsoidConfig.js b/lib/mediawiki.ParsoidConfig.js
index b8fb115..62ac30a 100644
--- a/lib/mediawiki.ParsoidConfig.js
+++ b/lib/mediawiki.ParsoidConfig.js
@@ -218,6 +218,25 @@
 ParsoidConfig.prototype.defaultAPIProxyURI = undefined;
 
 /**
+ * The server from which to load style modules.
+ */
+ParsoidConfig.prototype.modulesLoadURI = undefined;
+ParsoidConfig.prototype.getModulesLoadURI = function (apiURI) {
+       var loadURI;
+       // If not set, use the same as the API
+       if (this.modulesLoadURI && this.modulesLoadURI !== true) {
+               return this.modulesLoadURI;
+       } else if (this.modulesLoadURI === true) {
+               // Use bits.wikimedia.org, we need the site URI
+               loadURI = apiURI.replace(/^http:\/\//, '//bits.wikimedia.org/');
+       } else {
+               // Use the API URI
+               loadURI = apiURI.replace(/^http:\/\//, '//');
+       }
+       return loadURI.replace(/\/api.php$/, '/load.php');
+};
+
+/**
  * Load WMF sites in the interwikiMap from the cached sitematrix.json
  */
 ParsoidConfig.prototype.loadWMF = true;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4390bfc8afa4167ec7db788c9ec2a468afbb776b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Marcoil <marc...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to