Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lakejason0 committed Dec 22, 2023
2 parents 2b62d48 + a96a62a commit 01abe0d
Show file tree
Hide file tree
Showing 12 changed files with 677 additions and 380 deletions.
22 changes: 11 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"extends": [
"wikimedia/client-es6",
"wikimedia/jquery",
"wikimedia/mediawiki"
],
"rules": {
"compat/compat": "off",
"vue/no-v-html": "off"
}
}
"root": true,
"extends": [
"wikimedia/client-es6",
"wikimedia/jquery",
"wikimedia/mediawiki"
],
"rules": {
"compat/compat": "off",
"vue/no-v-html": "off"
}
}
24 changes: 24 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PHP build
on:
[ pull_request, push ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.4, 8.0, 8.1, 8.2 ]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Install dependencies
run: composer install --prefer-dist --no-interaction --ansi

- name: Running phpcs
run: composer run-script cs
14 changes: 7 additions & 7 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "stylelint-config-wikimedia",
"rules": {
"selector-max-id": null,
"no-descending-specificity": null,
"indentation": 2
}
}
"extends": "stylelint-config-wikimedia",
"rules": {
"selector-max-id": null,
"no-descending-specificity": null,
"indentation": 2
}
}
8 changes: 5 additions & 3 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
The Lakeus skin is written by Lakejason0, Light beacon, Dianliang233, Winston Sung and other contributors to the skin. See https://github.com/lakejason0/mediawiki-skins-Lakeus/graphs/contributors for the list of all contributors.
The Lakeus skin is written by Lakejason0, Light beacon, Dianliang233, Winston Sung and other contributors to the skin.
See https://github.com/lakejason0/mediawiki-skins-Lakeus/graphs/contributors for the list of all contributors.

Translations are done by Lakejason0 (`zh-hans`, `zh-hant`, `zh-hk`), Winston Sung (`zh-hant`), Olvcpr423 (`yue`) and other translators on Translatewiki.net. See https://translatewiki.net/wiki/Special:MessageGroupStats?group=mwgithub-lakeus&suppressempty=1&x=D for the message group statistics of the skin.
Translations are done by Lakejason0 (`zh-hans`, `zh-hant`, `zh-hk`), Winston Sung (`zh-hant`), Olvcpr423 (`yue`) and other translators on translatewiki.net.
See https://translatewiki.net/wiki/Special:MessageGroupStats?group=mwgithub-lakeus&suppressempty=1&x=D for the message group statistics of the skin.

Special thanks to Timeless, Vector, Minerva, FandomMobile and FandomDesktop for inspiration of some features of this skin!

Expand All @@ -23,4 +25,4 @@ Fandom skins:

This project uses Material icons; These icons are under their license (Apache License 2.0) as well.

This project uses OOUI icons; These icons are under their license (MIT) as well.
This project uses OOUI icons; These icons are under their license (MIT) as well.
46 changes: 46 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "mediawiki/lakeus-skin",
"description": "A MediaWiki skin made by Lakejason0 and other contributors.",
"keywords": [
"mediawiki"
],
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Lakejason0"
},
{
"name": "Light beacon"
},
{
"name": "Dianliang233"
},
{
"name": "Winston Sung"
}
],
"require": {
"php": ">=7.4",
"mustangostang/spyc": "0.6.3"
},
"require-dev": {
"phpunit/phpunit": "9.6.13",
"mediawiki/mediawiki-codesniffer": "42.0.0"
},
"support": {
"issues": "https://github.com/lakejason0/mediawiki-skins-Lakeus/issues"
},
"autoload": {
"psr-4": {
"MediaWiki\\Skins\\Lakeus\\": "includes/"
}
},
"scripts": {
"fix": "phpcbf",
"cs": "phpcs -sp",
"test": [
"@composer validate --no-interaction",
"@cs"
]
}
}
2 changes: 1 addition & 1 deletion i18n/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"lakeus-theme-designer-basic-derived": "基本派生",
"lakeus-theme-designer-color-secondary--derived": "次要色派生",
"lakeus-theme-designer-border-color-secondary--derived": "次要色边框颜色派生",
"lakeus-theme-designer-global": "全局",
"lakeus-theme-designer-global": "全域",
"lakeus-theme-designer-background-color-base": "HTML背景颜色",
"lakeus-theme-designer-color-link": "链接颜色",
"lakeus-theme-designer-color-link--visited": "访问过的链接颜色",
Expand Down
65 changes: 32 additions & 33 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<?php

namespace Lakeus;
namespace MediaWiki\Skins\Lakeus;

