http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84687

Revision: 84687
Author:   happy-melon
Date:     2011-03-24 17:05:49 +0000 (Thu, 24 Mar 2011)
Log Message:
-----------
Integrate scapmap into CodeReview core.

Modified Paths:
--------------
    trunk/extensions/CodeReview/CodeReview.php
    trunk/extensions/CodeReview/modules/ext.codereview.css
    trunk/extensions/CodeReview/ui/CodeView.php

Added Paths:
-----------
    trunk/extensions/CodeReview/modules/ext.codereview.scapmap.css
    trunk/extensions/CodeReview/modules/ext.codereview.scapmap.js

Modified: trunk/extensions/CodeReview/CodeReview.php
===================================================================
--- trunk/extensions/CodeReview/CodeReview.php  2011-03-24 17:04:02 UTC (rev 
84686)
+++ trunk/extensions/CodeReview/CodeReview.php  2011-03-24 17:05:49 UTC (rev 
84687)
@@ -155,6 +155,13 @@
        'dependencies' => 'jquery.tipsy'
 ) + $commonModuleInfo;
 
+// Revision 'scapmap':
+$wgResourceModules['ext.codereview.scapmap'] = array(
+       'scripts' => 'ext.codereview.scapmap.js',
+       'styles' => 'ext.codereview.scapmap.css',
+       'dependencies' => 'jquery.tipsy'
+) + $commonModuleInfo;
+
 // If you are running a closed svn, fill the following two lines with the 
username and password
 // of a user allowed to access it. Otherwise, leave it false.
 // This is only necessary if using the shell method to access Subversion

Modified: trunk/extensions/CodeReview/modules/ext.codereview.css
===================================================================
--- trunk/extensions/CodeReview/modules/ext.codereview.css      2011-03-24 
17:04:02 UTC (rev 84686)
+++ trunk/extensions/CodeReview/modules/ext.codereview.css      2011-03-24 
17:05:49 UTC (rev 84687)
@@ -7,6 +7,7 @@
        overflow:auto;
 }
 
+.TablePager_col_selectforchange,
 .TablePager_col_comments {
        text-align: center;
 }

Added: trunk/extensions/CodeReview/modules/ext.codereview.scapmap.css
===================================================================
--- trunk/extensions/CodeReview/modules/ext.codereview.scapmap.css              
                (rev 0)
+++ trunk/extensions/CodeReview/modules/ext.codereview.scapmap.css      
2011-03-24 17:05:49 UTC (rev 84687)
@@ -0,0 +1,82 @@
+#overviewmap {
+       border: 1px solid #2F6FAB;
+       padding: 2px;
+       min-width: 300px;
+}
+#overviewmap #overviewpop {
+       padding: 3px;
+       border: 1px solid black;
+       position: absolute;
+       height: 6.5em;
+       width: 16em;
+       display: none;
+       background-color: #ffffdd;
+       font-size: 80%;
+       line-height: 100%;
+       overflow: hidden;
+       white-space: pre;
+}
+#overviewmap > a {
+       display: block;
+       border: 1px solid #888;
+       float: left;
+       width: 26px; /* 26px for body + 2px for border + 2px for margin = 30px 
total */
+       height: 26px;
+       margin: 1px;
+       overflow: hidden;
+}
+#overviewmap > a:target {
+       border-style: dashed;
+}
+#overviewmap .summary {
+       clear: both;
+}
+
+/** Revision statuses **/
+.box-status-new {
+       background:  #ffffc0 !important;
+}
+.box-status-new:hover {
+       background:  #dfdfa0 !important;
+}
+.box-status-fixme {
+       background:  #ff9999 !important;
+}
+.box-status-fixme:hover {
+       background:  #df0000 !important;
+}
+.box-status-resolved {
+       background:  #b0eeb0 !important;
+}
+.box-status-resolved:hover {
+       background:  #80ff80 !important;
+}
+.box-status-reverted {
+       background:  #bbddee !important;
+} 
+.box-status-reverted:hover {
+       background:  #66bbff !important;
+}
+.box-status-deferred {
+       background:  #dddddd !important;
+} 
+.box-status-deferred:hover {
+       background:  #aaaaaa !important;
+}
+
+.box-live-live {
+       border: 1px solid #00ff00 !important;
+}
+
+table.TablePager tr:target {
+       font-weight: bold;
+}
+
+.overview-backlink {
+       clear:both;
+       display: none;
+}
+
+tr:target .overview-backlink {
+       display: inline;
+}
\ No newline at end of file


Property changes on: 
trunk/extensions/CodeReview/modules/ext.codereview.scapmap.css
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/extensions/CodeReview/modules/ext.codereview.scapmap.js
===================================================================
--- trunk/extensions/CodeReview/modules/ext.codereview.scapmap.js               
                (rev 0)
