Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | 'vector-editwarning-preference' => 'Warn me when I leave an edit page with unsaved changes', |
23 | 23 | 'vector-simplesearch-search' => 'Search', |
24 | 24 | 'vector-simplesearch-containing' => 'containing...', |
| 25 | + 'vector-noexperiments-preference' => 'Exclude me from feature experiments', |
25 | 26 | ); |
26 | 27 | |
27 | 28 | /** Message documentation (Message documentation) |
Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.php |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | 'editwarning' => array( 'global' => false, 'user' => true ), |
24 | 24 | 'expandablesearch' => array( 'global' => false, 'user' => false ), |
25 | 25 | 'footercleanup' => array( 'global' => false, 'user' => false ), |
| 26 | + 'sectioneditlinks' => array( 'global' => false, 'user' => false ), |
26 | 27 | 'simplesearch' => array( 'global' => false, 'user' => true ), |
27 | 28 | ); |
28 | 29 | |
— | — | @@ -33,6 +34,12 @@ |
34 | 35 | // Force the new version |
35 | 36 | $wgCollapsibleNavForceNewVersion = false; |
36 | 37 | |
| 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 | + |
37 | 44 | /* Setup */ |
38 | 45 | |
39 | 46 | $wgExtensionCredits['other'][] = array( |
— | — | @@ -93,6 +100,13 @@ |
94 | 101 | 'scripts' => 'ext.vector.footerCleanup.js', |
95 | 102 | 'styles' => 'ext.vector.footerCleanup.css', |
96 | 103 | ), |
| 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 | + ), |
97 | 111 | 'ext.vector.simpleSearch' => $vectorResourceTemplate + array( |
98 | 112 | 'scripts' => 'ext.vector.simpleSearch.js', |
99 | 113 | '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 |
1 | 15 | + 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 |
2 | 16 | + 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 |
3 | 17 | + 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 |
1 | 66 | + text/plain |
Index: branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php |
— | — | @@ -52,10 +52,29 @@ |
53 | 53 | 'footercleanup' => array( |
54 | 54 | 'modules' => array( 'ext.vector.footerCleanup' ), |
55 | 55 | ), |
| 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 | + ), |
56 | 66 | 'simplesearch' => array( |
57 | 67 | 'requirements' => array( 'vector-simplesearch' => true, 'disablesuggest' => false ), |
58 | 68 | 'modules' => array( 'ext.vector.simpleSearch' ), |
59 | 69 | ), |
| 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 | + ), |
60 | 79 | ); |
61 | 80 | |
62 | 81 | /* Protected Static Methods */ |
Index: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -152,4 +152,48 @@ |
153 | 153 | $dbw->commit(); |
154 | 154 | return $db_status; |
155 | 155 | } |
| 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 | + } |
156 | 200 | } |
Index: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php |
— | — | @@ -50,6 +50,10 @@ |
51 | 51 | $wgHooks['MakeGlobalVariablesScript'][] = 'ClickTrackingHooks::makeGlobalVariablesScript'; |
52 | 52 | $wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables'; |
53 | 53 | |
| 54 | +$wgHooks['EditPage::showEditForm:fields'][] = 'ClickTrackingHooks::editPageShowEditFormFields'; |
| 55 | +$wgHooks['ArticleSave'][] = 'ClickTrackingHooks::articleSave'; |
| 56 | +$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::articleSaveComplete'; |
| 57 | + |
54 | 58 | // API modules |
55 | 59 | $wgAPIModules['clicktracking'] = 'ApiClickTracking'; |
56 | 60 | $wgAPIModules['specialclicktracking'] = 'ApiSpecialClickTracking'; |