Ori.livneh has uploaded a new change for review.

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

Change subject: Only load ext.wikihiero styles if page contains hieroglyphics
......................................................................

Only load ext.wikihiero styles if page contains hieroglyphics

We can restrict the loading of the ext.wikihiero CSS module to those pages on
which it serves some purpose by adding the module in the parser hook.

Change-Id: I5a0c4cbcbca776e48579b2c10907e70ff9df1512
---
M wikihiero.body.php
M wikihiero.php
2 files changed, 2 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/wikihiero 
refs/changes/62/230262/1

diff --git a/wikihiero.body.php b/wikihiero.body.php
index e84db5c..725a81e 100644
--- a/wikihiero.body.php
+++ b/wikihiero.body.php
@@ -64,10 +64,11 @@
        /**
         *
         */
-       public static function parserHook( $input ) {
+       public static function parserHook( $input, $args = array(), $parser ) {
                $hiero = new WikiHiero();
                // Strip newlines to avoid breakage in the wiki parser block 
pass
                return str_replace( "\n", " ", $hiero->render( $input ) );
+               $parser->getOutput()->addModuleStyles( 'ext.wikihiero' );
        }
 
        public function getScale() {
diff --git a/wikihiero.php b/wikihiero.php
index 1a19d97..c15eda3 100644
--- a/wikihiero.php
+++ b/wikihiero.php
@@ -24,7 +24,6 @@
 define( 'WIKIHIERO_VERSION', '1.1' );
 
 $wgHooks['ParserFirstCallInit'][] = 'wfRegisterWikiHiero';
-$wgHooks['BeforePageDisplay'][] = 'wfHieroBeforePageDisplay';
 
 // Register MediaWiki extension
 $wgExtensionCredits['parserhook'][] = array(
@@ -103,14 +102,5 @@
  */
 function wfRegisterWikiHiero( &$parser ) {
        $parser->setHook( 'hiero', 'WikiHiero::parserHook' );
-       return true;
-}
-
-/**
- * @param $out OutputPage
- * @return bool
- */
-function wfHieroBeforePageDisplay( $out ) {
-       $out->addModuleStyles( 'ext.wikihiero' );
        return true;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a0c4cbcbca776e48579b2c10907e70ff9df1512
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/wikihiero
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

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

Reply via email to