diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | SkinTyrian.php | 15 | ||||
-rw-r--r-- | Tyrian.php | 3 | ||||
-rw-r--r-- | TyrianTemplate.php | 155 | ||||
-rw-r--r-- | icons/bell.svg | 4 | ||||
-rw-r--r-- | icons/tray.svg | 4 | ||||
-rw-r--r-- | main.css | 33 | ||||
-rw-r--r-- | skin.json | 55 |
8 files changed, 169 insertions, 108 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..dbe9cae --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +Tyrian skin for MediaWiki +====== + +Tyrian – The new look of gentoo.org. + +Find the Tyrian theme source [here](https://gitweb.gentoo.org/sites/tyrian-theme.git/). + +This skin overwrites *some* CSS found in the Tyrian theme in a way that is appropiate for rendering on MediaWiki. See the main.css file for details. diff --git a/SkinTyrian.php b/SkinTyrian.php index ece2ff6..edc0aa4 100644 --- a/SkinTyrian.php +++ b/SkinTyrian.php @@ -4,6 +4,7 @@ * MediaWiki implementation based on MonoBook nouveau. * * Copyright (C) 2014-2016 Alex Legler <a3li@gentoo.org> + * Copyright (C) 2016-2019 Gentoo wiki project <wiki@gentoo.org> */ /** @@ -19,7 +20,7 @@ class SkinTyrian extends SkinTemplate { const CDN_URL = 'https://assets.gentoo.org/tyrian/'; - function setupSkinUserCss(OutputPage $out) { + public function setupSkinUserCss(OutputPage $out) { $this->output = $out; parent::setupSkinUserCss($out); @@ -27,10 +28,16 @@ class SkinTyrian extends SkinTemplate { $out->addStyle(SkinTyrian::CDN_URL . 'bootstrap.min.css'); $out->addStyle(SkinTyrian::CDN_URL . 'tyrian.min.css'); - $out->addModuleStyles(array( + $out->addModuleStyles([ 'mediawiki.skinning.interface', 'mediawiki.skinning.content.externallinks', - 'skins.tyrian.styles' - )); + 'skins.tyrian.styles', + 'skins.tyrian.icons' + ]); + } + public static function injectMetaTags($out) { + $out->addMeta('viewport', 'width=device-width, initial-scale=1.0'); + $out->addMeta('theme-color', '#54487a'); + return true; } } @@ -4,6 +4,7 @@ * MediaWiki implementation based on MonoBook nouveau. * * Copyright (C) 2014-2016 Alex Legler <a3li@gentoo.org> + * Copyright (C) 2016-2019 Gentoo wiki project <wiki@gentoo.org> */ $wgExtensionCredits['skin'][] = array( @@ -11,7 +12,7 @@ $wgExtensionCredits['skin'][] = array( 'name' => 'Tyrian', 'namemsg' => 'skinname-tyrian', 'descriptionmsg' => 'tyrian-desc', - 'url' => 'http://www.gentoo.org/', + 'url' => 'https://www.gentoo.org/', 'author' => array('Alex Legler'), 'license-name' => 'GPLv2', ); diff --git a/TyrianTemplate.php b/TyrianTemplate.php index a91df4e..2f12ff4 100644 --- a/TyrianTemplate.php +++ b/TyrianTemplate.php @@ -4,9 +4,10 @@ * MediaWiki implementation based on MonoBook nouveau. * * Copyright (C) 2014-2016 Alex Legler <a3li@gentoo.org> + * Copyright (C) 2016-2019 Gentoo wiki project <wiki@gentoo.org> */ class TyrianTemplate extends BaseTemplate { - function execute() { + public function execute() { wfSuppressWarnings(); $this->html( 'headelement' ); @@ -19,41 +20,42 @@ class TyrianTemplate extends BaseTemplate { <div class="col-md-12"> <div id="content" class="mw-body" role="main"> <a id="top"></a> - <?php if ( $this->data['sitenotice'] ) { ?> - <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div> - <?php } ?> + <?php if ( $this->data['sitenotice'] ) { + echo '<div id="siteNotice">'; $this->html( 'sitenotice' ); echo '</div>'; + } ?> <h1 id="firstHeading" class="first-header" lang="<?php $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); $this->text( 'pageLanguage' ); ?>"> - <span dir="auto"><?php $this->html( 'title' ) ?></span> + <span dir="auto"><?php $this->html( 'title' ); ?></span> </h1> <div id="bodyContent" class="mw-body-content"> <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> - <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>> + <div id="contentSub"<?php $this->html( 'userlangattributes' ); ?>> <?php $this->html( 'subtitle' ) ?> </div> - <?php if ( $this->data['undelete'] ) { ?> - <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> - <?php } ?> - <?php if ( $this->data['newtalk'] ) { ?> - <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> - <?php } ?> + <?php if ( $this->data['undelete'] ) { + echo '<div id="contentSub2">'; $this->html( 'undelete' ); echo '</div>'; + } + if ( $this->data['newtalk'] ) { + echo '<div class="usermessage">'; $this->html( 'newtalk' ); echo '</div>'; + } ?> <div id="jump-to-nav" class="mw-jump"> <?php $this->msg( 'jumpto' ) ?> - <a href="#column-one"><?php $this->msg( 'jumptonavigation' ) ?></a><?php $this->msg( 'comma-separator' ) ?> - <a href="#searchInput"><?php $this->msg( 'jumptosearch' ) ?></a> + <a href="#column-one"><?php $this->msg( 'jumptonavigation' ); ?></a><?php $this->msg( 'comma-separator' ) ?> + <a href="#searchInput"><?php $this->msg( 'jumptosearch' ); ?></a> </div> <!-- start content --> - <?php $this->html( 'bodytext' ) ?> - <?php if ( $this->data['catlinks'] ) { ?> - <?php $this->html( 'catlinks' ); ?> - <?php } ?> - <!-- end content --> - - <?php if ( $this->data['dataAfterContent'] ) { - $this->html( 'dataAfterContent' ); - } ?> + <?php $this->html( 'bodytext' ); + if ( $this->data['catlinks'] ) { + $this->html( 'catlinks' ); + } + //<!-- end content --> + + if ( $this->data['dataAfterContent'] ) { + $this->html( 'dataAfterContent' ); + } + ?> </div> </div> </div> @@ -76,10 +78,10 @@ class TyrianTemplate extends BaseTemplate { /*************************************************************************************************/ - function header() { + private function header() { ?> <div class="mw-jump sr-only"> - <?php $this->msg( 'jumpto' ) ?> + <?php $this->msg( 'jumpto' ); ?> <a href="#top">content</a> </div> <header> @@ -150,7 +152,7 @@ class TyrianTemplate extends BaseTemplate { <?php } - function footer() { + private function footer() { $validFooterIcons = $this->getFooterIcons( "icononly" ); $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links ?> @@ -158,15 +160,15 @@ class TyrianTemplate extends BaseTemplate { <div class="container"> <div class="row"> <div class="col-xs-12 col-md-offset-2 col-md-7"> - <?php if ( count( $validFooterLinks ) > 0 ) { ?> + <?php if ( count( $validFooterLinks ) > 0 ): ?> <div class="spacer"></div> <ul id="f-list"> - <?php foreach ( $validFooterLinks as $aLink ) { ?> - <?php if ($aLink === 'copyright') continue; ?> - <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li> - <?php } ?> + <?php foreach ( $validFooterLinks as $aLink ) { + if ($aLink === 'copyright') continue; + echo "<li id=\"{$aLink}>\">"; $this->html( $aLink ); echo '</li>'; + } ?> </ul> - <?php } ?> + <?php endif; ?> </div> <div class="col-xs-12 col-md-3"> <!-- No questions or comments, the Wiki has enough information on how to contact us. --> @@ -181,7 +183,7 @@ class TyrianTemplate extends BaseTemplate { </ul> </div> <div class="col-xs-9 col-md-9"> - <strong>© 2001–2017 Gentoo Foundation, Inc.</strong><br /> + <strong>© 2001–2019 Gentoo Foundation, Inc.</strong><br /> <small> Gentoo is a trademark of the Gentoo Foundation, Inc. The contents of this document, unless otherwise expressly stated, are licensed under the @@ -199,37 +201,31 @@ class TyrianTemplate extends BaseTemplate { /** * @param array $sidebar */ - protected function renderPortals( $sidebar ) { + protected function renderPortals( array $sidebar ) { // These are already rendered elsewhere $sidebar['SEARCH'] = false; $sidebar['TOOLBOX'] = false; $sidebar['LANGUAGES'] = false; - foreach ( $sidebar as $boxName => $content ) { - if ( $content === false ) { - continue; - } - - $this->customBox( $boxName, $content ); - } + array_walk($sidebar, [$this, 'customBox'] ); } - function searchBox() { + private function searchBox() { ?> <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform" class="navbar-form navbar-right" role="search"> <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/> <div class="input-group"> - <?php echo $this->makeSearchInput( array( "id" => "searchInput", "class" => "form-control", "placeholder" => $this->getMsg( 'search' )->escaped() ) ); ?> + <?php echo $this->makeSearchInput( [ "id" => "searchInput", "class" => "form-control", "placeholder" => $this->getMsg( 'search' )->escaped() ] ); ?> <div class="input-group-btn"><?php echo $this->makeSearchButton( "go", - array( "id" => "searchGoButton", "class" => "searchButton btn btn-default" ) + [ "id" => "searchGoButton", "class" => "searchButton btn btn-default" ] ); echo $this->makeSearchButton( "fulltext", - array( "id" => "mw-searchButton", "class" => "searchButton btn btn-default" ) + [ "id" => "mw-searchButton", "class" => "searchButton btn btn-default" ] ); ?></div> </div> @@ -237,33 +233,30 @@ class TyrianTemplate extends BaseTemplate { <?php } - function cactions() { - $context_actions = array(); - $primary_actions = array(); - $secondary_actions = array(); + private function cactions() { + $context_actions = []; + $primary_actions = []; + $secondary_actions = []; + + $assign_active = function(array &$actionTab) { + if ( strpos( $actionTab['class'], 'selected' ) !== false ) { + $actionTab['class'] .= ' active'; + } + }; foreach ( $this->data['content_actions'] as $key => $tab ) { // TODO: handling form_edit separately here is a hack, no idea how it works in Vector. - if ( isset($tab['primary']) && $tab['primary'] == '1' || $key == 'form_edit' ) { + if ( isset($tab['primary']) && $tab['primary'] == '1' || $key == 'form_edit' || $key == 'formedit' ) { if ( isset($tab['context']) ) { $context_actions[$key] = $tab; - - if ( strpos( $tab['class'], 'selected' ) !== false ) { - $context_actions[$key]['class'] .= ' active'; - } + $assign_active($context_actions[$key]); } else { $primary_actions[$key] = $tab; - - if ( strpos( $tab['class'], 'selected' ) !== false ) { - $primary_actions[$key]['class'] .= ' active'; - } + $assign_active($primary_actions[$key]); } } else { $secondary_actions[$key] = $tab; - - if ( strpos( $tab['class'], 'selected' ) !== false ) { - $secondary_actions[$key]['class'] .= ' active'; - } + $assign_active($secondary_actions[$key]); } } ?> @@ -312,7 +305,7 @@ class TyrianTemplate extends BaseTemplate { } /*************************************************************************************************/ - function toolbox() { + private function toolbox() { ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-cog"></i> <?php $this->msg( 'toolbox' ) ?> <span class="caret"></span></a> @@ -322,8 +315,8 @@ class TyrianTemplate extends BaseTemplate { echo $this->makeListItem( $key, $tbitem ); } - wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) ); - wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) ); + wfRunHooks( 'MonoBookTemplateToolboxEnd', [&$this] ); + wfRunHooks( 'SkinTemplateToolboxEnd', [ &$this, true ] ); ?> </ul> </li> @@ -331,15 +324,13 @@ class TyrianTemplate extends BaseTemplate { } /*************************************************************************************************/ - function personaltools() { + private function personaltools() { $personal_tools = $this->getPersonalTools(); - $notifications_message_tool = NULL; - $notifications_alert_tool = NULL; ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> - <span class="glyphicon glyphicon-user" aria-label="<?php $this->msg( 'personaltools' ) ?>"></span> + <span class="fa fa-user" aria-label="<?php $this->msg( 'personaltools' ) ?>"></span> <?php if (isset($personal_tools['userpage'])) { echo $personal_tools['userpage']['links'][0]['text']; @@ -355,6 +346,8 @@ class TyrianTemplate extends BaseTemplate { $notifications_alert_tool = $item; } else if ($key === 'notifications-message') { $notifications_message_tool = $item; + } else if ($key === 'notifications-notice') { + $notifications_notice_tool = $item; } else { echo $this->makeListItem( $key, $item ); } @@ -364,27 +357,30 @@ class TyrianTemplate extends BaseTemplate { </li> <?php - if (!is_null($notifications_message_tool)) { + if (isset($notifications_message_tool)) { echo $this->makeListItem('notifications-message', $notifications_message_tool); } - if (!is_null($notifications_alert_tool)) { + if (isset($notifications_notice_tool)) { + echo $this->makeListItem('notifications-notice', $notifications_notice_tool); + } + + if (isset($notifications_alert_tool)) { echo $this->makeListItem('notifications-alert', $notifications_alert_tool); } } /*************************************************************************************************/ - function languageBox() { - if ( $this->data['language_urls'] !== false ) { + private function languageBox() { + if ( $this->data['language_urls'] !== false ): ?> <div id="p-lang" class="portlet" role="navigation"> <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3> <div class="pBody"> <ul> - <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?> - <?php echo $this->makeListItem( $key, $langlink ); ?> - <?php + <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { + echo $this->makeListItem( $key, $langlink ); } ?> </ul> @@ -393,7 +389,7 @@ class TyrianTemplate extends BaseTemplate { </div> </div> <?php - } + endif; } /*************************************************************************************************/ @@ -401,7 +397,10 @@ class TyrianTemplate extends BaseTemplate { * @param string $bar * @param array|string $cont */ - function customBox( $bar, $cont ) { + private function customBox( $cont, $bar ) { + if ($cont === false) { + return; + } $msgObj = wfMessage( $bar ); if ( $bar !== 'navigation' ) { ?> diff --git a/icons/bell.svg b/icons/bell.svg new file mode 100644 index 0000000..ff7ee2f --- /dev/null +++ b/icons/bell.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> + <path fill="#fff" d="M17.5 14V9c0-3-2.3-5-5.5-5S6.5 6 6.5 9v5c0 2 0 3-2 3v1h15v-1c-2 0-2-1-2-3zM12 20H9c0 1 1.6 2 3 2s3-1 3-2h-3z"/> +</svg> diff --git a/icons/tray.svg b/icons/tray.svg new file mode 100644 index 0000000..b9f84fc --- /dev/null +++ b/icons/tray.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> + <path fill="#fff" d="M3 13.35l1.8-7.2c.2-.996.81-1.8 1.8-1.8h10.8c.99 0 1.6.867 1.8 1.8l1.8 7.2v4.5c0 .99-.81 1.8-1.8 1.8H4.8c-.99 0-1.8-.81-1.8-1.8v-4.5zm6.96 1.8h4.08c-.49.557-1.212.9-2.04.9a2.68 2.68 0 0 1-2.04-.9h4.08c.414-.472.66-1.098.66-1.8h4.14l-1.44-7.2H6.6l-1.44 7.2H9.3c0 .702.246 1.328.66 1.8z"/> +</svg> @@ -1,4 +1,4 @@ -/* This file contains overrides for mediawiki stuff we don't want for Tyrian */ +/* This file contains overrides for MediaWiki stuff we don't want for Tyrian */ h1, h2, h3, h4, h5, h6 { padding-top: 0px; @@ -220,30 +220,15 @@ div#preferences table td { background-color: #4b406d; } -/* mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-image-invert oo-ui-iconElement oo-ui-iconElement-icon oo-ui-icon-speechBubble */ -/* oo-ui-widget oo-ui-widget-enabled oo-ui-labelElement oo-ui-labelElement-label oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-buttonElement-button oo-ui-iconElement-icon oo-ui-flaggedElement-primary mw-echo-notifications-badge oo-ui-icon-speechBubble oo-ui-iconElement oo-ui-image-invert */ - +/* body.skin-tyrian #pt-notifications-alert .mw-echo-notifications-badge, -body.skin-tyrian #pt-notifications-message .mw-echo-notifications-badge { - border-radius: 0.2em; - background-color: transparent; - font-size: 1.125em; - font-weight: bold; - color: white; - cursor: pointer; - text-decoration: none; - margin-top: 0; - display: inline-block; - padding: 10px; - padding-left: 35px; - height: 40px; - background-position: 10px 10px; - background-size: 1.1em; - background-repeat: no-repeat; +body.skin-tyrian #pt-notifications-notice .mw-echo-notifications-badge { + width: 36px; } - -body.ltr #pt-notifications-alert .mw-echo-notifications-badge, body.ltr #pt-notifications-message .mw-echo-notifications-badge { - background-position: 10px 10px !important; +*/ +body.skin-tyrian #pt-notifications-alert .mw-echo-notifications-badge:before, +body.skin-tyrian #pt-notifications-notice .mw-echo-notifications-badge:before { + top: 1012px; } .flow-board-header, .flow-board-navigation, .flow-board-header-menu, .flow-board { @@ -254,8 +239,6 @@ div#content .flow-topic-title { font-family: 'Bitter'; } - - body.mw-special-Specialpages h2 { border: none !important; margin-bottom: 0.75em; diff --git a/skin.json b/skin.json new file mode 100644 index 0000000..476e800 --- /dev/null +++ b/skin.json @@ -0,0 +1,55 @@ +{ + "name": "Tyrian", + "author": [ + "Alex Legler", + "Gentoo wiki project" + ], + "url": "https://www.gentoo.org/", + "descriptionmsg": "tyrian-desc", + "namemsg": "skinname-tyrian", + "license-name": "GPL-2.0", + "type": "skin", + "requires": { + "MediaWiki": ">= 1.25.0" + }, + "ValidSkinNames": { + "tyrian": "Tyrian" + }, + "MessagesDirs": { + "Tyrian": [ + "i18n" + ] + }, + "ResourceModules": { + "skins.tyrian.styles": { + "position": "top", + "styles": { + "main.css": { + "media": "screen" + } + } + }, + "skins.tyrian.icons": { + "position": "top", + "class": "ResourceLoaderImageModule", + "selector": "body.skin-tyrian #pt-notifications-{name} .mw-echo-notifications-badge:before", + "images": { + "alert": "icons/bell.svg", + "notice": "icons/tray.svg" + } + } + }, + "ResourceFileModulePaths": { + "localBasePath": "", + "remoteSkinPath": "Tyrian" + }, + "AutoloadClasses": { + "SkinTyrian": "SkinTyrian.php", + "TyrianTemplate": "TyrianTemplate.php" + }, + "Hooks": { + "OutputPageBeforeHTML": "SkinTyrian::injectMetaTags" + }, + "manifest_version": 1 +} + |