r54242 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54241‎ | r54242 | r54243 >
Date:22:15, 2 August 2009
Author:simetrical
Status:resolved (Comments)
Tags:
Comment:
Add legend and tooltips to explain RC flags

Based on a patch submitted by svip on IRC. I also changed the <span>
for unpatrolled into an <abbr>, and created a new message in case anyone
wants to localize !, for the sake of uniformity.
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ChangesList.php
@@ -68,8 +68,8 @@
6969 */
7070 private function preCacheMessages() {
7171 if( !isset( $this->message ) ) {
72 - foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
73 - 'blocklink history boteditletter semicolon-separator pipe-separator' ) as $msg ) {
 72+ foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
 73+ 'semicolon-separator pipe-separator' ) as $msg ) {
7474 $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
7575 }
7676 }
@@ -86,16 +86,44 @@
8787 * @return string
8888 */
8989 protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false ) {
90 - $f = $new ?
91 - '<abbr class="newpage">' . $this->message['newpageletter'] . '</abbr>' : $nothing;
92 - $f .= $minor ?
93 - '<abbr class="minor">' . $this->message['minoreditletter'] . '</abbr>' : $nothing;
94 - $f .= $bot ? '<abbr class="bot">' . $this->message['boteditletter'] . '</abbr>' : $nothing;
95 - $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
 90+ $f = $new ? self::flag( 'newpage' ) : $nothing;
 91+ $f .= $minor ? self::flag( 'minor' ) : $nothing;
 92+ $f .= $bot ? self::flag( 'bot' ) : $nothing;
 93+ $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing;
9694 return $f;
9795 }
9896
9997 /**
 98+ * Provide the <abbr> element appropriate to a given abbreviated flag,
 99+ * namely the flag indicating a new page, a minor edit, a bot edit, or an
 100+ * unpatrolled edit. By default in English it will contain "N", "m", "b",
 101+ * "!" respectively, plus it will have an appropriate title and class.
 102+ *
 103+ * @param $key string 'newpage', 'unpatrolled', 'minor', or 'bot'
 104+ * @return string Raw HTML
 105+ */
 106+ public static function flag( $key ) {
 107+ static $messages = null;
 108+ if ( is_null( $messages ) ) {
 109+ foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' .
 110+ 'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' .
 111+ 'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) {
 112+ $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' );
 113+ }
 114+ }
 115+ # Inconsistent naming, bleh
 116+ if ( $key == 'newpage' || $key == 'unpatrolled' ) {
 117+ $key2 = $key;
 118+ } else {
 119+ $key2 = $key . 'edit';
 120+ }
 121+ return "<abbr class=\"$key\" title=\""
 122+ . $messages["recentchanges-label-$key"] . "\">"
 123+ . $messages["${key2}letter"]
 124+ . '</abbr>';
 125+ }
 126+
 127+ /**
100128 * Returns text for the start of the tabular part of RC
101129 * @return string
102130 */
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -457,6 +457,13 @@
458458 Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
459459 );
460460
 461+ # TODO: This is probably a bad format for the message. If anyone
 462+ # customizes it and we add a new flag, it won't show up in the
 463+ # customized message unless it's changed.
 464+ $wgOut->addWikiMsg( 'recentchanges-label-legend',
 465+ ChangesList::flag( 'newpage' ), ChangesList::flag( 'minor' ),
 466+ ChangesList::flag( 'bot' ), ChangesList::flag( 'unpatrolled' ) );
 467+
461468 $this->setBottomText( $wgOut, $opts );
462469 }
463470
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1963,6 +1963,11 @@
19641964 'recentchanges-legend' => 'Recent changes options',
19651965 'recentchangestext' => 'Track the most recent changes to the wiki on this page.',
19661966 'recentchanges-feed-description' => 'Track the most recent changes to the wiki in this feed.',
 1967+'recentchanges-label-legend' => "Legend: $1 - new page, $2 - minor edit, $3 - bot edit, $4 - unpatrolled edit.",
 1968+'recentchanges-label-newpage' => 'This edit created a new page',
 1969+'recentchanges-label-minor' => 'This is a minor edit',
 1970+'recentchanges-label-bot' => 'This edit was performed by a bot',
 1971+'recentchanges-label-unpatrolled' => 'This edit has not yet been patrolled',
19671972 'rcnote' => "Below {{PLURAL:$1|is '''1''' change|are the last '''$1''' changes}} in the last {{PLURAL:$2|day|'''$2''' days}}, as of $5, $4.",
19681973 'rcnotefrom' => "Below are the changes since '''$2''' (up to '''$1''' shown).",
19691974 'rclistfrom' => 'Show new changes starting from $1',
@@ -1980,6 +1985,7 @@
19811986 'minoreditletter' => 'm',
19821987 'newpageletter' => 'N',
19831988 'boteditletter' => 'b',
 1989+'unpatrolledletter' => '!', # only translate this message to other languages if you have to change it