+++ trunk/extensions/CodeReview/modules/ext.codereview.scapmap.js       
2011-03-24 17:05:49 UTC (rev 84687)
@@ -0,0 +1,137 @@
+/* Scap roadmap viewer, version [0.0.7]
+ * Originally from: http://www.mediawiki.org/wiki/User:Splarka/scapmap.js
+ *
+ *
+ * Loads on, for example: http://www.mediawiki.org/wiki/Special:Code/MediaWiki
+ * Click [overview] to generate map.
+ * Text in the "path" input box is stripped from the path line in the summary.
+ * Clicking a colored box takes you to that relevant line, and a backlink is 
created in the id column on focus.
+ * Hovering over a colored box pops up a little info packet box.
+ */
+
+// check if we're on a page with a useful list of revisions
+( function( $ ) {
+       if( $( '#path' ).size() && $('table.TablePager').size() ) {
+               mw.util.addPortletLink(
+                               'p-cactions',
+                               '#',
+                               'Overview',
+                               'ca-scapmap',
+                               'Show a graphical overview of this list.',
+                               '1'
+                               );
+       }
+
+       $('#ca-scapmap').click( function ( $ ) {
+               var $tr = $('table.TablePager tr');
+               if( $tr.size() < 2 || $('#overviewmap').size() ) {
+                       return;
+               }
+
+               var overviewPopupData = {};
+
+               $( '#contentSub' ).after( $( '<div id="overviewmap">' ) );
+               $( '#overviewmap' ).slideUp( 0 );
+
+               var vpath = $( '#path' ).val();
+               var totals = {};
+               $tr.each( function( i ){
+                       var live = 'notlive';
+                       var status = false;
+
+                       var trc = $(this).attr( 'class' ).split(' ');
+                       if( !trc.length ) {
+                               return;
+                       }
+                       for( var j = 0; j < trc.length; j++ ) {
+                               // 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-' ) {
+                                       status = trc[j].substring( 21 );
+                               }
+                       }
+                       var $td = $( 'td', $(this) );
+
+                       var statusname = $td.filter( 
'.TablePager_col_cr_status' ).text();
+
+                       if( !statusname || !status || !live ) {
+                               return;
+                       }
+
+                       var rev = $td.filter( '.TablePager_col_cr_id, 
.TablePager_col_cp_rev_id' ).text();
+                       overviewPopupData[i] = {
+                               'status' : status,
+                               'statusname' : statusname,
+                               'notes' : $td.filter( 
'.TablePager_col_comments' ).text(),
+                               'author' : $td.filter( 
'.TablePager_col_cr_author' ).text(),
+                               'rev' : rev
+                       };
+
+                       var path = $td.filter( '.TablePager_col_cr_path' 
).text();
+                       if( path && path.indexOf( vpath ) == 0 && path != vpath 
&& vpath != '' ) {
+                               path = '\u2026' + path.substring( vpath.length 
);
+                       }
+                       overviewPopupData[i]['path'] = path;
+
+                       //overviewPopupData[i]['live'] = live;
+                       if( !totals[statusname] ) {
+                               totals[statusname] = 0;
+                       }
+                       //if( !totals[live] ) {
+                       //      totals[live] = 0;
+                       //}
+                       totals[statusname]++;
+                       //totals[live]++;
+
+                       $(this).attr( 'id', 'TablePager-row-' + rev );
+
+                       $td.filter( '.TablePager_col_selectforchange' )
+                               .append( $( '<a href="#box-' + i + '" 
class="overview-backlink">^</a>' ) );
+
+                       var $box = $( '<a href="#TablePager-row-' + rev + '" 
class="box-status-' + status + '" id="box-' + i + '"> </a>' );
+                       // $box.append( document.createTextNode( live ) );
+                       $( '#overviewmap' ).append( $box );
+               });
+
+               var sumtext = [];
+               for( var i in totals ) {
+                       if( typeof i != 'string' || typeof totals[i] != 
'number' ) {
+                               continue;
+                       }
+                       sumtext.push( i + ': ' + totals[i] );
+               }
+               sumtext.sort();
+               var $summary = $( '<div class="summary">' )
+                       .text( 'Total revisions: ' + ( $tr.size() - 1 ) + '. [' 
+ sumtext.join(', ') + ']' );
+
+               $( '#overviewmap' )
+                       .append( $summary )
+                       .css( 'max-width', Math.floor( Math.sqrt( $tr.size() ) 
) * 30 )
+                       .slideDown();
+
+               // Add the hover popup
+               $( '#overviewmap > a' )
+                       .mouseenter( function () {
+
+                       var $el = $( this );
+                               if ( $el.data('overviewPopup') ) {
+                                       return; // already processed
+                               }
+                               $el.tipsy( { fade: true, gravity: 'sw', 
html:true } );
+                               var id = parseInt( $(this).attr( 'id' 
).replace( /box\-/i, '' ) );
+
+                               var $popup = $( '<div id="overviewpop">' +
+                                       '<div>Rev: r<span 
id="overviewpop-rev">' + overviewPopupData[id]['rev'] +
+                                       '</span> (<span 
id="overviewpop-status">' + overviewPopupData[id]['status'] + '</span>)</div>' +
+                                       '<div>Number of notes: <span 
id="overviewpop-notes">' + overviewPopupData[id]['notes'] + '</span></div>' +
+                                       '<div>Path: <span 
id="overviewpop-path">' + overviewPopupData[id]['path'] + '</span></div>' +
+                                       '<div>Author: r<span 
id="overviewpop-author">' + overviewPopupData[id]['author'] + '</span></div>' +
+                                       //'<div>Live: <span 
id="overviewpop-live">' + overviewPopupData[id]['live'] + '</span></div>' +
+                                       '</div>')
+                               $el.attr( 'title', $popup.html() );
+                               $el.data( 'codeTooltip', true );
+                               $el.tipsy( 'show' );
+                       });
+       });
+})( jQuery ) ;


Property changes on: 
trunk/extensions/CodeReview/modules/ext.codereview.scapmap.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/CodeReview/ui/CodeView.php
===================================================================
--- trunk/extensions/CodeReview/ui/CodeView.php 2011-03-24 17:04:02 UTC (rev 
84686)
+++ trunk/extensions/CodeReview/ui/CodeView.php 2011-03-24 17:05:49 UTC (rev 
84687)
@@ -139,4 +139,10 @@
                $s .= "</tr>\n";
                return $s;
        }
+
+       function getStartBody() {
+               global $wgOut;
+               $wgOut->addModules( 'ext.codereview.scapmap' );
+               return parent::getStartBody();
+       }
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to