r88565 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88564‎ | r88565 | r88566 >
Date:08:47, 22 May 2011
Author:krinkle
Status:reverted
Tags:
Comment:
Using the new mw.user.tokens (Introduced in r88553).
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)
  • /trunk/extensions/WikiLove/wikiLove.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -41,23 +41,20 @@
4242 }
4343
4444 /**
45 - * Adds the required module and edit token JS if we are on a user (talk) page.
 45+ * Adds the required module if we are on a user (talk) page.
4646 *
4747 * @param $output
4848 * @param $skin Skin
4949 */
5050 public static function beforePageDisplay( $out, $skin ) {
5151 global $wgWikiLoveGlobal, $wgUser;
52 - if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) return true;
 52+ if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) {
 53+ return true;
 54+ }
5355
5456 $title = self::getUserTalkPage( $skin->getTitle() );
5557 if ( !is_null( $title ) ) {
5658 $out->addModules( 'ext.wikiLove' );
57 - $out->addInlineScript(
58 - 'jQuery( document ).ready( function() {
59 - jQuery.wikiLove.editToken = ' . FormatJson::encode( $wgUser->edittoken() ) . ';
60 - } );'
61 - );
6259 }
6360 return true;
6461 }
Index: trunk/extensions/WikiLove/wikiLove.js
@@ -1,7 +1,6 @@
22 ( function( $ ) { $.wikiLove = {
33
44 $dialog: null, // dialog jQuery object
5 - editToken: '', // edit token used for the final AJAX call
65 currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown')
76 currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special')
87 currentTypeOrSubtype: null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.)
@@ -213,14 +212,14 @@
214213 */
215214 sendEmail: function( subject, text ) {
216215 $.ajax({
217 - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
 216+ url: mw.util.wikiScript( 'api' ),
218217 data: {
219218 'action': 'emailuser',
220219 'target': wgTitle,
221220 'subject': subject,
222221 'text': text,
223222 'format': 'json',
224 - 'token': $.wikiLove.editToken
 223+ 'token': mw.user.tokens.get( 'editToken' )
225224 },
226225 dataType: 'json',
227226 type: 'POST'
@@ -445,7 +444,7 @@
446445 'type': type,
447446 'text': wikitext,
448447 'subject': subject,
449 - 'token': $.wikiLove.editToken
 448+ 'token': mw.user.tokens.get( 'editToken' )
450449 },
451450 dataType: 'json',
452451 type: 'POST',

Follow-up revisions

RevisionCommit summaryAuthorDate
r90133Reverted r88565 for now for 1.17wmf1 compatibilityjanpaul12318:32, 15 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88553Adding user.tokens module and loading by default. (ResourceLoaderUserTokensMo...krinkle22:52, 21 May 2011

Status & tagging log