Marcoil has uploaded a new change for review.

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

Change subject: WIP: Bug 67540 - Load extension CSS modules
......................................................................

WIP: Bug 67540 - Load extension CSS modules

This patch adds extensions' CSS modules to the list of modules
passed to load.php from Parsoid's <head> output. It will be further
developed to also load other module parts like JS, messages, etc.

Change-Id: I2b96a96a296919920c1c13cc34e78c603a0faea2
---
M lib/mediawiki.ApiRequest.js
M lib/mediawiki.DOMPostProcessor.js
2 files changed, 36 insertions(+), 3 deletions(-)


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

diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index 9ccd964..ad01399 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -457,7 +457,8 @@
                action: 'parse',
                text: text,
                disablepp: 'true',
-               contentmodel: 'wikitext'
+               contentmodel: 'wikitext',
+               prop: 'text|modules'
        };
        var uri = env.conf.wiki.apiURI;
 
@@ -517,6 +518,33 @@
 
                // Add the source to the cache
                this.env.pageCache[this.text] = parsedHtml;
+
+               // Add the modules to the page data
+               var i;
+               if (data.parse.modules) {
+                       if (!this.env.page.extensionModules) {
+                               this.env.page.extensionModules = new Set();
+                       }
+                       for (i in data.parse.modules) { 
this.env.page.extensionModules.add(data.parse.modules[i]); }
+               }
+               if (data.parse.modulescripts) {
+                       if (!this.env.page.extensionModuleScripts) {
+                               this.env.page.extensionModuleScripts = new 
Set();
+                       }
+                       for (i in data.parse.modulescripts) { 
this.env.page.extensionModuleScripts.add(data.parse.modulescripts[i]); }
+               }
+               if (data.parse.modulestyles) {
+                       if (!this.env.page.extensionModuleStyles) {
+                               this.env.page.extensionModuleStyles = new Set();
+                       }
+                       for (i in data.parse.modulestyles) { 
this.env.page.extensionModuleStyles.add(data.parse.modulestyles[i]); }
+               }
+               if (data.parse.modulemessages) {
+                       if (!this.env.page.extensionModuleMessages) {
+                               this.env.page.extensionModuleMessages = new 
Set();
+                       }
+                       for (i in data.parse.modulemessages) { 
this.env.page.extensionModuleMessages.add(data.parse.modulemessages[i]); }
+               }
        } catch ( e2 ) {
                error = new DoesNotExistError( 'Could not expand extension 
content for ' +
                                this.title + e2 );
diff --git a/lib/mediawiki.DOMPostProcessor.js 
b/lib/mediawiki.DOMPostProcessor.js
index 636017c..cf7923b 100644
--- a/lib/mediawiki.DOMPostProcessor.js
+++ b/lib/mediawiki.DOMPostProcessor.js
@@ -343,8 +343,13 @@
                                'skins.vector.styles',
                                'site',
                                'mediawiki.skinning.content.parsoid'
-                       ],
-                       styleURI = env.conf.wiki.apiURI
+                       ];
+               if (env.page.extensionModuleStyles) {
+                       env.page.extensionModuleStyles.forEach(function 
(module) {
+                               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';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b96a96a296919920c1c13cc34e78c603a0faea2
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