diff options
author | jdlrobson <jdlrobson@gmail.com> | 2019-03-26 17:35:01 -0700 |
---|---|---|
committer | Roan Kattouw <roan.kattouw@gmail.com> | 2019-04-02 14:52:50 -0700 |
commit | 5040b3f680cde6d6e65ca8d1f36c90cb1f54f011 (patch) | |
tree | 12aed57956c0638006e0fdc42edafa74082c292c | |
parent | 80566f8a8014c0a3ec2ddc30f1164fb796d70169 (diff) | |
download | mediawikicore-5040b3f680cde6d6e65ca8d1f36c90cb1f54f011.tar.gz mediawikicore-5040b3f680cde6d6e65ca8d1f36c90cb1f54f011.zip |
RecentChanges updated to use pseudo elements for presentation
Bug: T219348
Change-Id: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
-rw-r--r-- | includes/Linker.php | 2 | ||||
-rw-r--r-- | includes/changes/ChangesList.php | 8 | ||||
-rw-r--r-- | includes/changes/EnhancedChangesList.php | 90 | ||||
-rw-r--r-- | includes/changes/RCCacheEntryFactory.php | 10 | ||||
-rw-r--r-- | includes/logging/LogFormatter.php | 4 | ||||
-rw-r--r-- | includes/templates/EnhancedChangesListGroup.mustache | 4 | ||||
-rw-r--r-- | tests/phpunit/includes/changes/EnhancedChangesListTest.php | 4 | ||||
-rw-r--r-- | tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php | 5 |
8 files changed, 81 insertions, 46 deletions
diff --git a/includes/Linker.php b/includes/Linker.php index 17dc0370f039..4f0ab6a65d71 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 2389997949ae..184a2c10e608 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -617,7 +617,13 @@ class ChangesList extends ContextSource { return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>'; } 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 3e98f650e683..81860590c3ac 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 = ' <span class="mw-changeslist-separator">. .</span> '; + $separator = ' <span class="mw-changeslist-separator"></span> '; $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'] = ' <span class="mw-changeslist-separator">. .</span> '; + $data['separatorAfterLinks'] = ' <span class="mw-changeslist-separator"></span> '; # Character diff if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { $data['characterDiff'] = $cd; - $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator">. .</span> '; + $data['separatorAftercharacterDiff'] = ' <span class="mw-changeslist-separator"></span> '; } } @@ -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 .= "</td></tr></table>\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 e8c3a997ced9..2d60ca28f7c1 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 6d45ed56ea7c..1f37a35e182e 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 6d9d6b0a8268..5a5986f7cf10 100644 --- a/includes/templates/EnhancedChangesListGroup.mustache +++ b/includes/templates/EnhancedChangesListGroup.mustache @@ -16,8 +16,8 @@ <td class="mw-changeslist-line-inner"> {{# rev-deleted-event }}<span class="history-deleted">{{{ . }}}</span>{{/ rev-deleted-event }} {{{ articleLink }}}{{{ languageDirMark }}}{{{ logText }}} - <span class="mw-changeslist-separator">. .</span> - {{# charDifference }}{{{ . }}} <span class="mw-changeslist-separator">. .</span>{{/ charDifference }} + <span class="mw-changeslist-separator"></span> + {{# charDifference }}{{{ . }}} <span class="mw-changeslist-separator"></span>{{/ charDifference }} <span class="changedby">{{{ users }}}</span> {{ numberofWatchingusers }} </td> diff --git a/tests/phpunit/includes/changes/EnhancedChangesListTest.php b/tests/phpunit/includes/changes/EnhancedChangesListTest.php index eff2c851afa3..1511d46c5c0a 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 b1857cccf04b..8f914b714a56 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( - '#^ <span class="mw-usertoollinks">\(.*<a .+>talk</a>.*\)</span>#', + '#^ <span class="mw-usertoollinks mw-changeslist-links">.*<span><a .+>talk</a></span>.*</span>#', $cacheEntry->usertalklink, 'verify user talk link' ); $this->assertValidHTML( $cacheEntry->usertalklink ); $this->assertRegExp( - '#^ <span class="mw-usertoollinks">\(.*<a .+>contribs</a>.*\)</span>$#', + '#^ <span class="mw-usertoollinks mw-changeslist-links">.*<span><a .+>' . + 'contribs</a></span>.*</span>$#', $cacheEntry->usertalklink, 'verify user tool links' ); |