mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 06:13:54 +00:00
Minerva should use FeatureManagers class
Bug: T182362 Depends-On: I6cc4a2ebcd75c054294daf329d94d35a02e50f8e Change-Id: I6ba5bf49b9060c31ad2224a437072b3426a45619
This commit is contained in:
parent
09a1f98ab3
commit
dede844830
|
@ -56,5 +56,9 @@
|
|||
"mobile-frontend-user-page-talk": "Talk",
|
||||
"mobile-frontend-user-page-uploads": "Uploads",
|
||||
"skinname-minerva": "MinervaNeue",
|
||||
"minerva-skin-desc": "A responsive mobile first skin"
|
||||
"minerva-skin-desc": "A responsive mobile first skin",
|
||||
"skin-minerva-mobile-option-MinervaShowCategoriesButton": "Categories",
|
||||
"skin-minerva-mobile-option-MinervaShowCategoriesButton-description": "View categories of pages",
|
||||
"skin-minerva-mobile-option-MinervaEnableBackToTop": "Jump to top",
|
||||
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Jump to top of the current page using a floating button"
|
||||
}
|
||||
|
|
|
@ -65,5 +65,9 @@
|
|||
"mobile-frontend-user-page-talk": "Text of the link to the user's talk page\n{{Identical|Talk}}",
|
||||
"mobile-frontend-user-page-uploads": "Text of the link to the user's uploads page\n{{Identical|Upload}}",
|
||||
"skinname-minerva": "{{name}}",
|
||||
"minerva-skin-desc": "{{desc|name=Minerva Neue|url=https://www.mediawiki.org/wiki/Skin:Minerva_Neue|what=skin}}"
|
||||
"minerva-skin-desc": "{{desc|name=Minerva Neue|url=https://www.mediawiki.org/wiki/Skin:Minerva_Neue|what=skin}}",
|
||||
"skin-minerva-mobile-option-MinervaShowCategoriesButton": "Label for categories mobile web beta feature.",
|
||||
"skin-minerva-mobile-option-MinervaShowCategoriesButton-description": "Description label for categories mobile web beta feature.",
|
||||
"skin-minerva-mobile-option-MinervaEnableBackToTop": "Label for jump to top mobile web beta feature",
|
||||
"skin-minerva-mobile-option-MinervaEnableBackToTop-description": "Description label for jump to top mobile web beta feature"
|
||||
}
|
||||
|
|
|
@ -27,6 +27,40 @@ class MinervaHooks {
|
|||
$lessVars['wgMinervaApplyKnownTemplateHacks'] = $config->get( 'MinervaApplyKnownTemplateHacks' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register mobile web beta features
|
||||
* @see https://www.mediawiki.org/wiki/
|
||||
* Extension:MobileFrontend/MobileFrontendFeaturesRegistration
|
||||
*
|
||||
* @param MobileFrontend\Features\FeaturesManager $featureManager
|
||||
* @return bool
|
||||
*/
|
||||
public static function onMobileFrontendFeaturesRegistration( $featureManager ) {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()
|
||||
->makeConfig( 'minerva' );
|
||||
|
||||
try {
|
||||
$featureManager->registerFeature(
|
||||
new MobileFrontend\Features\Feature(
|
||||
'MinervaShowCategoriesButton',
|
||||
'skin-minerva',
|
||||
$config->get( 'MinervaShowCategoriesButton' )
|
||||
)
|
||||
);
|
||||
$featureManager->registerFeature(
|
||||
new MobileFrontend\Features\Feature(
|
||||
'MinervaEnableBackToTop',
|
||||
'skin-minerva',
|
||||
$config->get( 'MinervaEnableBackToTop' )
|
||||
)
|
||||
);
|
||||
} catch ( RuntimeException $e ) {
|
||||
// features already registered...
|
||||
// due to a bug it's possible for this to run twice
|
||||
// https://phabricator.wikimedia.org/T165068
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skin registration callback.
|
||||
*/
|
||||
|
@ -132,13 +166,19 @@ class MinervaHooks {
|
|||
) {
|
||||
// setSkinOptions is not available
|
||||
if ( $skin instanceof SkinMinerva ) {
|
||||
$featureManager = \MediaWiki\MediaWikiServices::getInstance()
|
||||
->getService( 'MobileFrontend.FeaturesManager' );
|
||||
|
||||
$isBeta = $mobileContext->isBetaGroupMember();
|
||||
$skin->setSkinOptions( [
|
||||
SkinMinerva::OPTIONS_MOBILE_BETA
|
||||
=> $mobileContext->isBetaGroupMember(),
|
||||
=> $isBeta,
|
||||
|
||||
SkinMinerva::OPTION_CATEGORIES
|
||||
=> $mobileContext->getConfigVariable( 'MinervaShowCategoriesButton' ),
|
||||
=> $featureManager->isFeatureAvailableInContext( 'MinervaShowCategoriesButton',
|
||||
$mobileContext ),
|
||||
SkinMinerva::OPTION_BACK_TO_TOP
|
||||
=> $mobileContext->getConfigVariable( 'MinervaEnableBackToTop' ),
|
||||
=> $featureManager->isFeatureAvailableInContext( 'MinervaEnableBackToTop', $mobileContext ),
|
||||
SkinMinerva::OPTION_TOGGLING => true,
|
||||
SkinMinerva::OPTION_MOBILE_OPTIONS => true,
|
||||
] );
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
"minerva": "GlobalVarConfig::newInstance"
|
||||
},
|
||||
"Hooks": {
|
||||
"MobileFrontendFeaturesRegistration": [
|
||||
"MinervaHooks::onMobileFrontendFeaturesRegistration"
|
||||
],
|
||||
"RequestContextCreateSkinMobile": [
|
||||
"MinervaHooks::onRequestContextCreateSkinMobile"
|
||||
],
|
||||
|
@ -504,10 +507,12 @@
|
|||
],
|
||||
"MinervaAlwaysShowLanguageButton": true,
|
||||
"MinervaShowCategoriesButton": {
|
||||
"prefix": "skin-minerva-",
|
||||
"base": false,
|
||||
"beta": true
|
||||
},
|
||||
"MinervaEnableBackToTop": {
|
||||
"prefix": "skin-minerva-",
|
||||
"base": false,
|
||||
"beta": true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue