From 0e1edec723c2a3f218c7d7bf867b9882520f2436 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Tue, 8 Jan 2019 16:30:18 -0800 Subject: [PATCH] Apply the pseudo-css selector rules to diff and changelist pages The styles that we are applying on changelist pages should also apply on diff pages. This generalises the rules into a new module. To avoid problems with cached HTML mediawiki.special.changeslist temporarily loads resources/src/mediawiki.interface.helpers.styles. This will be removed after the change has been in production for a week. Bug: T212613 Change-Id: I6aad563e48f41c783df8b176a4f437e60a1255cc --- includes/actions/HistoryAction.php | 1 + includes/changes/ChangesList.php | 5 ++- includes/changes/EnhancedChangesList.php | 1 + includes/diff/DifferenceEngine.php | 5 ++- .../specialpage/ChangesListSpecialPage.php | 1 + includes/specials/SpecialContributions.php | 1 + resources/Resources.php | 33 +++++++++++++++++-- .../src/mediawiki.diff.styles/header.less | 9 ----- .../mediawiki.interface.helpers.styles.less | 32 ++++++++++++++++++ .../src/mediawiki.special.changeslist.less | 28 ---------------- 10 files changed, 75 insertions(+), 41 deletions(-) delete mode 100644 resources/src/mediawiki.diff.styles/header.less create mode 100644 resources/src/mediawiki.interface.helpers.styles.less diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index fdf4f85336..39bc830ddc 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -133,6 +133,7 @@ class HistoryAction extends FormlessAction { $out->setFeedAppendQuery( 'action=history' ); $out->addModules( 'mediawiki.action.history' ); $out->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', 'mediawiki.action.history.styles', 'mediawiki.special.changeslist', ] ); diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index b8ab971b94..bf275b36d3 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -289,7 +289,10 @@ class ChangesList extends ContextSource { $this->rcCacheIndex = 0; $this->lastdate = ''; $this->rclistOpen = false; - $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' ); + $this->getOutput()->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', + 'mediawiki.special.changeslist' + ] ); return '
'; } diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 51a26baab7..3e98f650e6 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -78,6 +78,7 @@ class EnhancedChangesList extends ChangesList { $this->rclistOpen = false; $this->getOutput()->addModuleStyles( [ 'mediawiki.icon', + 'mediawiki.interface.helpers.styles', 'mediawiki.special.changeslist', 'mediawiki.special.changeslist.enhanced', ] ); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 87863a4c12..8e2b96d080 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -956,7 +956,10 @@ class DifferenceEngine extends ContextSource { */ public function showDiffStyle() { if ( !$this->isSlotDiffRenderer ) { - $this->getOutput()->addModuleStyles( 'mediawiki.diff.styles' ); + $this->getOutput()->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', + 'mediawiki.diff.styles' + ] ); foreach ( $this->getSlotDiffRenderers() as $slotDiffRenderer ) { $slotDiffRenderer->addModules( $this->getOutput() ); } diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index dfdbc07d52..7cf36aa6db 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -1691,6 +1691,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { $out = $this->getOutput(); // Styles and behavior for the legend box (see makeLegend()) $out->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', 'mediawiki.special.changeslist.legend', 'mediawiki.special.changeslist', ] ); diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 3a180db60e..8a48aa6374 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -42,6 +42,7 @@ class SpecialContributions extends IncludableSpecialPage { $out = $this->getOutput(); // Modules required for viewing the list of contributions (also when included on other pages) $out->addModuleStyles( [ + 'mediawiki.interface.helpers.styles', 'mediawiki.special', 'mediawiki.special.changeslist', ] ); diff --git a/resources/Resources.php b/resources/Resources.php index 92930630db..3ddc8aa53b 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -914,9 +914,15 @@ return [ ], ], 'mediawiki.diff.styles' => [ + // FIXME: Remove class and lessMessages + // when I6aad563e48f41c783df8b176a4f437e60a1255cc has + // been in production for 1 week. 'class' => ResourceLoaderLessVarFileModule::class, 'styles' => [ - 'resources/src/mediawiki.diff.styles/header.less', + // Remove resources/src/mediawiki.interface.helpers.styles.less + // when I6aad563e48f41c783df8b176a4f437e60a1255cc has + // been in production for 1 week. + 'resources/src/mediawiki.interface.helpers.styles.less', 'resources/src/mediawiki.diff.styles/diff.css', 'resources/src/mediawiki.diff.styles/print.css' => [ 'media' => 'print' @@ -925,6 +931,7 @@ return [ 'lessMessages' => [ 'parentheses-start', 'parentheses-end', + 'pipe-separator' ], 'targets' => [ 'desktop', 'mobile' ], ], @@ -2008,6 +2015,20 @@ return [ 'oojs-ui.styles.icons-media', ], ], + 'mediawiki.interface.helpers.styles' => [ + 'class' => ResourceLoaderLessVarFileModule::class, + 'lessMessages' => [ + 'parentheses-start', + 'parentheses-end', + 'pipe-separator' + ], + 'styles' => [ + 'resources/src/mediawiki.interface.helpers.styles.less', + ], + 'targets' => [ + 'desktop', 'mobile' + ], + ], 'mediawiki.special' => [ 'styles' => [ 'resources/src/mediawiki.special/special.less', @@ -2123,13 +2144,21 @@ return [ 'targets' => [ 'desktop', 'mobile' ], ], 'mediawiki.special.changeslist' => [ + // FIXME: Remove class and lessMessages + // when I6aad563e48f41c783df8b176a4f437e60a1255cc has + // been in production for 1 week. 'class' => ResourceLoaderLessVarFileModule::class, 'lessMessages' => [ 'parentheses-start', 'parentheses-end', 'pipe-separator' ], - 'styles' => 'resources/src/mediawiki.special.changeslist.less', + 'styles' => [ + // FIXME: Remove this line when I6aad563e48f41c783df8b176a4f437e60a1255cc has + // been in production for 1 week. + 'resources/src/mediawiki.interface.helpers.styles.less', + 'resources/src/mediawiki.special.changeslist.less', + ], 'targets' => [ 'desktop', 'mobile' ], ], 'mediawiki.special.changeslist.enhanced' => [ diff --git a/resources/src/mediawiki.diff.styles/header.less b/resources/src/mediawiki.diff.styles/header.less deleted file mode 100644 index d41ea08e21..0000000000 --- a/resources/src/mediawiki.diff.styles/header.less +++ /dev/null @@ -1,9 +0,0 @@ -.mw-tag-markers { - &:before { - content: '@{msg-parentheses-start}'; - } - - &:after { - content: '@{msg-parentheses-end}'; - } -} diff --git a/resources/src/mediawiki.interface.helpers.styles.less b/resources/src/mediawiki.interface.helpers.styles.less new file mode 100644 index 0000000000..cfabab6838 --- /dev/null +++ b/resources/src/mediawiki.interface.helpers.styles.less @@ -0,0 +1,32 @@ +/** + * Helper classes used across special pages + */ + +/* Content dividers */ +/* @todo FIXME: Hard coded ". .". Is there a message for this? Should there be? */ +.mw-changeslist-separator:empty:before { + content: '. .'; +} + +.comment--without-parentheses, +.mw-changeslist-links, +.mw-diff-bytes, +/* Needed by pages calling ChangeTags::formatSummaryRow (T212613) */ +.mw-tag-markers, +.mw-uctop { + &:before { + content: '@{msg-parentheses-start}'; + } + + &:after { + content: '@{msg-parentheses-end}'; + } +} + +.mw-changeslist-links { + display: inline-block; + + > span:not( :first-child ):before { + content: '@{msg-pipe-separator}'; + } +} diff --git a/resources/src/mediawiki.special.changeslist.less b/resources/src/mediawiki.special.changeslist.less index db33f4abf7..ce43855681 100644 --- a/resources/src/mediawiki.special.changeslist.less +++ b/resources/src/mediawiki.special.changeslist.less @@ -60,31 +60,3 @@ .mw-rcfilters-ui-highlights { display: none; } - -/* Content dividers */ -/* @todo FIXME: Hard coded ". .". Is there a message for this? Should there be? */ -.mw-changeslist-separator:empty:before { - content: '. .'; -} - -.comment--without-parentheses, -.mw-changeslist-links, -.mw-diff-bytes, -.mw-tag-markers, -.mw-uctop { - &:before { - content: '@{msg-parentheses-start}'; - } - - &:after { - content: '@{msg-parentheses-end}'; - } -} - -.mw-changeslist-links { - display: inline-block; - - > span:not( :first-child ):before { - content: '@{msg-pipe-separator}'; - } -} -- 2.20.1