mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-28 00:01:05 +00:00
Initial creation of Citizen skin
Set up the basic framework
This commit is contained in:
commit
c444b7d07b
359
CitizenTemplate.php
Normal file
359
CitizenTemplate.php
Normal file
|
@ -0,0 +1,359 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin built from ground up for 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
|
||||
* (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
|
||||
*/
|
||||
|
||||
/**
|
||||
* QuickTemplate class for Citizen skin
|
||||
* @ingroup Skins
|
||||
*/
|
||||
class CitizenTemplate extends BaseTemplate {
|
||||
/**
|
||||
* Outputs the entire contents of the page
|
||||
*/
|
||||
public function execute() {
|
||||
$this->html( 'headelement' );
|
||||
?>
|
||||
<div id="mw-wrapper">
|
||||
<div class="mw-body" role="main">
|
||||
<?php
|
||||
if ( $this->data['sitenotice'] ) {
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'id' => 'siteNotice' ),
|
||||
$this->get( 'sitenotice' )
|
||||
);
|
||||
}
|
||||
if ( $this->data['newtalk'] ) {
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'class' => 'usermessage' ),
|
||||
$this->get( 'newtalk' )
|
||||
);
|
||||
}
|
||||
echo $this->getIndicators();
|
||||
echo Html::rawElement(
|
||||
'h1',
|
||||
array(
|
||||
'class' => 'firstHeading',
|
||||
'lang' => $this->get( 'pageLanguage' )
|
||||
),
|
||||
$this->get( 'title' )
|
||||
);
|
||||
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'id' => 'siteSub' ),
|
||||
$this->getMsg( 'tagline' )->parse()
|
||||
);
|
||||
?>
|
||||
|
||||
<div class="mw-body-content">
|
||||
<?php
|
||||
echo Html::openElement(
|
||||
'div',
|
||||
array( 'id' => 'contentSub' )
|
||||
);
|
||||
if ( $this->data['subtitle'] ) {
|
||||
echo Html::rawelement (
|
||||
'p',
|
||||
[],
|
||||
$this->get( 'subtitle' )
|
||||
);
|
||||
}
|
||||
echo Html::rawelement (
|
||||
'p',
|
||||
[],
|
||||
$this->get( 'undelete' )
|
||||
);
|
||||
echo Html::closeElement( 'div' );
|
||||
|
||||
$this->html( 'bodycontent' );
|
||||
$this->clear();
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'class' => 'printfooter' ),
|
||||
$this->get( 'printfooter' )
|
||||
);
|
||||
$this->html( 'catlinks' );
|
||||
$this->html( 'dataAfterContent' );
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="mw-navigation">
|
||||
<?php
|
||||
echo Html::rawElement(
|
||||
'h2',
|
||||
[],
|
||||
$this->getMsg( 'navigation-heading' )->parse()
|
||||
);
|
||||
|
||||
echo $this->getLogo();
|
||||
echo $this->getSearch();
|
||||
|
||||
// User profile links
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'id' => 'user-tools' ),
|
||||
$this->getUserLinks()
|
||||
);
|
||||
|
||||
// Page editing and tools
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'id' => 'page-tools' ),
|
||||
$this->getPageLinks()
|
||||
);
|
||||
|
||||
// Site navigation/sidebar
|
||||
echo Html::rawElement(
|
||||
'div',
|
||||
array( 'id' => 'site-navigation' ),
|
||||
$this->getSiteNavigation()
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="mw-footer">
|
||||
<?php
|
||||
echo Html::openElement(
|
||||
'ul',
|
||||
array(
|
||||
'id' => 'footer-icons',
|
||||
'role' => 'contentinfo'
|
||||
)
|
||||
);
|
||||
foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons ) {
|
||||
echo Html::openElement(
|
||||
'li',
|
||||
array(
|
||||
'id' => 'footer-' . Sanitizer::escapeId( $blockName ) . 'ico'
|
||||
)
|
||||
);
|
||||
foreach ( $footerIcons as $icon ) {
|
||||
echo $this->getSkin()->makeFooterIcon( $icon );
|
||||
}
|
||||
echo Html::closeElement( 'li' );
|
||||
}
|
||||
echo Html::closeElement( 'ul' );
|
||||
|
||||
foreach ( $this->getFooterLinks() as $category => $links ) {
|
||||
echo Html::openElement(
|
||||
'ul',
|
||||
array(
|
||||
'id' => 'footer-' . Sanitizer::escapeId( $category ),
|
||||
'role' => 'contentinfo'
|
||||
)
|
||||
);
|
||||
foreach ( $links as $key ) {
|
||||
echo Html::rawElement(
|
||||
'li',
|
||||
array(
|
||||
'id' => 'footer-' . Sanitizer::escapeId( $category . '-' . $key )
|
||||
),
|
||||
$this->get( $key )
|
||||
);
|
||||
}
|
||||
echo Html::closeElement( 'ul' );
|
||||
}
|
||||
$this->clear();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->printTrail() ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a single sidebar portlet of any kind
|
||||
* @return string html
|
||||
*/
|
||||
private function getPortlet( $box ) {
|
||||
if ( !$box['content'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$html = Html::openElement(
|
||||
'div',
|
||||
array(
|
||||
'role' => 'navigation',
|
||||
'class' => 'mw-portlet',
|
||||
'id' => Sanitizer::escapeId( $box['id'] )
|
||||
) + Linker::tooltipAndAccesskeyAttribs( $box['id'] )
|
||||
);
|
||||
$html .= Html::element(
|
||||
'h3',
|
||||
[],
|
||||
isset( $box['headerMessage'] ) ? $this->getMsg( $box['headerMessage'] )->text() : $box['header'] );
|
||||
if ( is_array( $box['content'] ) ) {
|
||||
$html .= Html::openElement( 'ul' );
|
||||
foreach ( $box['content'] as $key => $item ) {
|
||||
$html .= $this->makeListItem( $key, $item );
|
||||
}
|
||||
$html .= Html::closeElement( 'ul' );
|
||||
} else {
|
||||
$html .= $box['content'];
|
||||
}
|
||||
$html .= Html::closeElement( 'div' );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the logo and (optionally) site title
|
||||
* @return string html
|
||||
*/
|
||||
private function getLogo( $id = 'p-logo', $imageOnly = false ) {
|
||||
$html = Html::openElement(
|
||||
'div',
|
||||
array(
|
||||
'id' => $id,
|
||||
'class' => 'mw-portlet',
|
||||
'role' => 'banner'
|
||||
)
|
||||
);
|
||||
$html .= Html::element(
|
||||
'a',
|
||||
array(
|
||||
'href' => $this->data['nav_urls']['mainpage']['href'],
|
||||
'class' => 'mw-wiki-logo',
|
||||
) + Linker::tooltipAndAccesskeyAttribs( 'p-logo' )
|
||||
);
|
||||
if ( !$imageOnly ) {
|
||||
$html .= Html::element(
|
||||
'a',
|
||||
array(
|
||||
'id' => 'p-banner',
|
||||
'class' => 'mw-wiki-title',
|
||||
'href'=> $this->data['nav_urls']['mainpage']['href']
|
||||
) + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ),
|
||||
$this->getMsg( 'sitetitle' )->escaped()
|
||||
);
|
||||
}
|
||||
$html .= Html::closeElement( 'div' );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the search form
|
||||
* @return string html
|
||||
*/
|
||||
private function getSearch() {
|
||||
$html = Html::openElement(
|
||||
'form',
|
||||
array(
|
||||
'action' => htmlspecialchars( $this->get( 'wgScript' ) ),
|
||||
'role' => 'search',
|
||||
'class' => 'mw-portlet',
|
||||
'id' => 'p-search'
|
||||
)
|
||||
);
|
||||
$html .= Html::hidden( 'title', htmlspecialchars( $this->get( 'searchtitle' ) ) );
|
||||
$html .= Html::rawelement(
|
||||
'h3',
|
||||
[],
|
||||
Html::label( $this->getMsg( 'search' )->escaped(), 'searchInput' )
|
||||
);
|
||||
$html .= $this->makeSearchInput( array( 'id' => 'searchInput' ) );
|
||||
$html .= $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) );
|
||||
$html .= Html::closeElement( 'form' );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the sidebar
|
||||
* Set the elements to true to allow them to be part of the sidebar
|
||||
* @return string html
|
||||
*/
|
||||
private function getSiteNavigation() {
|
||||
$html = '';
|
||||
|
||||
$sidebar = $this->getSidebar();
|
||||
|
||||
$sidebar['SEARCH'] = false;
|
||||
$sidebar['TOOLBOX'] = true;
|
||||
$sidebar['LANGUAGES'] = true;
|
||||
|
||||
foreach ( $sidebar as $boxName => $box ) {
|
||||
if ( $boxName === false ) {
|
||||
continue;
|
||||
}
|
||||
$html .= $this->getPortlet( $box, true );
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates page-related tools/links
|
||||
* @return string html
|
||||
*/
|
||||
private function getPageLinks() {
|
||||
$html = $this->getPortlet( array(
|
||||
'id' => 'p-namespaces',
|
||||
'headerMessage' => 'namespaces',
|
||||
'content' => $this->data['content_navigation']['namespaces'],
|
||||
) );
|
||||
$html .= $this->getPortlet( array(
|
||||
'id' => 'p-variants',
|
||||
'headerMessage' => 'variants',
|
||||
'content' => $this->data['content_navigation']['variants'],
|
||||
) );
|
||||
$html .= $this->getPortlet( array(
|
||||
'id' => 'p-views',
|
||||
'headerMessage' => 'views',
|
||||
'content' => $this->data['content_navigation']['views'],
|
||||
) );
|
||||
$html .= $this->getPortlet( array(
|
||||
'id' => 'p-actions',
|
||||
'headerMessage' => 'actions',
|
||||
'content' => $this->data['content_navigation']['actions'],
|
||||
) );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates user tools menu
|
||||
* @return string html
|
||||
*/
|
||||
private function getUserLinks() {
|
||||
return $this->getPortlet( array(
|
||||
'id' => 'p-personal',
|
||||
'headerMessage' => 'personaltools',
|
||||
'content' => $this->getPersonalTools(),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a css clear using the core visualClear class
|
||||
*/
|
||||
private function clear() {
|
||||
echo '<div class="visualClear"></div>';
|
||||
}
|
||||
}
|
54
SkinCitizen.php
Normal file
54
SkinCitizen.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin built from ground up for 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
|
||||
* (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 Citizen skin
|
||||
* @ingroup Skins
|
||||
*/
|
||||
class SkinCitizen extends SkinTemplate {
|
||||
public $skinname = 'citizen', $stylename = 'Citizen',
|
||||
$template = 'CitizenTemplate', $useHeadElement = true;
|
||||
|
||||
/**
|
||||
* Initializes output page and sets up skin-specific parameters
|
||||
* @param OutputPage $out Object to initialize
|
||||
*/
|
||||
|
||||
public function initPage( OutputPage $out ) {
|
||||
parent::initPage( $out );
|
||||
$out->addMeta( 'viewport', 'width=device-width, initial-scale=1' );
|
||||
$out->addModules( 'skins.citizen.js' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSS via ResourceLoader
|
||||
*
|
||||
* @param $out OutputPage
|
||||
*/
|
||||
function setupSkinUserCss( OutputPage $out ) {
|
||||
parent::setupSkinUserCss( $out );
|
||||
$out->addModuleStyles( array(
|
||||
'mediawiki.skinning.interface', 'skins.citizen'
|
||||
) );
|
||||
}
|
||||
}
|
7
i18n/en.json
Normal file
7
i18n/en.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [ "alistair3149" ]
|
||||
},
|
||||
"skinname-citizen": "Citizen",
|
||||
"citizen-desc": "A responsive skin built from ground up for Star Citizen Wiki"
|
||||
}
|
42
skin.json
Normal file
42
skin.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "Citizen",
|
||||
"author": [
|
||||
"alistair3149",
|
||||
],
|
||||
"url": "https://starcitizen.tools",
|
||||
"descriptionmsg": "citizen-skin-desc",
|
||||
"namemsg": "skinname-citizen",
|
||||
"license-name": "GPL-2.0+",
|
||||
"type": "skin",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.27.0"
|
||||
},
|
||||
"ValidSkinNames": {
|
||||
"citizen": "Citizen"
|
||||
},
|
||||
"AutoloadClasses": {
|
||||
"SkinCitizen": "SkinCitizen.php"
|
||||
},
|
||||
"MessageDirs": {
|
||||
"Citizen": "i18n"
|
||||
},
|
||||
"ResourceModules": {
|
||||
"skins.citizen": {
|
||||
"styles": {
|
||||
"resources/screen.less": { "media": "screen" },
|
||||
"resources/print.less": { "media": "print" }
|
||||
}
|
||||
},
|
||||
"skins.citizen.js": {
|
||||
"scripts": [
|
||||
"citizen.js"
|
||||
],
|
||||
"position": "top",
|
||||
"dependencies": "jquery.ui.dialog"
|
||||
}
|
||||
},
|
||||
"ResourceFileModulePaths": {
|
||||
"localBasePath": "",
|
||||
"remoteSkinPath": "Citizen"
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue