Bartosz Dziewoński has submitted this change and it was merged. Change subject: Example skin ......................................................................
Example skin This is an example skin showcasing the best practices, a companion to the MediaWiki skinning guide available at <https://www.mediawiki.org/wiki/Manual:Skinning>. The code is released into public domain. Change-Id: I03c02f1a9cf5f2372417b925aec562b56b05f870 --- A Example.php A Example.skin.php A i18n/en.json A i18n/qqq.json A resources/screen.css 5 files changed, 365 insertions(+), 0 deletions(-) Approvals: Bartosz Dziewoński: Verified; Looks good to me, approved Siebrand: Looks good to me, but someone else must approve diff --git a/Example.php b/Example.php new file mode 100644 index 0000000..2f33ae3 --- /dev/null +++ b/Example.php @@ -0,0 +1,42 @@ +<?php +/** + * Example skin + * + * This is an example skin showcasing the best practices, a companion to the MediaWiki skinning + * guide available at <https://www.mediawiki.org/wiki/Manual:Skinning>. + * + * The code is released into public domain, which means you can freely copy it, modify and release + * as your own skin without providing attribution and with absolutely no restrictions. Remember to + * change the license information if you do not intend to provide your changes on the same terms. + * + * @file + * @ingroup Skins + * @author ... + * @license CC0 (public domain) <http://creativecommons.org/publicdomain/zero/1.0/> + */ + +$wgExtensionCredits['skin'][] = array( + 'path' => __FILE__, + 'name' => 'Example', + 'namemsg' => 'skinname-example', + 'version' => '1.0', + 'url' => 'https://www.mediawiki.org/wiki/Skin:Example', + 'author' => '...', + 'descriptionmsg' => 'example-desc', + // When modifying this skin, remember to change the license information if you do not want to + // waive all of your rights to your work! + 'license' => 'CC0', +); + +$wgValidSkinNames['example'] = 'Example'; + +$wgAutoloadClasses['SkinExample'] = __DIR__ . '/Example.skin.php'; +$wgMessagesDirs['Example'] = __DIR__ . '/i18n'; + +$wgResourceModules['skins.example'] = array( + 'styles' => array( + 'Example/resources/screen.css' => array( 'media' => 'screen' ), + ), + 'remoteBasePath' => &$GLOBALS['wgStylePath'], + 'localBasePath' => &$GLOBALS['wgStyleDirectory'], +); diff --git a/Example.skin.php b/Example.skin.php new file mode 100644 index 0000000..d9cbb44 --- /dev/null +++ b/Example.skin.php @@ -0,0 +1,212 @@ +<?php +/** + * Skin file for the Example skin. + * + * @file + * @ingroup Skins + */ + +/** + * SkinTemplate class for the Example skin + * + * @ingroup Skins + */ +class SkinExample extends SkinTemplate { + var $skinname = 'example', $stylename = 'Example', + $template = 'ExampleTemplate', $useHeadElement = true; + + /** + * Add CSS via ResourceLoader + * + * @param $out OutputPage + */ + function setupSkinUserCss( OutputPage $out ) { + parent::setupSkinUserCss( $out ); + $out->addModuleStyles( array( + 'mediawiki.skinning.interface', 'skins.example' + ) ); + } +} + +/** + * BaseTemplate class for the Example skin + * + * @ingroup Skins + */ +class ExampleTemplate extends BaseTemplate { + /** + * Outputs a single sidebar portlet of any kind. + */ + private function outputPortlet( $box ) { + if ( !$box['content'] ) { + return; + } + + ?> + <div + role="navigation" + class="mw-portlet" + id="<?php echo Sanitizer::escapeId( $box['id'] ) ?>" + <?php echo Linker::tooltip( $box['id'] ) ?> + > + <h3> + <?php + if ( isset( $box['headerMessage'] ) ) { + $this->msg( $box['headerMessage'] ); + } else { + echo htmlspecialchars( $box['header'] ); + } + ?> + </h3> + + <?php + if ( is_array( $box['content'] ) ) { + echo '<ul>'; + foreach ( $box['content'] as $key => $item ) { + echo $this->makeListItem( $key, $item ); + } + echo '</ul>'; + } else { + echo $box['content']; + }?> + </div> + <?php + } + + /** + * Outputs the entire contents of the page + */ + public function execute() { + $this->html( 'headelement' ) ?> + <div id="mw-wrapper"> + <a + id="p-logo" + role="banner" + href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>" + <?php echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) ?> + > + <img + src="<?php $this->text( 'logopath' ) ?>" + alt="<?php $this->text( 'sitename' ) ?>" + /> + </a> + + + <div class="mw-body" role="main"> + <?php if ( $this->data['sitenotice'] ) { ?> + <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div> + <?php } ?> + + <?php if ( $this->data['newtalk'] ) { ?> + <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> + <?php } ?> + + <h1 class="firstHeading"> + <span dir="auto"><?php $this->html( 'title' ) ?></span> + </h1> + + <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> + + <div class="mw-body-content"> + <div id="contentSub"> + <?php if ( $this->data['subtitle'] ) { ?> + <p><?php $this->html( 'subtitle' ) ?></p> + <?php } ?> + <?php if ( $this->data['undelete'] ) { ?> + <p><?php $this->html( 'undelete' ) ?></p> + <?php } ?> + </div> + + <?php $this->html( 'bodytext' ) ?> + + <?php $this->html( 'catlinks' ) ?> + + <?php $this->html( 'dataAfterContent' ); ?> + + </div> + </div> + + + <div id="mw-navigation"> + <h2><?php $this->msg( 'navigation-heading' ) ?></h2> + + <form + action="<?php $this->text( 'wgScript' ) ?>" + role="search" + class="mw-portlet" + id="p-search" + > + <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>" /> + + <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3> + + <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ) ?> + <?php echo $this->makeSearchButton( 'go' ) ?> + + </form> + + <?php + + $this->outputPortlet( array( + 'id' => 'p-personal', + 'headerMessage' => 'personaltools', + 'content' => $this->getPersonalTools(), + ) ); + + $this->outputPortlet( array( + 'id' => 'p-namespaces', + 'headerMessage' => 'namespaces', + 'content' => $this->data['content_navigation']['namespaces'], + ) ); + $this->outputPortlet( array( + 'id' => 'p-variants', + 'headerMessage' => 'variants', + 'content' => $this->data['content_navigation']['variants'], + ) ); + $this->outputPortlet( array( + 'id' => 'p-views', + 'headerMessage' => 'views', + 'content' => $this->data['content_navigation']['views'], + ) ); + $this->outputPortlet( array( + 'id' => 'p-actions', + 'headerMessage' => 'actions', + 'content' => $this->data['content_navigation']['actions'], + ) ); + + foreach ( $this->getSidebar() as $boxName => $box ) { + $this->outputPortlet( $box ); + } + + ?> + </div> + + <div id="mw-footer"> + <?php foreach ( $this->getFooterLinks() as $category => $links ) { ?> + <ul role="contentinfo"> + <?php foreach ( $links as $key ) { ?> + <li><?php $this->html( $key ) ?></li> + <?php } ?> + </ul> + <?php } ?> + + <ul role="contentinfo"> + <?php foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons ) { ?> + <li> + <?php + foreach ( $footerIcons as $icon ) { + echo $this->getSkin()->makeFooterIcon( $icon ); + } + ?> + </li> + <?php } ?> + </ul> + </div> + </div> + + <?php $this->printTrail() ?> + </body></html> + + <?php + } +} diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..f0e6d86 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,7 @@ +{ + "@metadata": { + "authors": [ "..." ] + }, + "skinname-example": "Example", + "example-desc": "An example skin showcasing the best practices" +} diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 0000000..7b5d653 --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,7 @@ +{ + "@metadata": { + "authors": [ "..." ] + }, + "skinname-example": "{{optional}}", + "example-desc": "{{desc|what=skin|name=Example|url=https://www.mediawiki.org/wiki/Skin:Example}}" +} diff --git a/resources/screen.css b/resources/screen.css new file mode 100644 index 0000000..6a396b4 --- /dev/null +++ b/resources/screen.css @@ -0,0 +1,97 @@ +/** + * Basic styling for the Example skin. + */ + +/* Page layout */ + +html, +body { + font-family: sans-serif; + margin: 0; + padding: 0; +} + +#mw-wrapper { + width: 60em; + margin: 0 auto; + border-left: 1px solid black; + border-right: 1px solid black; + position: relative; +} + +.mw-body { + width: 46em; + padding: 1em; + padding-top: 6em; + border-left: 1px solid black; + float: right; +} + +#p-logo, +#mw-navigation { + width: 10em; + padding-left: 1em; + clear: left; + float: left; +} + +#p-logo { + text-align: center; +} + +/* Search form and personal menu in top-right corner */ + +#p-search { + position: absolute; + top: 1em; + right: 1em; + width: 46em; + text-align: right; +} + +#p-personal { + position: absolute; + top: 3em; + right: 1em; + width: 46em; + text-align: right; +} + +#p-personal ul { + list-style-type: none; + margin: 0; +} + +#p-personal ul li { + display: inline-block; + margin-right: 1em; +} + +/* Footer */ + +#mw-footer { + clear: both; + border-top: 1px solid black; + margin-top: 1em; + padding: 1em; +} + +#mw-footer ul { + list-style-type: none; + margin: 0; +} + +#mw-footer ul li { + display: inline-block; + margin-right: 1em; +} + +/* Hide some headings, but keep them accessible for screen-readers */ + +#mw-navigation h2, +#p-search h3, +#p-personal h3 { + position: absolute; + top: -9999px; +} + -- To view, visit https://gerrit.wikimedia.org/r/147690 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I03c02f1a9cf5f2372417b925aec562b56b05f870 Gerrit-PatchSet: 9 Gerrit-Project: mediawiki/skins/Example Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <[email protected]> Gerrit-Reviewer: Bartosz Dziewoński <[email protected]> Gerrit-Reviewer: Isarra <[email protected]> Gerrit-Reviewer: Krinkle <[email protected]> Gerrit-Reviewer: Legoktm <[email protected]> Gerrit-Reviewer: Robert Vogel <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
