Hoo man has uploaded a new change for review.

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

Change subject: Conditionally add the "capiunto.infobox.main" RL module
......................................................................

Conditionally add the "capiunto.infobox.main" RL module

Bug: 69540
Change-Id: Ifd2d1ea7da247462a72f780f63ac9813bb1db29a
---
M Capiunto.hooks.php
M Capiunto.php
M includes/LuaLibrary.php
M includes/lua/Infobox.lua
4 files changed, 15 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Capiunto 
refs/changes/65/163065/1

diff --git a/Capiunto.hooks.php b/Capiunto.hooks.php
index 680c196..a98fd65 100644
--- a/Capiunto.hooks.php
+++ b/Capiunto.hooks.php
@@ -74,19 +74,4 @@
                return true;
        }
 
-       /**
-        * Adds css for infoboxes.
-        * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
-        *
-        * @param OutputPage &$out
-        * @param Skin &$skin
-        *
-        * @return bool
-        */
-       public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin ) {
-               // @FIXME: Find a way to do this conditionally from Lua
-               $out->addModules( 'capiunto.infobox.main' );
-               return true;
-       }
-
 }
diff --git a/Capiunto.php b/Capiunto.php
index ae2e8f2..f26f212 100644
--- a/Capiunto.php
+++ b/Capiunto.php
@@ -29,7 +29,6 @@
 $wgHooks['UnitTestsList'][]                            = 
'\Capiunto\CapiuntoHooks::registerUnitTests';
 $wgHooks['ScribuntoExternalLibraries'][]       = 
'\Capiunto\CapiuntoHooks::registerScribuntoLibraries';
 $wgHooks['ScribuntoExternalLibraryPaths'][]    = 
'\Capiunto\CapiuntoHooks::registerScribuntoExternalLibraryPaths';
-$wgHooks['BeforePageDisplay'][]                                = 
'\Capiunto\CapiuntoHooks::onBeforePageDisplay';
 
 $commonModuleInfo = array(
        'localBasePath' => __DIR__ . '/resources',
diff --git a/includes/LuaLibrary.php b/includes/LuaLibrary.php
index c47f170..eeced15 100644
--- a/includes/LuaLibrary.php
+++ b/includes/LuaLibrary.php
@@ -17,7 +17,17 @@
         * Register the library
         */
        public function register() {
-               $this->getEngine()->registerInterface( __DIR__ . 
'/lua/Infobox.lua', array(), array() );
+               $lib = array(
+                       'addScribuntoModules' => array( $this, 
'addScribuntoModules' )
+               );
+
+               $this->getEngine()->registerInterface( __DIR__ . 
'/lua/Infobox.lua', $lib, array() );
        }
 
+       /**
+        * Allows Lua to dynamically add the RL modules required for Infoboxes.
+        */
+       public function addScribuntoModules() {
+               $this->getParser()->getOutput()->addModules( 
'capiunto.infobox.main' );
+       }
 }
diff --git a/includes/lua/Infobox.lua b/includes/lua/Infobox.lua
index fb1acbd..86798fb 100644
--- a/includes/lua/Infobox.lua
+++ b/includes/lua/Infobox.lua
@@ -15,6 +15,7 @@
 local infobox = {}
 local metatable = {}
 local methodtable = {}
+local php = mw_interface
 
 metatable.__index = methodtable
 
@@ -71,6 +72,9 @@
        render.renderRows( html, args )
        render.renderBottomRow( html, args )
 
+       -- Add the Scribunto modules needed to properly display the generated 
HTML
+       php.addScribuntoModules()
+
        return html
 end
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd2d1ea7da247462a72f780f63ac9813bb1db29a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Capiunto
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

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

Reply via email to