class Hooks
{
/**
* @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Hooks/GetPreferences
* @param User $user
* @param array $preferences
*/
public static function onGetPreferences($user, &$preferences)
{
// A checkbox
$preferences['lakeus-enable-theme-designer'] = [
'type' => 'check',
'label-message' => 'lakeus-preferences-enable-theme-designer', // a system message
'help-message' => 'lakeus-preferences-enable-theme-designer-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];
class Hooks {
/**
* @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Hooks/GetPreferences
* @param User $user
* @param array &$preferences
*/
public static function onGetPreferences( $user, &$preferences ) {
// A checkbox
$preferences['lakeus-enable-theme-designer'] = [
'type' => 'check',
// a system message
'label-message' => 'lakeus-preferences-enable-theme-designer',
'help-message' => 'lakeus-preferences-enable-theme-designer-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];

$preferences['lakeus-sticky-toc-donot-auto-collapse'] = [
'type' => 'check',
'label-message' => 'lakeus-preferences-sticky-toc-donot-auto-collapse',
'help-message' => 'lakeus-preferences-sticky-toc-donot-auto-collapse-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];
$preferences['lakeus-sticky-toc-donot-auto-collapse'] = [
'type' => 'check',
'label-message' => 'lakeus-preferences-sticky-toc-donot-auto-collapse',
'help-message' => 'lakeus-preferences-sticky-toc-donot-auto-collapse-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];

$preferences['lakeus-smooth-scroll-behavior'] = [
'type' => 'check',
'label-message' => 'lakeus-preferences-smooth-scroll-behavior',
'help-message' => 'lakeus-preferences-smooth-scroll-behavior-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];
}
$preferences['lakeus-smooth-scroll-behavior'] = [
'type' => 'check',
'label-message' => 'lakeus-preferences-smooth-scroll-behavior',
'help-message' => 'lakeus-preferences-smooth-scroll-behavior-desc',
'section' => 'rendering/skin/skin-prefs',
'hide-if' => [ '!==', 'wpskin', 'lakeus' ],
];
}
}
111 changes: 66 additions & 45 deletions includes/SkinLakeus.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,69 @@
<?php

namespace MediaWiki\Skins\Lakeus;

use BagOStuff;
# use MediaWiki\Html\TemplateParser; // Namespaced in 1.40.0
# use MediaWiki\SiteStats\SiteStats; // Namespaced in 1.41.0
use SiteStats;
use SkinMustache;
use TemplateParser;

class SkinLakeus extends SkinMustache {

public const TEMPLATE_DIR = __DIR__ . '/templates';

/**
* @param BagOStuff $localServerObjectCache
* @param array $options
*/
public function __construct( BagOStuff $localServerObjectCache, array $options ) {
$options['templateDirectory'] = self::TEMPLATE_DIR;
parent::__construct( $options );

$this->templateParser = new TemplateParser( $this->options['templateDirectory'], $localServerObjectCache );
}

/**
* Extends the getTemplateData function to add a template key 'html-myskin-hello-world'
* which can be rendered in skin.mustache using {{{html-myskin-hello-world}}}
*/
public function getTemplateData() {
$data = parent::getTemplateData();
$config = $this->getConfig(); // this is a Config object

$data["html-articlecount"] = SiteStats::articles();
// trying to overwrite
$data["msg-lakeus-articlecount"] = $this->msg( 'lakeus-articlecount' )->numParams( SiteStats::articles() )->parse();
$wgLakeusShowRepositoryLink = $config->get( 'LakeusShowRepositoryLink' );
if ($wgLakeusShowRepositoryLink) {
$data["html-repository-link"] = '<a href="https://github.com/lakejason0/mediawiki-skins-Lakeus">' . $this->msg( 'lakeus-footermessage' )->plain() . '</a>';
$data["is-repository-link-shown"] = true;
}
$data["is-notice-with-border"] = $config->get( 'LakeusSiteNoticeHasBorder' );
$data["is-portlet-animated"] = $config->get( 'LakeusShouldAnimatePortlets' );
$data["is-sticky-toc-shown"] = $config->get( 'LakeusShowStickyTOC' );

$pageToolsKey = array_search('p-tb' , array_column( $data["data-portlets-sidebar"]["array-portlets-rest"], 'id' ) );
$data["data-portlets"]["data-page-tools"] = $data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey];
unset($data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey]);
$data["data-portlets-sidebar"]["array-portlets-rest"] = array_values($data["data-portlets-sidebar"]["array-portlets-rest"]);

if ( empty($data["data-toc"]["array-sections"]) ) {
unset($data["data-toc"]);
}

return $data;
}
}
public const TEMPLATE_DIR = __DIR__ . '/templates';

/**
* @param BagOStuff $localServerObjectCache
* @param array $options
*/
public function __construct( BagOStuff $localServerObjectCache, array $options ) {
$options['templateDirectory'] = self::TEMPLATE_DIR;
parent::__construct( $options );

$this->templateParser = new TemplateParser( $this->options['templateDirectory'], $localServerObjectCache );
}

/**
* Extends the getTemplateData function to add a template key 'html-myskin-hello-world'
* which can be rendered in skin.mustache using {{{html-myskin-hello-world}}}
*
* @return array
*/
public function getTemplateData(): array {
$data = parent::getTemplateData();
// this is a Config object
$config = $this->getConfig();

$data["html-articlecount"] = SiteStats::articles();
// trying to overwrite
$data["msg-lakeus-articlecount"] = $this->msg( 'lakeus-articlecount' )
->numParams( SiteStats::articles() )->parse();
$showRepositoryLink = $config->get( 'LakeusShowRepositoryLink' );
if ( $showRepositoryLink ) {
$data["html-repository-link"] = '<a href="https://github.com/lakejason0/mediawiki-skins-Lakeus">' .
$this->msg( 'lakeus-footermessage' )->plain() . '</a>';
$data["is-repository-link-shown"] = true;
}
$data["is-notice-with-border"] = $config->get( 'LakeusSiteNoticeHasBorder' );
$data["is-portlet-animated"] = $config->get( 'LakeusShouldAnimatePortlets' );
$data["is-sticky-toc-shown"] = $config->get( 'LakeusShowStickyTOC' );

$pageToolsKey = array_search(
'p-tb',
array_column( $data["data-portlets-sidebar"]["array-portlets-rest"], 'id' )
);
$data["data-portlets"]["data-page-tools"] =
$data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey];
unset( $data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey] );
$data["data-portlets-sidebar"]["array-portlets-rest"] = array_values(
$data["data-portlets-sidebar"]["array-portlets-rest"]
);

if ( empty( $data["data-toc"]["array-sections"] ) ) {
unset( $data["data-toc"] );
}

return $data;
}
}
7 changes: 7 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
<file>.</file>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
</ruleset>
Loading

0 comments on commit 01abe0d

Please sign in to comment.