From: jdlrobson Date: Wed, 27 Mar 2019 00:35:01 +0000 (-0700) Subject: RecentChanges updated to use pseudo elements for presentation X-Git-Tag: 1.34.0-rc.0~2188^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=5040b3f680cde6d6e65ca8d1f36c90cb1f54f011;p=lhc%2Fweb%2Fwiklou.git RecentChanges updated to use pseudo elements for presentation Bug: T219348 Change-Id: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324 --- diff --git a/includes/Linker.php b/includes/Linker.php index 17dc0370f0..4f0ab6a65d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1001,7 +1001,7 @@ class Linker { * @return string */ public static function userToolLinksRedContribs( $userId, $userText, $edits = null ) { - return self::userToolLinks( $userId, $userText, true, 0, $edits ); + return self::userToolLinks( $userId, $userText, true, 0, $edits, false ); } /** diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 2389997949..184a2c10e6 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -617,7 +617,13 @@ class ChangesList extends ContextSource { return ' ' . $this->msg( 'rev-deleted-comment' )->escaped() . ''; } else { - return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); + return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(), + // Whether section links should refer to local page (using default false) + false, + // wikid to generate links for (using default null) */ + null, + // whether parentheses should be rendered as part of the message + false ); } } diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 3e98f650e6..81860590c3 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -393,7 +393,7 @@ class EnhancedChangesList extends ChangesList { } $classes = array_merge( $classes, $this->getHTMLClasses( $rcObj, $rcObj->watched ) ); - $separator = ' . . '; + $separator = ' '; $data['recentChangesFlags'] = [ 'newpage' => $type == RC_NEW, @@ -556,19 +556,22 @@ class EnhancedChangesList extends ChangesList { $isnew || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) { - $links['total-changes'] = $nchanges[$n]; + $links['total-changes'] = Html::rawElement( 'span', [], $nchanges[$n] ); } else { - $links['total-changes'] = $this->linkRenderer->makeKnownLink( - $block0->getTitle(), - new HtmlArmor( $nchanges[$n] ), - [ 'class' => 'mw-changeslist-groupdiff' ], - $queryParams + [ - 'diff' => $currentRevision, - 'oldid' => $last->mAttribs['rc_last_oldid'], - ] + $links['total-changes'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( + $block0->getTitle(), + new HtmlArmor( $nchanges[$n] ), + [ 'class' => 'mw-changeslist-groupdiff' ], + $queryParams + [ + 'diff' => $currentRevision, + 'oldid' => $last->mAttribs['rc_last_oldid'], + ] + ) ); if ( $sinceLast > 0 && $sinceLast < $n ) { - $links['total-changes-since-last'] = $this->linkRenderer->makeKnownLink( + $links['total-changes-since-last'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( $block0->getTitle(), new HtmlArmor( $sinceLastVisitMsg[$sinceLast] ), [ 'class' => 'mw-changeslist-groupdiff' ], @@ -576,7 +579,8 @@ class EnhancedChangesList extends ChangesList { 'diff' => $currentRevision, 'oldid' => $unvisitedOldid, ] - ); + ) + ); } } } @@ -585,17 +589,19 @@ class EnhancedChangesList extends ChangesList { if ( $allLogs || $rcObj->mAttribs['rc_type'] == RC_CATEGORIZE ) { // don't show history link for logs } elseif ( $namehidden || !$block0->getTitle()->exists() ) { - $links['history'] = $this->message['enhancedrc-history']; + $links['history'] = Html::rawElement( 'span', [], $this->message['enhancedrc-history'] ); } else { $params = $queryParams; $params['action'] = 'history'; - $links['history'] = $this->linkRenderer->makeKnownLink( + $links['history'] = Html::rawElement( 'span', [], + $this->linkRenderer->makeKnownLink( $block0->getTitle(), new HtmlArmor( $this->message['enhancedrc-history'] ), [ 'class' => 'mw-changeslist-history' ], $params - ); + ) + ); } # Allow others to alter, remove or add to these links @@ -606,8 +612,8 @@ class EnhancedChangesList extends ChangesList { return ''; } - $logtext = implode( $this->message['pipe-separator'], $links ); - $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped(); + $logtext = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + implode( ' ', $links ) ); return ' ' . $logtext; } @@ -653,10 +659,9 @@ class EnhancedChangesList extends ChangesList { $logPage = new LogPage( $logType ); $logTitle = SpecialPage::getTitleFor( 'Log', $logType ); $logName = $logPage->getName()->text(); - $data['logLink'] = $this->msg( 'parentheses' ) - ->rawParams( - $this->linkRenderer->makeKnownLink( $logTitle, $logName ) - )->escaped(); + $data['logLink'] = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + $this->linkRenderer->makeKnownLink( $logTitle, $logName ) + ); } else { $data['articleLink'] = $this->getArticleLink( $rcObj, $rcObj->unpatrolled, $rcObj->watched ); } @@ -664,16 +669,16 @@ class EnhancedChangesList extends ChangesList { # Diff and hist links if ( $type != RC_LOG && $type != RC_CATEGORIZE ) { $query['action'] = 'history'; - $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false ); } - $data['separatorAfterLinks'] = ' . . '; + $data['separatorAfterLinks'] = ' '; # Character diff if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { $data['characterDiff'] = $cd; - $data['separatorAftercharacterDiff'] = ' . . '; + $data['separatorAftercharacterDiff'] = ' '; } } @@ -686,7 +691,7 @@ class EnhancedChangesList extends ChangesList { $data['userTalkLink'] = $rcObj->usertalklink; $data['comment'] = $this->insertComment( $rcObj ); if ( $type == RC_CATEGORIZE ) { - $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query ); + $data['historyLink'] = $this->getDiffHistLinks( $rcObj, $query, false ); } $data['rollback'] = $this->getRollback( $rcObj ); } @@ -744,7 +749,11 @@ class EnhancedChangesList extends ChangesList { ] ); // everything else: makes it easier for extensions to add or remove data - $line .= implode( '', $data ); + foreach ( $data as $key => $dataItem ) { + $line .= Html::rawElement( 'span', [ + 'class' => 'mw-changeslist-line-inner-' . $key, + ], $dataItem ); + } $line .= "\n"; @@ -759,9 +768,10 @@ class EnhancedChangesList extends ChangesList { * * @param RCCacheEntry $rc * @param array $query array of key/value pairs to append as a query string + * @param bool $useParentheses (optional) Wrap comments in parentheses where needed * @return string HTML */ - public function getDiffHistLinks( RCCacheEntry $rc, array $query ) { + public function getDiffHistLinks( RCCacheEntry $rc, array $query, $useParentheses = true ) { $pageTitle = $rc->getTitle(); if ( $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE ) { // For categorizations we must swap the category title with the page title! @@ -773,15 +783,23 @@ class EnhancedChangesList extends ChangesList { } } - $retVal = ' ' . $this->msg( 'parentheses' ) - ->rawParams( $rc->difflink . $this->message['pipe-separator'] - . $this->linkRenderer->makeKnownLink( - $pageTitle, - new HtmlArmor( $this->message['hist'] ), - [ 'class' => 'mw-changeslist-history' ], - $query - ) )->escaped(); - return $retVal; + $histLink = $this->linkRenderer->makeKnownLink( + $pageTitle, + new HtmlArmor( $this->message['hist'] ), + [ 'class' => 'mw-changeslist-history' ], + $query + ); + if ( $useParentheses ) { + $retVal = $this->msg( 'parentheses' ) + ->rawParams( $rc->difflink . $this->message['pipe-separator'] + . $histLink )->escaped(); + } else { + $retVal = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-links' ], + Html::rawElement( 'span', [], $rc->difflink ) . + Html::rawElement( 'span', [], $histLink ) + ); + } + return ' ' . $retVal; } /** diff --git a/includes/changes/RCCacheEntryFactory.php b/includes/changes/RCCacheEntryFactory.php index e8c3a997ce..2d60ca28f7 100644 --- a/includes/changes/RCCacheEntryFactory.php +++ b/includes/changes/RCCacheEntryFactory.php @@ -82,7 +82,15 @@ class RCCacheEntryFactory { if ( !ChangesList::isDeleted( $cacheEntry, Revision::DELETED_USER ) ) { $cacheEntry->usertalklink = Linker::userToolLinks( $cacheEntry->mAttribs['rc_user'], - $cacheEntry->mAttribs['rc_user_text'] + $cacheEntry->mAttribs['rc_user_text'], + // Should the contributions link be red if the user has no edits (using default) + false, + // Customisation flags (using default 0) + 0, + // User edit count (using default ) + null, + // do not wrap the message in parentheses + false ); } diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index 6d45ed56ea..1f37a35e18 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -762,7 +762,9 @@ class LogFormatter { $user->getName(), true, // redContribsWhenNoEdits $toolFlags, - $user->getEditCount() + $user->getEditCount(), + // do not render parenthesises in the HTML markup (CSS will provide) + false ); } } diff --git a/includes/templates/EnhancedChangesListGroup.mustache b/includes/templates/EnhancedChangesListGroup.mustache index 6d9d6b0a82..5a5986f7cf 100644 --- a/includes/templates/EnhancedChangesListGroup.mustache +++ b/includes/templates/EnhancedChangesListGroup.mustache @@ -16,8 +16,8 @@ {{# rev-deleted-event }}{{{ . }}}{{/ rev-deleted-event }} {{{ articleLink }}}{{{ languageDirMark }}}{{{ logText }}} - . . - {{# charDifference }}{{{ . }}} . .{{/ charDifference }} + + {{# charDifference }}{{{ . }}} {{/ charDifference }} {{{ users }}} {{ numberofWatchingusers }} diff --git a/tests/phpunit/includes/changes/EnhancedChangesListTest.php b/tests/phpunit/includes/changes/EnhancedChangesListTest.php index eff2c851af..1511d46c5c 100644 --- a/tests/phpunit/includes/changes/EnhancedChangesListTest.php +++ b/tests/phpunit/includes/changes/EnhancedChangesListTest.php @@ -124,14 +124,14 @@ class EnhancedChangesListTest extends MediaWikiLangTestCase { $html = $this->createCategorizationLine( $this->getCategorizationChange( '20150629191735', 0, 0 ) ); - $this->assertNotContains( '(diff | hist)', strip_tags( $html ) ); + $this->assertNotContains( 'diffhist', strip_tags( $html ) ); } public function testCategorizationLineFormattingWithRevision() { $html = $this->createCategorizationLine( $this->getCategorizationChange( '20150629191735', 1025, 1024 ) ); - $this->assertContains( '(diff | hist)', strip_tags( $html ) ); + $this->assertContains( 'diffhist', strip_tags( $html ) ); } /** diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php index b1857cccf0..8f914b714a 100644 --- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php +++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php @@ -156,14 +156,15 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase { $this->assertValidHTML( $cacheEntry->usertalklink ); $this->assertRegExp( - '#^ \(.*talk.*\)#', + '#^ .*talk.*#', $cacheEntry->usertalklink, 'verify user talk link' ); $this->assertValidHTML( $cacheEntry->usertalklink ); $this->assertRegExp( - '#^ \(.*contribs.*\)$#', + '#^ .*' . + 'contribs.*$#', $cacheEntry->usertalklink, 'verify user tool links' );