From 4fad68ed0b5ac14a9e584247b067153ff60bd163 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Wed, 30 Sep 2020 15:17:33 -0700 Subject: [PATCH] Source footer data from SkinMustache SkinMustache now provides this data in a slightly modified form. Use it. Change-Id: I060a8acfab6e7e2eea14e84fd4a5cad23677390b --- includes/SkinVector.php | 68 ------------------------- includes/templates/Footer.mustache | 14 +++-- includes/templates/Footer__row.mustache | 5 ++ stories/Footer.stories.data.js | 15 +++--- 4 files changed, 19 insertions(+), 83 deletions(-) create mode 100644 includes/templates/Footer__row.mustache diff --git a/includes/SkinVector.php b/includes/SkinVector.php index 22969f2..e957db7 100644 --- a/includes/SkinVector.php +++ b/includes/SkinVector.php @@ -133,7 +133,6 @@ class SkinVector extends SkinMustache { 'html-newtalk' => $newTalksHtml ? '
' . $newTalksHtml . '
' : '', 'html-categories' => $skin->getCategories(), - 'data-footer' => $this->getFooterData(), 'is-search-in-header' => $isSearchInHeader, 'input-location' => $this->getSearchBoxInputLocation( $isSearchInHeader ), @@ -175,73 +174,6 @@ class SkinVector extends SkinMustache { : Constants::SEARCH_BOX_INPUT_LOCATION_DEFAULT; } - /** - * Get rows that make up the footer - * @return array for use in Mustache template describing the footer elements. - */ - private function getFooterData() : array { - $skin = $this; - $footerRows = []; - foreach ( $this->getFooterLinks() as $category => $links ) { - $items = []; - $rowId = "footer-$category"; - - foreach ( $links as $key => $link ) { - // Link may be null. If so don't include it. - if ( $link ) { - $items[] = [ - 'id' => "$rowId-$key", - 'html' => $link, - ]; - } - } - - $footerRows[] = [ - 'id' => $rowId, - 'className' => null, - 'array-items' => $items - ]; - } - - // If footer icons are enabled append to the end of the rows - $footerIcons = $this->getFooterIcons(); - - if ( count( $footerIcons ) > 0 ) { - $items = []; - foreach ( $footerIcons as $blockName => $blockIcons ) { - $html = ''; - foreach ( $blockIcons as $icon ) { - // Only output icons which have an image. - // For historic reasons this mimics the `icononly` option - // for BaseTemplate::getFooterIcons. - if ( is_string( $icon ) || isset( $icon['src'] ) ) { - $html .= $skin->makeFooterIcon( $icon ); - } - } - // For historic reasons this mimics the `icononly` option - // for BaseTemplate::getFooterIcons. Empty rows should not be output. - if ( $html ) { - $items[] = [ - 'id' => 'footer-' . htmlspecialchars( $blockName ) . 'ico', - 'html' => $html, - ]; - } - } - - // Empty rows should not be output. - // This is how Vector has behaved historically but we can revisit. - if ( count( $items ) > 0 ) { - $footerRows[] = [ - 'id' => 'footer-icons', - 'className' => 'noprint', - 'array-items' => $items, - ]; - } - } - - return [ 'array-footer-rows' => $footerRows ]; - } - /** * Determines wheather the initial state of sidebar is visible on not * diff --git a/includes/templates/Footer.mustache b/includes/templates/Footer.mustache index 699c624..a3218e4 100644 --- a/includes/templates/Footer.mustache +++ b/includes/templates/Footer.mustache @@ -10,17 +10,15 @@ @prop footerItem[] array-items string|null html-user-language-attributes a string of attribute HTML - footerRow[] array-footer-rows iterable list of footer rows + footerRow data-info the info row + footerRow data-places the places row + footerRow data-icons the icons row }} {{! `role` is unnecessary but kept to support selectors in any gadgets or user styles and to mitigate a VoiceOver bug. }} diff --git a/includes/templates/Footer__row.mustache b/includes/templates/Footer__row.mustache new file mode 100644 index 0000000..a51119b --- /dev/null +++ b/includes/templates/Footer__row.mustache @@ -0,0 +1,5 @@ + diff --git a/stories/Footer.stories.data.js b/stories/Footer.stories.data.js index 9605324..f761d39 100644 --- a/stories/Footer.stories.data.js +++ b/stories/Footer.stories.data.js @@ -3,8 +3,8 @@ import { htmlUserLanguageAttributes } from './utils'; import footerTemplate from '!!raw-loader!../includes/templates/Footer.mustache'; -const FOOTER_ROWS = [ - { +const + FOOTER_INFO = { id: 'footer-info', 'array-items': [ { @@ -19,7 +19,7 @@ additional terms may apply. See Powered by MediaWiki` } ] - } -]; + }; export { footerTemplate }; export const FOOTER_TEMPLATE_DATA = { 'html-user-language-attributes': htmlUserLanguageAttributes, - 'array-footer-rows': FOOTER_ROWS + 'data-info': FOOTER_INFO, + 'data-places': FOOTER_PLACES, + 'data-icons': FOOTER_ICONS };