From 1145a1a3d44768d0e54594a590fbaff625e1774d Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Fri, 26 Nov 2021 17:27:00 -0800 Subject: [PATCH 1/6] Use skin extension registration --- SkinModernSkylight.php | 16 ++-------------- skin.json | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/SkinModernSkylight.php b/SkinModernSkylight.php index b04bc1d..e233251 100644 --- a/SkinModernSkylight.php +++ b/SkinModernSkylight.php @@ -12,10 +12,6 @@ } class SkinModernSkylight extends SkinTemplate { - - var $skinname = 'modernskylight', $stylename = 'ModernSkylight', - $template = 'ModernSkylightTemplate', $useHeadElement = true; - /** * Initializes output page and sets up skin-specific parameters * @param $out OutputPage object to initialize @@ -32,25 +28,17 @@ public function initPage( OutputPage $out ) { $out->addHeadItem( 'csshover', '"); + "/ModernSkylight/csshover{$min}.htc\")}"); // tab-size가 듣지 않는 IE를 위해 글꼴 강제 수정 $out->addHeadItem( 'fontoverride', '' ); - $out->addModuleScripts( 'skins.modern-skylight.js' ); if ($out->getTitle()->isMainPage()) { - $out->addModuleScripts( 'skins.modern-skylight.mainpage.js' ); + $out->addModules( 'skins.modern-skylight.mainpage.js' ); } - } - - function setupSkinUserCss( OutputPage $out ){ - global $wgStylePath; - - parent::setupSkinUserCss( $out ); - $out->addModuleStyles( 'skins.modern-skylight.css' ); if ($out->getTitle()->isMainPage()) { $out->addModuleStyles( 'skins.modern-skylight.mainpage.css' ); } diff --git a/skin.json b/skin.json index 4d18232..a8d2cbc 100644 --- a/skin.json +++ b/skin.json @@ -11,13 +11,28 @@ "license-name": "BSD-2", "type": "skin", "ValidSkinNames": { - "modernskylight": "ModernSkylight" + "modernskylight": { + "class": "SkinModernSkylight", + "args": [ + { + "name": "modernskylight", + "template": "ModernSkylightTemplate", + "styles": [ + "skins.modern-skylight.css" + ], + "scripts": [ + "skins.modern-skylight.js" + ] + } + ] + } }, "MessagesDirs": { "ModernSkylight": [ "i18n" ] }, + "manifest_version": 2, "AutoloadClasses": { "SkinModernSkylight": "SkinModernSkylight.php", "ModernSkylightTemplate": "ModernSkylightTemplate.php", From 2d992a76d21db0c9c91d3c9ac80cef5192c1e80a Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Fri, 26 Nov 2021 17:33:00 -0800 Subject: [PATCH 2/6] Use BeforePageDisplay hook for head modification --- SkinModernSkylight.php => ModernSkylightHooks.php | 11 ++++++----- skin.json | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) rename SkinModernSkylight.php => ModernSkylightHooks.php (85%) diff --git a/SkinModernSkylight.php b/ModernSkylightHooks.php similarity index 85% rename from SkinModernSkylight.php rename to ModernSkylightHooks.php index e233251..465395a 100644 --- a/SkinModernSkylight.php +++ b/ModernSkylightHooks.php @@ -11,20 +11,21 @@ die( -1 ); } -class SkinModernSkylight extends SkinTemplate { +class ModernSkylightHooks { /** * Initializes output page and sets up skin-specific parameters * @param $out OutputPage object to initialize */ - public function initPage( OutputPage $out ) { + public static function onBeforePageDisplay( OutputPage $out, &$skin ) { global $wgLocalStylePath; - - parent::initPage( $out ); + if ( $skin->getSkinName() !== 'modernskylight' ) { + return; + } // Append CSS which includes IE only behavior fixes for hover support - // this is better than including this in a CSS file since it doesn't // wait for the CSS file to load before fetching the HTC file. - $min = $this->getRequest()->getFuzzyBool( 'debug' ) ? '' : '.min'; + $min = $out->getRequest()->getFuzzyBool( 'debug' ) ? '' : '.min'; $out->addHeadItem( 'csshover', '