mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-12-01 17:36:49 +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
|
<?php
|
||||||
/**
|
/**
|
||||||
|
* Citizen - A responsive skin developed for the Star Citizen Wiki
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -23,9 +25,7 @@ namespace Citizen;
|
||||||
use ConfigException;
|
use ConfigException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use OutputPage;
|
|
||||||
use RequestContext;
|
use RequestContext;
|
||||||
use Skin;
|
|
||||||
use ThumbnailImage;
|
use ThumbnailImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,27 +35,6 @@ use ThumbnailImage;
|
||||||
* on<HookName>()
|
* on<HookName>()
|
||||||
*/
|
*/
|
||||||
class CitizenHooks {
|
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
|
* ResourceLoaderGetConfigVars hook handler for setting a config variable
|
||||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
||||||
|
|
|
@ -1,4 +1,25 @@
|
||||||
<?php
|
<?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;
|
use MediaWiki\MediaWikiServices;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,28 @@
|
||||||
<?php
|
<?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
|
* SkinTemplate class for the Citizen skin
|
||||||
*
|
|
||||||
* @ingroup Skins
|
* @ingroup Skins
|
||||||
*/
|
*/
|
||||||
class SkinCitizen extends SkinTemplate {
|
class SkinCitizen extends SkinTemplate {
|
||||||
|
@ -211,6 +231,7 @@ class SkinCitizen extends SkinTemplate {
|
||||||
*/
|
*/
|
||||||
public function getDefaultModules() {
|
public function getDefaultModules() {
|
||||||
$modules = parent::getDefaultModules();
|
$modules = parent::getDefaultModules();
|
||||||
|
$out = $this->getOutput();
|
||||||
|
|
||||||
// Replace the search module
|
// Replace the search module
|
||||||
if ( $this->getConfigValue( 'CitizenEnableSearch' ) === true ) {
|
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;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds all needed skin modules
|
* Adds all needed skin modules
|
||||||
|
* TODO: Replace with getDefaultModules() when we move to min 1.35
|
||||||
*/
|
*/
|
||||||
private function addModules() {
|
private function addModules() {
|
||||||
$this->out->addModuleStyles( [
|
$this->out->addModuleStyles( [
|
||||||
'mediawiki.skinning.content.externallinks',
|
'mediawiki.skinning.content.externallinks',
|
||||||
'skins.citizen.styles',
|
'skins.citizen.styles',
|
||||||
'skins.citizen.styles.fonts',
|
'skins.citizen.styles.fonts',
|
||||||
|
'skins.citizen.styles.toc',
|
||||||
'skins.citizen.icons',
|
'skins.citizen.icons',
|
||||||
'skins.citizen.icons.ca',
|
'skins.citizen.icons.ca',
|
||||||
'skins.citizen.icons.es',
|
'skins.citizen.icons.es',
|
||||||
|
@ -242,6 +271,11 @@ class SkinCitizen extends SkinTemplate {
|
||||||
'skins.citizen.icons.badges',
|
'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( [
|
$this->out->addModules( [
|
||||||
'skins.citizen.scripts',
|
'skins.citizen.scripts',
|
||||||
] );
|
] );
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
@import '../variables.less';
|
||||||
|
@import '../mixins.less';
|
||||||
|
|
||||||
.toc {
|
.toc {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: -1; // So that it is below float objects in content
|
z-index: -1; // So that it is below float objects in content
|
|
@ -8,7 +8,6 @@
|
||||||
@import 'common/content.less';
|
@import 'common/content.less';
|
||||||
@import 'common/typography.less';
|
@import 'common/typography.less';
|
||||||
@import 'common/hacks.less';
|
@import 'common/hacks.less';
|
||||||
@import 'common/toc.less';
|
|
||||||
@import 'common/wikitable.less';
|
@import 'common/wikitable.less';
|
||||||
@import 'common/scrollbar.less';
|
@import 'common/scrollbar.less';
|
||||||
@import 'common/reducemotion.less';
|
@import 'common/reducemotion.less';
|
||||||
|
|
17
skin.json
17
skin.json
|
@ -188,6 +188,14 @@
|
||||||
],
|
],
|
||||||
"styles": [ "resources/skins.citizen.styles.fonts/font-face.less" ]
|
"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": {
|
"skins.citizen.styles.search": {
|
||||||
"class": "ResourceLoaderSkinModule",
|
"class": "ResourceLoaderSkinModule",
|
||||||
"targets": [
|
"targets": [
|
||||||
|
@ -206,10 +214,14 @@
|
||||||
},
|
},
|
||||||
"skins.citizen.scripts": {
|
"skins.citizen.scripts": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"resources/skins.citizen.scripts/toc.js",
|
|
||||||
"resources/skins.citizen.scripts/search.js"
|
"resources/skins.citizen.scripts/search.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"skins.citizen.scripts.toc": {
|
||||||
|
"scripts": [
|
||||||
|
"resources/skins.citizen.scripts.toc/toc.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
"skins.citizen.scripts.search": {
|
"skins.citizen.scripts.search": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"resources/skins.citizen.scripts.search/underscore.partial.js",
|
"resources/skins.citizen.scripts.search/underscore.partial.js",
|
||||||
|
@ -517,9 +529,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
"BeforePageDisplay": [
|
|
||||||
"Citizen\\CitizenHooks::onBeforePageDisplay"
|
|
||||||
],
|
|
||||||
"ResourceLoaderGetConfigVars": [
|
"ResourceLoaderGetConfigVars": [
|
||||||
"Citizen\\CitizenHooks::onResourceLoaderGetConfigVars"
|
"Citizen\\CitizenHooks::onResourceLoaderGetConfigVars"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue