[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
Legoktm has submitted this change and it was merged. Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 (cherry picked from commit 3e05e3810ed50486cbbf305720a911152ceeef56) --- M GlobalCssJs.hooks.php M ResourceLoaderGlobalModule.php A ResourceLoaderGlobalSiteCssModule.php A ResourceLoaderGlobalSiteJsModule.php M ResourceLoaderGlobalSiteModule.php A ResourceLoaderGlobalUserCssModule.php A ResourceLoaderGlobalUserJsModule.php M ResourceLoaderGlobalUserModule.php M extension.json M tests/ResourceLoaderGlobalSiteModuleTest.php M tests/ResourceLoaderGlobalUserModuleTest.php 11 files changed, 270 insertions(+), 59 deletions(-) Approvals: Legoktm: Verified; Looks good to me, approved diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..67feef1 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -25,7 +25,7 @@ * @return bool */ static function onBeforePageDisplay( OutputPage $out ) { - $out->addModuleStyles( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); + $out->addModuleStyles( array( 'ext.globalCssJs.user.styles', 'ext.globalCssJs.site.styles' ) ); $out->addModuleScripts( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); return true; @@ -57,15 +57,27 @@ return true; } - $user = array( - 'class' => 'ResourceLoaderGlobalUserModule', + $userJs = array( + 'class' => 'ResourceLoaderGlobalUserJsModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.user', $user ); + $resourceLoader->register( 'ext.globalCssJs.user', $userJs ); - $site = array( - 'class' => 'ResourceLoaderGlobalSiteModule', + $userCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalUserCssModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.site', $site ); + $resourceLoader->register( 'ext.globalCssJs.user.styles', $userCss ); + + $siteJs = array( + 'class' => 'ResourceLoaderGlobalSiteJsModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site', $siteJs ); + + $siteCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalSiteCssModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site.styles', $siteCss ); return true; } diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php index daedaca..7117f88 100644 --- a/ResourceLoaderGlobalModule.php +++ b/ResourceLoaderGlobalModule.php @@ -40,9 +40,21 @@ */ protected $source; + /** @var string Position on the page to load this module at */ + protected $position = 'bottom'; + public function __construct( $options ) { - $this->wiki = $options['wiki']; - $this->source = $options['source']; + foreach ( $options as $member => $option ) { + switch ( $member ) { + case 'position': + $this->isPositionDefined = true; + // fall through + case 'wiki': + case 'source': + $this->{$member} = (string)$option; + break; + } + } } /** @@ -63,4 +75,7 @@ } } + public function getPosition() { + return $this->position; + } } diff --git a/ResourceLoaderGlobalSiteCssModule.php b/ResourceLoaderGlobalSiteCssModule.php new file mode 100644 index 000..7ecf5f6 --- /dev/null +++ b/ResourceLoaderGlobalSiteCssModule.php @@ -0,0 +1,40 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Kunal Mehta + */ + +/** + * Module for sitewide global CSS customizations + */ +class ResourceLoaderGlobalSiteCssModule extends ResourceLoaderGlobalSiteModule { + protected function doGetPages( ResourceLoaderContext $context ) { + $pages = array(); + +
[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/214401 Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 (cherry picked from commit 3e05e3810ed50486cbbf305720a911152ceeef56) --- M GlobalCssJs.hooks.php M ResourceLoaderGlobalModule.php A ResourceLoaderGlobalSiteCssModule.php A ResourceLoaderGlobalSiteJsModule.php M ResourceLoaderGlobalSiteModule.php A ResourceLoaderGlobalUserCssModule.php A ResourceLoaderGlobalUserJsModule.php M ResourceLoaderGlobalUserModule.php M extension.json M tests/ResourceLoaderGlobalModuleTest.php M tests/ResourceLoaderGlobalSiteModuleTest.php M tests/ResourceLoaderGlobalUserModuleTest.php 12 files changed, 285 insertions(+), 59 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs refs/changes/01/214401/1 diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..67feef1 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -25,7 +25,7 @@ * @return bool */ static function onBeforePageDisplay( OutputPage $out ) { - $out->addModuleStyles( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); + $out->addModuleStyles( array( 'ext.globalCssJs.user.styles', 'ext.globalCssJs.site.styles' ) ); $out->addModuleScripts( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); return true; @@ -57,15 +57,27 @@ return true; } - $user = array( - 'class' => 'ResourceLoaderGlobalUserModule', + $userJs = array( + 'class' => 'ResourceLoaderGlobalUserJsModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.user', $user ); + $resourceLoader->register( 'ext.globalCssJs.user', $userJs ); - $site = array( - 'class' => 'ResourceLoaderGlobalSiteModule', + $userCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalUserCssModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.site', $site ); + $resourceLoader->register( 'ext.globalCssJs.user.styles', $userCss ); + + $siteJs = array( + 'class' => 'ResourceLoaderGlobalSiteJsModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site', $siteJs ); + + $siteCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalSiteCssModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site.styles', $siteCss ); return true; } diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php index daedaca..7117f88 100644 --- a/ResourceLoaderGlobalModule.php +++ b/ResourceLoaderGlobalModule.php @@ -40,9 +40,21 @@ */ protected $source; + /** @var string Position on the page to load this module at */ + protected $position = 'bottom'; + public function __construct( $options ) { - $this->wiki = $options['wiki']; - $this->source = $options['source']; + foreach ( $options as $member => $option ) { + switch ( $member ) { + case 'position': + $this->isPositionDefined = true; + // fall through + case 'wiki': + case 'source': + $this->{$member} = (string)$option; + break; + } + } } /** @@ -63,4 +75,7 @@ } } + public function getPosition() { + return $this->position; + } } diff --git a/ResourceLoaderGlobalSiteCssModule.php b/ResourceLoaderGlobalSiteCssModule.php new file mode 100644 index 000..7ecf5f6 --- /dev/null +++ b/ResourceLoaderGlobalSiteCssModule.php @@ -0,0 +1,40 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Kunal Mehta + */ + +/** + * Module for sitewide global CSS customizations + */ +class ResourceLoaderGlobalSiteCssModule extends ResourceLoaderGlobalSiteModule { +
[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
jenkins-bot has submitted this change and it was merged. Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 (cherry picked from commit 3e05e3810ed50486cbbf305720a911152ceeef56) --- M GlobalCssJs.hooks.php M ResourceLoaderGlobalModule.php A ResourceLoaderGlobalSiteCssModule.php A ResourceLoaderGlobalSiteJsModule.php M ResourceLoaderGlobalSiteModule.php A ResourceLoaderGlobalUserCssModule.php A ResourceLoaderGlobalUserJsModule.php M ResourceLoaderGlobalUserModule.php M extension.json M tests/ResourceLoaderGlobalModuleTest.php M tests/ResourceLoaderGlobalSiteModuleTest.php M tests/ResourceLoaderGlobalUserModuleTest.php 12 files changed, 285 insertions(+), 59 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..67feef1 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -25,7 +25,7 @@ * @return bool */ static function onBeforePageDisplay( OutputPage $out ) { - $out->addModuleStyles( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); + $out->addModuleStyles( array( 'ext.globalCssJs.user.styles', 'ext.globalCssJs.site.styles' ) ); $out->addModuleScripts( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); return true; @@ -57,15 +57,27 @@ return true; } - $user = array( - 'class' => 'ResourceLoaderGlobalUserModule', + $userJs = array( + 'class' => 'ResourceLoaderGlobalUserJsModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.user', $user ); + $resourceLoader->register( 'ext.globalCssJs.user', $userJs ); - $site = array( - 'class' => 'ResourceLoaderGlobalSiteModule', + $userCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalUserCssModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.site', $site ); + $resourceLoader->register( 'ext.globalCssJs.user.styles', $userCss ); + + $siteJs = array( + 'class' => 'ResourceLoaderGlobalSiteJsModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site', $siteJs ); + + $siteCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalSiteCssModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site.styles', $siteCss ); return true; } diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php index daedaca..7117f88 100644 --- a/ResourceLoaderGlobalModule.php +++ b/ResourceLoaderGlobalModule.php @@ -40,9 +40,21 @@ */ protected $source; + /** @var string Position on the page to load this module at */ + protected $position = 'bottom'; + public function __construct( $options ) { - $this->wiki = $options['wiki']; - $this->source = $options['source']; + foreach ( $options as $member => $option ) { + switch ( $member ) { + case 'position': + $this->isPositionDefined = true; + // fall through + case 'wiki': + case 'source': + $this->{$member} = (string)$option; + break; + } + } } /** @@ -63,4 +75,7 @@ } } + public function getPosition() { + return $this->position; + } } diff --git a/ResourceLoaderGlobalSiteCssModule.php b/ResourceLoaderGlobalSiteCssModule.php new file mode 100644 index 000..7ecf5f6 --- /dev/null +++ b/ResourceLoaderGlobalSiteCssModule.php @@ -0,0 +1,40 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Kunal Mehta + */ + +/** + * Module for sitewide global CSS customizations + */ +class ResourceLoaderGlobalSiteCssModule extends ResourceLoaderGlobalSiteModule { + protected function doGetPages( ResourceLoaderContext $
[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/214399 Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 (cherry picked from commit 3e05e3810ed50486cbbf305720a911152ceeef56) --- M GlobalCssJs.hooks.php M ResourceLoaderGlobalModule.php A ResourceLoaderGlobalSiteCssModule.php A ResourceLoaderGlobalSiteJsModule.php M ResourceLoaderGlobalSiteModule.php A ResourceLoaderGlobalUserCssModule.php A ResourceLoaderGlobalUserJsModule.php M ResourceLoaderGlobalUserModule.php M extension.json M tests/ResourceLoaderGlobalModuleTest.php M tests/ResourceLoaderGlobalSiteModuleTest.php M tests/ResourceLoaderGlobalUserModuleTest.php 12 files changed, 285 insertions(+), 59 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs refs/changes/99/214399/1 diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..67feef1 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -25,7 +25,7 @@ * @return bool */ static function onBeforePageDisplay( OutputPage $out ) { - $out->addModuleStyles( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); + $out->addModuleStyles( array( 'ext.globalCssJs.user.styles', 'ext.globalCssJs.site.styles' ) ); $out->addModuleScripts( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); return true; @@ -57,15 +57,27 @@ return true; } - $user = array( - 'class' => 'ResourceLoaderGlobalUserModule', + $userJs = array( + 'class' => 'ResourceLoaderGlobalUserJsModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.user', $user ); + $resourceLoader->register( 'ext.globalCssJs.user', $userJs ); - $site = array( - 'class' => 'ResourceLoaderGlobalSiteModule', + $userCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalUserCssModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.site', $site ); + $resourceLoader->register( 'ext.globalCssJs.user.styles', $userCss ); + + $siteJs = array( + 'class' => 'ResourceLoaderGlobalSiteJsModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site', $siteJs ); + + $siteCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalSiteCssModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site.styles', $siteCss ); return true; } diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php index daedaca..7117f88 100644 --- a/ResourceLoaderGlobalModule.php +++ b/ResourceLoaderGlobalModule.php @@ -40,9 +40,21 @@ */ protected $source; + /** @var string Position on the page to load this module at */ + protected $position = 'bottom'; + public function __construct( $options ) { - $this->wiki = $options['wiki']; - $this->source = $options['source']; + foreach ( $options as $member => $option ) { + switch ( $member ) { + case 'position': + $this->isPositionDefined = true; + // fall through + case 'wiki': + case 'source': + $this->{$member} = (string)$option; + break; + } + } } /** @@ -63,4 +75,7 @@ } } + public function getPosition() { + return $this->position; + } } diff --git a/ResourceLoaderGlobalSiteCssModule.php b/ResourceLoaderGlobalSiteCssModule.php new file mode 100644 index 000..7ecf5f6 --- /dev/null +++ b/ResourceLoaderGlobalSiteCssModule.php @@ -0,0 +1,40 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Kunal Mehta + */ + +/** + * Module for sitewide global CSS customizations + */ +class ResourceLoaderGlobalSiteCssModule extends ResourceLoaderGlobalSiteModule { +
[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
jenkins-bot has submitted this change and it was merged. Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 --- M GlobalCssJs.hooks.php M ResourceLoaderGlobalModule.php A ResourceLoaderGlobalSiteCssModule.php A ResourceLoaderGlobalSiteJsModule.php M ResourceLoaderGlobalSiteModule.php A ResourceLoaderGlobalUserCssModule.php A ResourceLoaderGlobalUserJsModule.php M ResourceLoaderGlobalUserModule.php M extension.json M tests/ResourceLoaderGlobalModuleTest.php M tests/ResourceLoaderGlobalSiteModuleTest.php M tests/ResourceLoaderGlobalUserModuleTest.php 12 files changed, 285 insertions(+), 59 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..67feef1 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -25,7 +25,7 @@ * @return bool */ static function onBeforePageDisplay( OutputPage $out ) { - $out->addModuleStyles( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); + $out->addModuleStyles( array( 'ext.globalCssJs.user.styles', 'ext.globalCssJs.site.styles' ) ); $out->addModuleScripts( array( 'ext.globalCssJs.user', 'ext.globalCssJs.site' ) ); return true; @@ -57,15 +57,27 @@ return true; } - $user = array( - 'class' => 'ResourceLoaderGlobalUserModule', + $userJs = array( + 'class' => 'ResourceLoaderGlobalUserJsModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.user', $user ); + $resourceLoader->register( 'ext.globalCssJs.user', $userJs ); - $site = array( - 'class' => 'ResourceLoaderGlobalSiteModule', + $userCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalUserCssModule', ) + $config; - $resourceLoader->register( 'ext.globalCssJs.site', $site ); + $resourceLoader->register( 'ext.globalCssJs.user.styles', $userCss ); + + $siteJs = array( + 'class' => 'ResourceLoaderGlobalSiteJsModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site', $siteJs ); + + $siteCss = array( + 'position' => 'top', + 'class' => 'ResourceLoaderGlobalSiteCssModule', + ) + $config; + $resourceLoader->register( 'ext.globalCssJs.site.styles', $siteCss ); return true; } diff --git a/ResourceLoaderGlobalModule.php b/ResourceLoaderGlobalModule.php index daedaca..7117f88 100644 --- a/ResourceLoaderGlobalModule.php +++ b/ResourceLoaderGlobalModule.php @@ -40,9 +40,21 @@ */ protected $source; + /** @var string Position on the page to load this module at */ + protected $position = 'bottom'; + public function __construct( $options ) { - $this->wiki = $options['wiki']; - $this->source = $options['source']; + foreach ( $options as $member => $option ) { + switch ( $member ) { + case 'position': + $this->isPositionDefined = true; + // fall through + case 'wiki': + case 'source': + $this->{$member} = (string)$option; + break; + } + } } /** @@ -63,4 +75,7 @@ } } + public function getPosition() { + return $this->position; + } } diff --git a/ResourceLoaderGlobalSiteCssModule.php b/ResourceLoaderGlobalSiteCssModule.php new file mode 100644 index 000..7ecf5f6 --- /dev/null +++ b/ResourceLoaderGlobalSiteCssModule.php @@ -0,0 +1,40 @@ +http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Kunal Mehta + */ + +/** + * Module for sitewide global CSS customizations + */ +class ResourceLoaderGlobalSiteCssModule extends ResourceLoaderGlobalSiteModule { + protected function doGetPages( ResourceLoaderContext $context ) { + $pages = array(); + + $conf
[MediaWiki-commits] [Gerrit] Explicitly define module position - change (mediawiki...GlobalCssJs)
Gilles has uploaded a new change for review. https://gerrit.wikimedia.org/r/207088 Change subject: Explicitly define module position .. Explicitly define module position Style modules currently added through addModuleStyles default to being in the head ("top" position). This is an unhealthy default, since only critical styles that are needed at pageload should be in the head. In order to be able to switch the default to "bottom", existing module positions have to be defined explicitly. Bug: T97410 Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 --- M GlobalCssJs.hooks.php 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs refs/changes/88/207088/1 diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php index 4bf994e..f617a22 100644 --- a/GlobalCssJs.hooks.php +++ b/GlobalCssJs.hooks.php @@ -58,11 +58,13 @@ } $user = array( + 'position' => 'top', 'class' => 'ResourceLoaderGlobalUserModule', ) + $config; $resourceLoader->register( 'ext.globalCssJs.user', $user ); $site = array( + 'position' => 'top', 'class' => 'ResourceLoaderGlobalSiteModule', ) + $config; $resourceLoader->register( 'ext.globalCssJs.site', $site ); -- To view, visit https://gerrit.wikimedia.org/r/207088 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31e3e68487d91d0bee2be5b0b4d1c63344830c67 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GlobalCssJs Gerrit-Branch: master Gerrit-Owner: Gilles ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits