-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/lakejason0/mediawiki-skin…
- Loading branch information
Showing
12 changed files
with
677 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.