r83600 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83599‎ | r83600 | r83601 >
Date:18:55, 9 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: Merge Vector edit section links module plus required ClickTracking changes: r83056, r83057, r83226, r83546, r83547, r83548, r83560
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/Vector.php (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css (added) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js (added) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit-faded.png (added) (history)
  • /branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit.png (added) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php
@@ -21,6 +21,7 @@
2222 'vector-editwarning-preference' => 'Warn me when I leave an edit page with unsaved changes',
2323 'vector-simplesearch-search' => 'Search',
2424 'vector-simplesearch-containing' => 'containing...',
 25+ 'vector-noexperiments-preference' => 'Exclude me from feature experiments',
2526 );
2627
2728 /** Message documentation (Message documentation)
Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.php
@@ -22,6 +22,7 @@
2323 'editwarning' => array( 'global' => false, 'user' => true ),
2424 'expandablesearch' => array( 'global' => false, 'user' => false ),
2525 'footercleanup' => array( 'global' => false, 'user' => false ),
 26+ 'sectioneditlinks' => array( 'global' => false, 'user' => false ),
2627 'simplesearch' => array( 'global' => false, 'user' => true ),
2728 );
2829
@@ -33,6 +34,12 @@
3435 // Force the new version
3536 $wgCollapsibleNavForceNewVersion = false;
3637
 38+// Enable bucket testing for new version of section edit links
 39+$wgVectorSectionEditLinksBucketTest = false;
 40+// Percentage of users who's use of section edit links will be tracked - half of which will see the
 41+// new section edit links - default 5%
 42+$wgVectorSectionEditLinksLotteryOdds = 5;
 43+
3744 /* Setup */
3845
3946 $wgExtensionCredits['other'][] = array(
@@ -93,6 +100,13 @@
94101 'scripts' => 'ext.vector.footerCleanup.js',
95102 'styles' => 'ext.vector.footerCleanup.css',
96103 ),
 104+ 'ext.vector.sectionEditLinks' => $vectorResourceTemplate + array(
 105+ 'scripts' => 'ext.vector.sectionEditLinks.js',
 106+ 'styles' => 'ext.vector.sectionEditLinks.css',
 107+ 'dependencies' => array(
 108+ 'jquery.cookie',
 109+ ),
 110+ ),