19841990 'sectionlink' => '→', # only translate this message to other languages if you have to change it
19851991 'number_of_watching_users_RCview' => '[$1]', # do not translate or duplicate this message to other languages
19861992 'number_of_watching_users_pageview' => '[$1 watching {{PLURAL:$1|user|users}}]',
Index: trunk/phase3/RELEASE-NOTES
@@ -180,6 +180,8 @@
181181 * (bug 16322) Allow maintenance scripts to accept DB user/pass over input or params
182182 * (bug 18566) Maintenance script to un/protect pages
183183 * (bug 671) The HTML <abbr> tag is now permitted.
 184+* RecentChanges now has a legend to explain what the Nmb! flags mean, and the
 185+ flags have tooltips.
184186
185187 === Bug fixes in 1.16 ===
186188
Index: trunk/phase3/maintenance/language/messages.inc
@@ -1149,6 +1149,11 @@
11501150 'recentchanges-legend',
11511151 'recentchangestext',
11521152 'recentchanges-feed-description',
 1153+ 'recentchanges-label-legend',
 1154+ 'recentchanges-label-newpage',
 1155+ 'recentchanges-label-minor',
 1156+ 'recentchanges-label-bot',
 1157+ 'recentchanges-label-unpatrolled',
11531158 'rcnote',
11541159 'rcnotefrom',
11551160 'rclistfrom',
@@ -1166,6 +1171,7 @@
11671172 'minoreditletter',
11681173 'newpageletter',
11691174 'boteditletter',
 1175+ 'unpatrolledletter',
11701176 'sectionlink',
11711177 'number_of_watching_users_RCview',
11721178 'number_of_watching_users_pageview',
Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -341,6 +341,7 @@
342342 'timezone-utc',
343343 'whatlinkshere-backlink',
344344 'recentchangeslinked-backlink',
 345+ 'unpatrolledletter',
345346 'diff-with-additional',
346347 'pagetitle-view-mainpage',
347348 'trackback',
Index: trunk/phase3/skins/common/shared.css
@@ -68,7 +68,7 @@
6969 background-color: #ffa;
7070 }
7171
72 -span.unpatrolled {
 72+.unpatrolled {
7373 font-weight: bold;
7474 color: red;
7575 }
@@ -436,7 +436,7 @@
437437 }
438438
439439 /** Generic minor/bot/newpage styling */
440 -abbr.newpage, abbr.minor, abbr.bot {
 440+.newpage, .minor, .bot {
441441 font-weight: bold;
442442 }
443443
Index: trunk/phase3/CREDITS
@@ -102,6 +102,7 @@
103103 * Simon Walker
104104 * Stefano Codari
105105 * Str4nd
 106+* svip
106107
107108 == Translators ==
108109 * Anders Wegge Jakobsen

Follow-up revisions

RevisionCommit summaryAuthorDate
r54248Add legend to watchlist as well...simetrical00:21, 3 August 2009
r54258Make work with core r54242nikerabbit09:14, 3 August 2009
r54335Show change flag tooltips everywhere, not just RC...simetrical00:28, 4 August 2009
r54336Only show useful info in RC legend...simetrical00:48, 4 August 2009
r54337Add wrapper div for RC label legend...simetrical00:50, 4 August 2009

Comments

#Comment by Nikerabbit (talk | contribs)   09:14, 3 August 2009

I don't quite like the redundancy (legend + tooltips). Recent changes is already quite big in terms of html source code.

#Comment by Svippong (talk | contribs)   14:40, 3 August 2009

I think the redundancy in this case makes sense. The legend is pretty much required. The tooltips is to describe the flags where they are. When it comes to usability, redundancy is usually better. Especially having both a legend and tooltips.

True, the legend is much less HTML than each tooltip will make up to be. But they serve a common purpose.

#Comment by Simetrical (talk | contribs)   16:59, 3 August 2009

Well, at least the legend is necessary, because currently there's no explanation at all. The tooltips I'm not as attached to, but I agree with svip that redundancy is good for usability. RC is big because it has lots of content!

#Comment by Umherirrender (talk | contribs)   16:23, 3 August 2009

Please wrap 'recentchanges-label-legend' into a div with id. Then users can add own style. Thanks.

#Comment by Simetrical (talk | contribs)   00:51, 4 August 2009

Done in r54337. I used a class instead of id because classes are more flexible; we don't necessarily want to restrict ourselves to having only one of these. (For instance, some skin might want to put another one on the bottom of the page.)

#Comment by Umherirrender (talk | contribs)   17:29, 3 August 2009

Missing tooltip for Diffs and Contributions, see r53975 for all places where the span was changed to abbr.

#Comment by Simetrical (talk | contribs)   00:28, 4 August 2009

Thanks for the pointer, fixed in r54335.

#Comment by Brion VIBBER (talk | contribs)   22:26, 4 August 2009

We've lived without a legend for years, and of course note that it's not visible unless you're scrolled to the top anyway. :)

IMO the legend is also just not very attractive... the formatting looks very odd and it doesn't feel in place on the page.

#Comment by Simetrical (talk | contribs)   00:07, 5 August 2009

But currently there's no way for users to figure out what the flags actually mean. Do you think the tooltips are sufficient? I guess the meaning isn't really important for most users, so maybe having the info only in tooltips is acceptable.

#Comment by Werdna (talk | contribs)   17:01, 27 August 2009

Fixed up in later revisions.

Status & tagging log