mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-29 08:35:23 +00:00
Merge pull request #141 from StarCitizenTools/dev
Various improvement and clean up
This commit is contained in:
commit
f9ac569796
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin developed for the Star Citizen Wiki
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
|
@ -23,9 +25,7 @@ namespace Citizen;
|
|||
use ConfigException;
|
||||
use Exception;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use OutputPage;
|
||||
use RequestContext;
|
||||
use Skin;
|
||||
use ThumbnailImage;
|
||||
|
||||
/**
|
||||
|
@ -35,27 +35,6 @@ use ThumbnailImage;
|
|||
* on<HookName>()
|
||||
*/
|
||||
class CitizenHooks {
|
||||
/**
|
||||
* @param OutputPage $out
|
||||
* @param Skin $skin
|
||||
* @return bool
|
||||
*/
|
||||
public static function onBeforePageDisplay( $out, $skin ) {
|
||||
try {
|
||||
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' );
|
||||
$lazyloadEnabled = $config->get( 'CitizenEnableLazyload' );
|
||||
} catch ( Exception $e ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $lazyloadEnabled === true ) {
|
||||
$out->addModules( 'skins.citizen.styles.lazyload' );
|
||||
$out->addModules( 'skins.citizen.scripts.lazyload' );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceLoaderGetConfigVars hook handler for setting a config variable
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
||||
|
|
|
@ -1,4 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin developed for the Star Citizen Wiki
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup Skins
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
|
|
|
@ -1,8 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin developed for the Star Citizen Wiki
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup Skins
|
||||
*/
|
||||
|
||||
/**
|
||||
* SkinTemplate class for the Citizen skin
|
||||
*
|
||||
* @ingroup Skins
|
||||
*/
|
||||
class SkinCitizen extends SkinTemplate {
|
||||
|
@ -211,6 +231,7 @@ class SkinCitizen extends SkinTemplate {
|
|||
*/
|
||||
public function getDefaultModules() {
|
||||
$modules = parent::getDefaultModules();
|
||||
$out = $this->getOutput();
|
||||
|
||||
// Replace the search module
|
||||
if ( $this->getConfigValue( 'CitizenEnableSearch' ) === true ) {
|
||||
|
@ -221,17 +242,25 @@ class SkinCitizen extends SkinTemplate {
|
|||
];
|
||||
}
|
||||
|
||||
if ( $out->isTOCEnabled() ) {
|
||||
// Disable style condition loading due to pop in
|
||||
// $modules['content'][] = 'skins.citizen.styles.toc';
|
||||
$modules['content'][] = 'skins.citizen.scripts.toc';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all needed skin modules
|
||||
* TODO: Replace with getDefaultModules() when we move to min 1.35
|
||||
*/
|
||||
private function addModules() {
|
||||
$this->out->addModuleStyles( [
|
||||
'mediawiki.skinning.content.externallinks',
|
||||
'skins.citizen.styles',
|
||||
'skins.citizen.styles.fonts',
|
||||
'skins.citizen.styles.toc',
|
||||
'skins.citizen.icons',
|
||||
'skins.citizen.icons.ca',
|
||||
'skins.citizen.icons.es',
|
||||
|
@ -242,6 +271,11 @@ class SkinCitizen extends SkinTemplate {
|
|||
'skins.citizen.icons.badges',
|
||||
] );
|
||||
|
||||
// Add lazyload-related modules
|
||||
if ( $this->getConfigValue( 'CitizenEnableLazyload' ) === true ) {
|
||||
$this->out->addModuleStyles( [ 'skins.citizen.styles.lazyload' ] );
|
||||
$this->out->addModules( [ 'skins.citizen.scripts.lazyload' ] );
|
||||
}
|
||||
$this->out->addModules( [
|
||||
'skins.citizen.scripts',
|
||||
] );
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
@import '../variables.less';
|
||||
@import '../mixins.less';
|
||||
|
||||
.toc {
|
||||
position: fixed;
|
||||
z-index: -1; // So that it is below float objects in content
|
|
@ -8,7 +8,6 @@
|
|||
@import 'common/content.less';
|
||||
@import 'common/typography.less';
|
||||
@import 'common/hacks.less';
|
||||
@import 'common/toc.less';
|
||||
@import 'common/wikitable.less';
|
||||
@import 'common/scrollbar.less';
|
||||
@import 'common/reducemotion.less';
|
||||
|
|
17
skin.json
17
skin.json
|
@ -188,6 +188,14 @@
|
|||
],
|
||||
"styles": [ "resources/skins.citizen.styles.fonts/font-face.less" ]
|
||||
},
|
||||
"skins.citizen.styles.toc": {
|
||||
"class": "ResourceLoaderSkinModule",
|
||||
"targets": [
|
||||
"desktop",
|
||||
"mobile"
|
||||
],
|
||||
"styles": [ "resources/skins.citizen.styles.toc/toc.less" ]
|
||||
},
|
||||
"skins.citizen.styles.search": {
|
||||
"class": "ResourceLoaderSkinModule",
|
||||
"targets": [
|
||||
|
@ -206,10 +214,14 @@
|
|||
},
|
||||
"skins.citizen.scripts": {
|
||||
"scripts": [
|
||||
"resources/skins.citizen.scripts/toc.js",
|
||||
"resources/skins.citizen.scripts/search.js"
|
||||
]
|
||||
},
|
||||
"skins.citizen.scripts.toc": {
|
||||
"scripts": [
|
||||
"resources/skins.citizen.scripts.toc/toc.js"
|
||||
]
|
||||
},
|
||||
"skins.citizen.scripts.search": {
|
||||
"scripts": [
|
||||
"resources/skins.citizen.scripts.search/underscore.partial.js",
|
||||
|
@ -517,9 +529,6 @@
|
|||
}
|
||||
},
|
||||
"Hooks": {
|
||||
"BeforePageDisplay": [
|
||||
"Citizen\\CitizenHooks::onBeforePageDisplay"
|
||||
],
|
||||
"ResourceLoaderGetConfigVars": [
|
||||
"Citizen\\CitizenHooks::onResourceLoaderGetConfigVars"
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue