r86490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86489‎ | r86490 | r86491 >
Date:16:28, 20 April 2011
Author:happy-melon
Status:resolved (Comments)
Tags:
Comment:
Restore r84687 (reverted in r84751). Now with a few extra features:
* Now called 'overview' rather than 'scapmap', to hopefully prevent more IRC-cabal reverts :P
* Tab is added to p-namespaces, not into the dropdown menu in p-cactions
* Clicking again on the tab hides the overview.
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.css (modified) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.overview.css (added) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.overview.js (added) (history)
  • /trunk/extensions/CodeReview/ui/CodeView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -156,6 +156,13 @@
157157 'dependencies' => 'jquery.tipsy'
158158 ) + $commonModuleInfo;
159159
 160+// Revision 'scapmap':
 161+$wgResourceModules['ext.codereview.overview'] = array(
 162+ 'scripts' => 'ext.codereview.overview.js',
 163+ 'styles' => 'ext.codereview.overview.css',
 164+ 'dependencies' => 'jquery.tipsy'
 165+) + $commonModuleInfo;
 166+
160167 // If you are running a closed svn, fill the following two lines with the username and password
161168 // of a user allowed to access it. Otherwise, leave it false.
162169 // This is only necessary if using the shell method to access Subversion
Index: trunk/extensions/CodeReview/modules/ext.codereview.css
@@ -7,6 +7,7 @@
88 overflow:auto;
99 }
1010
 11+.TablePager_col_selectforchange,
1112 .TablePager_col_comments {
1213 text-align: center;
1314 }
Index: trunk/extensions/CodeReview/modules/ext.codereview.overview.css
@@ -0,0 +1,82 @@
 2+#overviewmap {
 3+ border: 1px solid #2F6FAB;
 4+ padding: 2px;
 5+ min-width: 300px;
 6+}
 7+#overviewmap #overviewpop {
 8+ padding: 3px;
 9+ border: 1px solid black;
 10+ position: absolute;
 11+ height: 6.5em;
 12+ width: 16em;
 13+ display: none;
 14+ background-color: #ffffdd;
 15+ font-size: 80%;
 16+ line-height: 100%;
 17+ overflow: hidden;
 18+ white-space: pre;
 19+}
 20+#overviewmap > a {
 21+ display: block;
 22+ border: 1px solid #888;
 23+ float: left;
 24+ width: 26px; /* 26px for body + 2px for border + 2px for margin = 30px total */
 25+ height: 26px;
 26+ margin: 1px;
 27+ overflow: hidden;
 28+}
 29+#overviewmap > a:target {
 30+ border-style: dashed;
 31+}
 32+#overviewmap .summary {
 33+ clear: both;
 34+}
 35+
 36+/** Revision statuses **/
 37+.box-status-new {
 38+ background: #ffffc0 !important;
 39+}
 40+.box-status-new:hover {
 41+ background: #dfdfa0 !important;
 42+}
 43+.box-status-fixme {
 44+ background: #ff9999 !important;
 45+}
 46+.box-status-fixme:hover {
 47+ background: #df0000 !important;
 48+}
 49+.box-status-resolved {
 50+ background: #b0eeb0 !important;
 51+}
 52+.box-status-resolved:hover {
 53+ background: #80ff80 !important;
 54+}
 55+.box-status-reverted {
 56+ background: #bbddee !important;
 57+}
 58+.box-status-reverted:hover {
 59+ background: #66bbff !important;
 60+}
 61+.box-status-deferred {
 62+ background: #dddddd !important;
 63+}
 64+.box-status-deferred:hover {
 65+ background: #aaaaaa !important;
 66+}
 67+
 68+.box-live-live {
 69+ border: 1px solid #00ff00 !important;
 70+}
 71+
 72+table.TablePager tr:target {
 73+ font-weight: bold;
 74+}
 75+
 76+.overview-backlink {
 77+ clear:both;
 78+ display: none;
 79+}
 80+
 81+tr:target .overview-backlink {
 82+ display: inline;
 83+}
\ No newline at end of file
Property changes on: trunk/extensions/CodeReview/modules/ext.codereview.overview.css
___________________________________________________________________
Added: svn:eol-style
184 + native
Index: trunk/extensions/CodeReview/modules/ext.codereview.overview.js
@@ -0,0 +1,142 @@
 2+/* Scap roadmap viewer, version [0.0.7]
 3+ * Originally from: http://www.mediawiki.org/wiki/User:Splarka/scapmap.js
 4+ *
 5+ *
 6+ * Loads on, for example: http://www.mediawiki.org/wiki/Special:Code/MediaWiki
 7+ * Click [overview] to generate map.
 8+ * Text in the "path" input box is stripped from the path line in the summary.
 9+ * Clicking a colored box takes you to that relevant line, and a backlink is created in the id column on focus.
 10+ * Hovering over a colored box pops up a little info packet box.
 11+ */
 12+jQuery( function( $ ) {
 13+ // check if we're on a page with a useful list of revisions
 14+ if( $( '#path' ).size() && $('table.TablePager').size() ) {
 15+ var portlet = $( '#p-namespaces' ).size() ? 'p-namespaces' : 'p-cactions';
 16+ mw.util.addPortletLink(
 17+ portlet,
 18+ '#',
 19+ 'Overview',
 20+ 'ca-scapmap',
 21+ 'Show a graphical overview of this list.',
 22+ '1',
 23+ '' // Nextnode, needs to be defined but we actually don't care
 24+ );
 25+ }
 26+
 27+ $('#ca-scapmap').click( function () {
 28+ var $tr = $('table.TablePager tr');
 29+ if( $tr.size() < 2 ){
 30+ return;
 31+ } else if( $('#overviewmap').size() ) {
 32+ // We've already created it; maybe they just want to toggle it on and off
 33+ $('#overviewmap').slideToggle();
 34+ return;
 35+ }
 36+
 37+ var overviewPopupData = {};
 38+
 39+ $( '#contentSub' ).after( $( '<div id="overviewmap">' ) );
 40+ $( '#overviewmap' ).slideUp( 0 );
 41+
 42+ var vpath = $( '#path' ).val();
 43+ var totals = {};
 44+ $tr.each( function( i ){
 45+ var live = 'notlive';
 46+ var status = false;
 47+
 48+ var trc = $(this).attr( 'class' ).split(' ');
 49+ if( !trc.length ) {
 50+ return;
 51+ }
 52+ for( var j = 0; j < trc.length; j++ ) {
 53+ // WMF doesn't use live/not live ATM
 54+ // if( /mw\-codereview\-(not|)live/.test( trc[j] ) )
 55+ // live = trc[j].substring( 14 );
 56+ if( trc[j].substring( 0, 21 ) == 'mw-codereview-status-' ) {
 57+ status = trc[j].substring( 21 );
 58+ }
 59+ }
 60+ var $td = $( 'td', $(this) );
 61+
 62+ var statusname = $td.filter( '.TablePager_col_cr_status' ).text();
 63+
 64+ if( !statusname || !status || !live ) {
 65+ return;
 66+ }
 67+
 68+ var rev = $td.filter( '.TablePager_col_cr_id, .TablePager_col_cp_rev_id' ).text();
 69+ overviewPopupData[i] = {
 70+ 'status' : status,
 71+ 'statusname' : statusname,
 72+ 'notes' : $td.filter( '.TablePager_col_comments' ).text(),
 73+ 'author' : $td.filter( '.TablePager_col_cr_author' ).text(),
 74+ 'rev' : rev
 75+ };
 76+
 77+ var path = $td.filter( '.TablePager_col_cr_path' ).text();
 78+ if( path && path.indexOf( vpath ) == 0 && path != vpath && vpath != '' ) {
 79+ path = '\u2026' + path.substring( vpath.length );
 80+ }
 81+ overviewPopupData[i]['path'] = path;
 82+
 83+ //overviewPopupData[i]['live'] = live;
 84+ if( !totals[statusname] ) {
 85+ totals[statusname] = 0;
 86+ }
 87+ //if( !totals[live] ) {
 88+ // totals[live] = 0;
 89+ //}
 90+ totals[statusname]++;
 91+ //totals[live]++;
 92+
 93+ $(this).attr( 'id', 'TablePager-row-' + rev );
 94+
 95+ $td.filter( '.TablePager_col_selectforchange' )
 96+ .append( $( '<a href="#box-' + i + '" class="overview-backlink">^</a>' ) );
 97+
 98+ var $box = $( '<a href="#TablePager-row-' + rev + '" class="box-status-' + status + '" id="box-' + i + '"> </a>' );
 99+ // $box.append( document.createTextNode( live ) );
 100+ $( '#overviewmap' ).append( $box );
 101+ });
 102+
 103+ var sumtext = [];
 104+ for( var i in totals ) {
 105+ if( typeof i != 'string' || typeof totals[i] != 'number' ) {
 106+ continue;
 107+ }
 108+ sumtext.push( i + ': ' + totals[i] );
 109+ }
 110+ sumtext.sort();
 111+ var $summary = $( '<div class="summary">' )
 112+ .text( 'Total revisions: ' + ( $tr.size() - 1 ) + '. [' + sumtext.join(', ') + ']' );
 113+
 114+ $( '#overviewmap' )
 115+ .append( $summary )
 116+ .css( 'max-width', Math.floor( Math.sqrt( $tr.size() ) ) * 30 )
 117+ .slideDown();
 118+
 119+ // Add the hover popup
 120+ $( '#overviewmap > a' )
 121+ .mouseenter( function () {
 122+
 123+ var $el = $( this );
 124+ if ( $el.data('overviewPopup') ) {
 125+ return; // already processed
 126+ }
 127+ $el.tipsy( { fade: true, gravity: 'sw', html:true } );
 128+ var id = parseInt( $(this).attr( 'id' ).replace( /box\-/i, '' ) );
 129+
 130+ var $popup = $( '<div id="overviewpop">' +
 131+ '<div>Rev: r<span id="overviewpop-rev">' + overviewPopupData[id]['rev'] +
 132+ '</span> (<span id="overviewpop-status">' + overviewPopupData[id]['status'] + '</span>)</div>' +
 133+ '<div>Number of notes: <span id="overviewpop-notes">' + overviewPopupData[id]['notes'] + '</span></div>' +
 134+ '<div>Path: <span id="overviewpop-path">' + overviewPopupData[id]['path'] + '</span></div>' +
 135+ '<div>Author: r<span id="overviewpop-author">' + overviewPopupData[id]['author'] + '</span></div>' +
 136+ //'<div>Live: <span id="overviewpop-live">' + overviewPopupData[id]['live'] + '</span></div>' +
 137+ '</div>')
 138+ $el.attr( 'title', $popup.html() );
 139+ $el.data( 'codeTooltip', true );
 140+ $el.tipsy( 'show' );
 141+ });
 142+ });
 143+} );
Property changes on: trunk/extensions/CodeReview/modules/ext.codereview.overview.js
___________________________________________________________________
Added: svn:eol-style
1144 + native
Index: trunk/extensions/CodeReview/ui/CodeView.php
@@ -151,4 +151,10 @@
152152 $s .= "</tr>\n";
153153 return $s;
154154 }
 155+
 156+ function getStartBody() {
 157+ global $wgOut;
 158+ $wgOut->addModules( 'ext.codereview.overview' );
 159+ return parent::getStartBody();
 160+ }
155161 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r90889Followup r86490, remove spurious rreedy17:36, 27 June 2011
r90893Follow-up r86490 CR: localise strings and synchronise CSS styles.happy-melon17:49, 27 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84687Integrate scapmap into CodeReview core.happy-melon17:05, 24 March 2011
r84751Per IRC cabal: revert r84687 (integrate scapmap to CodeReview)....demon15:29, 25 March 2011

Comments

#Comment by Reedy (talk | contribs)   14:35, 22 April 2011

Looks fine this time ;P

More obvious place

#Comment by Krinkle (talk | contribs)   18:23, 6 June 2011
mw.util.addPortletLink(
+				portlet,
+				'#',
+				'Overview',
+				'ca-scapmap',
+				'Show a graphical overview of this list.',
+				'1',
+				'' // Nextnode, needs to be defined but we actually don't care
+				);

lies, nextnode is not requires. Only the first three paramters are required. A string is not a valid nextnode value and will either be ignored or cause a useless jQuery object to be created.

Also '1' is allowed as accesskey, but did you intend it as an actual accesskey or meant to skip it ?

These strings are hardcoded and not localized, please use mw.msg()


+#overviewmap #overviewpop {

Seems overly specific, unless there are going to be different contexts #overviewpop is shorter and faster.

+				// WMF doesn't use live/not live ATM
+				// if( /mw\-codereview\-(not|)live/.test( trc[j] ) )
+				// 	live = trc[j].substring( 14 );
+				if( trc[j].substring( 0, 21 ) == 'mw-codereview-status-' ) {
..
+			//if( !totals[live] ) {
+			//	totals[live] = 0;
+			//

This kind of code may be fine for an on-wiki gadget, but Wikimedia's configuration is irrelevant for this extension.

If the status values options are needed, they should be exposed to the frontend through mw.config.

#Comment by Krinkle (talk | contribs)   18:31, 6 June 2011

+			.css( 'max-width', Math.floor( Math.sqrt( $tr.size() ) ) * 30 )

This doesn't make sense to me. The end-result is an element with inline-styling max-width, and min-width (which may be higher) in the stylesheet.

See http://i.imgur.com/QGOTl.png

Also there seems to be some inconsistency with the colors (blue is reverted, dark grey is deferred). Can't the same classnames be used that style the table rows ?

And a character "r" is added in front of all username.. ?

#Comment by Krinkle (talk | contribs)   18:32, 6 June 2011

Nevermind about the max-width, if there are more than x items it's not redundant (which in most cases there will be). Nice.

#Comment by Happy-melon (talk | contribs)   17:21, 27 June 2011

And a character "r" is added in front of all username.. ?

Where?

#Comment by OverlordQ (talk | contribs)   17:27, 27 June 2011
'<div>Author: r<span id="overviewpop-author">' + overviewPopupData[id]['author'] + '</span></div>' +

Status & tagging log