97111 'ext.vector.simpleSearch' => $vectorResourceTemplate + array(
98112 'scripts' => 'ext.vector.simpleSearch.js',
99113 'messages' => array(
Index: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css
@@ -0,0 +1,13 @@
 2+span.vector-editLink {
 3+ float: none;
 4+ display: inline-block;
 5+}
 6+span.vector-editLink a {
 7+ padding-left: 18px;
 8+ background-image: url(images/edit-faded.png);
 9+ background-position: left top;
 10+ background-repeat: no-repeat;
 11+}
 12+span.vector-editLink a:hover {
 13+ background-image: url(images/edit.png);
 14+}
Property changes on: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css
___________________________________________________________________
Added: svn:mime-type
115 + text/plain
Index: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit.png
___________________________________________________________________
Added: svn:mime-type
216 + application/octet-stream
Index: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit-faded.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit-faded.png
___________________________________________________________________
Added: svn:mime-type
317 + application/octet-stream
Index: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js
@@ -0,0 +1,64 @@
 2+/*
 3+ * Section Edit Links for Vector
 4+ */
 5+( function( $, mw ) {
 6+
 7+if ( mw.config.get( 'wgVectorSectionEditLinksBucketTest', false ) ) {
 8+ var bucket = $.cookie( 'ext.vector.sectionEditLinks-bucket' );
 9+ if ( bucket === null ) {
 10+ // Percentage chance of being tracked
 11+ var odds = Math.min( 100, Math.max( 0,
 12+ Number( mw.config.get( 'wgVectorSectionEditLinksLotteryOdds', 0 ) )
 13+ ) );
 14+ // 0 = not tracked, 1 = tracked with old version, 2 = tracked with new version
 15+ bucket = ( Math.random() * 100 ) < odds ? Number( Math.random() < 0.5 ) + 1 : 0;
 16+ $.cookie( 'ext.vector.sectionEditLinks-bucket', bucket );
 17+ // If we are going to track this person from now on, let's also track which bucket we put
 18+ // them into and when
 19+ if ( bucket > 0 && 'trackActionWithInfo' in $ ) {
 20+ $.trackActionWithInfo( 'ext.vector.sectionEditLinks-bucket', bucket );
 21+ }
 22+ }
 23+}
 24+if ( bucket ) {
 25+ // Transform the targets of section edit links to route through the click tracking API
 26+ $( 'span.editsection a' ).each( function() {
 27+ var session = $.cookie( 'clicktracking-session' );
 28+ var editUrl = $( this ).attr( 'href' );
 29+ editUrl += ( editUrl.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( {
 30+ 'clicktrackingsession': session,
 31+ 'clicktrackingevent': 'ext.vector.sectionEditLinks-bucket' + bucket + '-save'
 32+ } );
 33+ $(this).attr( 'href', mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
 34+ 'action': 'clicktracking',
 35+ 'eventid': 'ext.vector.sectionEditLinks-bucket' + bucket + '-click',
 36+ 'token': session,
 37+ 'redirectto': editUrl
 38+ } ) );
 39+ } );
 40+ if ( bucket == 2 ) {
 41+ // Move the link over to be next to the heading text and style it with an icon
 42+ $( 'span.mw-headline' ).each( function() {
 43+ $(this)
 44+ .after(
 45+ $( '<span class="editsection vector-editLink"></span>' )
 46+ .append(
 47+ $(this)
 48+ .prev( 'span.editsection' )
 49+ .find( 'a' )
 50+ .each( function() {
 51+ var text = $(this).text();
 52+ $(this).text(
 53+ text.substr( 0, 1 ).toUpperCase() + text.substr( 1 )
 54+ );
 55+ } )
 56+ .detach()
 57+ )
 58+ )
 59+ .prev( 'span.editsection' )
 60+ .remove();
 61+ } );
 62+ }
 63+}
 64+
 65+} )( jQuery, mediaWiki );
Property changes on: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js
___________________________________________________________________
Added: svn:mime-type
166 + text/plain
Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php
@@ -52,10 +52,29 @@
5353 'footercleanup' => array(
5454 'modules' => array( 'ext.vector.footerCleanup' ),
5555 ),
 56+ 'sectioneditlinks' => array(
 57+ 'modules' => array( 'ext.vector.sectionEditLinks' ),
 58+ 'configurations' => array(
 59+ 'wgVectorSectionEditLinksBucketTest',
 60+ 'wgVectorSectionEditLinksLotteryOdds',
 61+ ),
 62+ 'requirements' => array(
 63+ 'vector-noexperiments' => false,
 64+ ),
 65+ ),
5666 'simplesearch' => array(
5767 'requirements' => array( 'vector-simplesearch' => true, 'disablesuggest' => false ),
5868 'modules' => array( 'ext.vector.simpleSearch' ),
5969 ),
 70+ 'experiments' => array(
 71+ 'preferences' => array(
 72+ 'vector-noexperiments' => array(
 73+ 'type' => 'toggle',
 74+ 'label-message' => 'vector-noexperiments-preference',
 75+ 'section' => 'rendering/advancedrendering',
 76+ ),
 77+ ),
 78+ ),
6079 );
6180
6281 /* Protected Static Methods */
Index: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php
@@ -152,4 +152,48 @@
153153 $dbw->commit();
154154 return $db_status;
155155 }
 156+
 157+ public static function editPageShowEditFormFields( $editPage, $output ) {
 158+ global $wgRequest;
 159+
 160+ // Add clicktracking fields to form, if given
 161+ $session = $wgRequest->getVal( 'clicktrackingsession' );
 162+ $event = $wgRequest->getVal( 'clicktrackingevent' );
 163+ if ( $session !== null && $event !== null ) {
 164+ $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingsession', $session );
 165+ $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingevent', $event );
 166+ }
 167+
 168+ return true;
 169+ }
 170+
 171+ public static function articleSave( $editpage ) {
 172+ self::trackRequest( 'save-attempt' );
 173+ return true;
 174+ }
 175+
 176+ public static function articleSaveComplete( $article, $user, $text, $summary, $minoredit,
 177+ $watchthis, $sectionanchor, $flags, $revision, $status, $baseRevId, $redirect ) {
 178+ self::trackRequest( 'save-complete' );
 179+ return true;
 180+ }
 181+
 182+ protected static function trackRequest( $info ) {
 183+ global $wgRequest;
 184+
 185+ $session = $wgRequest->getVal( 'clicktrackingsession' );
 186+ $event = $wgRequest->getVal( 'clicktrackingevent' );
 187+ if ( $session !== null && $event !== null ) {
 188+ $params = new FauxRequest( array(
 189+ 'action' => 'clicktracking',
 190+ 'eventid' => $event,
 191+ 'token' => $session,
 192+ 'additional' => $info,
 193+ ) );
 194+ $api = new ApiMain( $params, true );
 195+ $api->execute();
 196+ }
 197+
 198+ return true;
 199+ }
156200 }
Index: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php
@@ -50,6 +50,10 @@
5151 $wgHooks['MakeGlobalVariablesScript'][] = 'ClickTrackingHooks::makeGlobalVariablesScript';
5252 $wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables';
5353
 54+$wgHooks['EditPage::showEditForm:fields'][] = 'ClickTrackingHooks::editPageShowEditFormFields';
 55+$wgHooks['ArticleSave'][] = 'ClickTrackingHooks::articleSave';
 56+$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::articleSaveComplete';
 57+
5458 // API modules
5559 $wgAPIModules['clicktracking'] = 'ApiClickTracking';
5660 $wgAPIModules['specialclicktracking'] = 'ApiSpecialClickTracking';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83056Added ext.vector.sectionEditLink module which moves the section edit links to...tparscal23:41, 1 March 2011
r83057Added images for ext.vector.sectionEditLinks module - follow up to r83056tparscal23:52, 1 March 2011
r83226Track people being added to a bucket, if the bucket will be tracked.tparscal18:11, 4 March 2011
r83546Added session and info parameters to the edit page links, so that edit save t...tparscal21:21, 8 March 2011
r83547Pass event though event, not infotparscal21:59, 8 March 2011
r83548Added edit tracking...tparscal22:01, 8 March 2011
r83560* Added experimental features preference...tparscal00:43, 9 March 2011

Status & tagging log