r81077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81076‎ | r81077 | r81078 >
Date:01:04, 27 January 2011
Author:tparscal
Status:deferred
Tags:
Comment:
* Added database patch that fixed issue where logged in users' ratings were not being associated with them after the first time they rated.
* Ported the basic survey launching code over from previous version of the extension (see r76893)
Modified paths:
  • /trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js (modified) (history)
  • /trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js (modified) (history)
  • /trunk/extensions/ArticleFeedback/sql/AddPropertiesTable.sql (added) (history)
  • /trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql (modified) (history)
  • /trunk/extensions/ArticleFeedback/sql/FixAnonTokenSchema.sql (added) (history)
  • /trunk/extensions/ArticleFeedback/sql/article_feedback_properties.sql (deleted) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/sql/article_feedback_properties.sql
@@ -1,12 +0,0 @@
2 -CREATE TABLE /*_*/article_feedback_properties (
3 - -- Keys to the primary key fields in article_feedback, except aa_rating_id
4 - -- article_feedback doesn't have a nice PK, blegh
5 - afp_revision integer unsigned NOT NULL,
6 - afp_user_text varbinary(255) NOT NULL,
7 - afp_user_anon_token binary(32) DEFAULT '',
8 -
9 - -- Key/value pairs
10 - afp_key varbinary(255) NOT NULL,
11 - afp_value integer signed NOT NULL
12 -) /*$wgDBTableOptions*/;
13 -CREATE UNIQUE INDEX /*i*/afp_rating_key ON /*_*/article_feedback_properties (afp_revision, afp_user_text, afp_user_anon_token, afp_key);
Index: trunk/extensions/ArticleFeedback/sql/FixAnonTokenSchema.sql
@@ -0,0 +1 @@
 2+ALTER TABLE /*_*/article_feedback MODIFY aa_user_anon_token varbinary(32) NOT NULL DEFAULT '';
Property changes on: trunk/extensions/ArticleFeedback/sql/FixAnonTokenSchema.sql
___________________________________________________________________
Added: svn:eol-style
13 + native
Index: trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql
@@ -20,7 +20,7 @@
2121 -- Username or IP address
2222 aa_user_text varbinary(255) NOT NULL,
2323 -- Unique token for anonymous users (to facilitate ratings from multiple users on the same IP)
24 - aa_user_anon_token binary(32) DEFAULT '',
 24+ aa_user_anon_token varbinary(32) NOT NULL DEFAULT '',
2525 -- Foreign key to revision.rev_id
2626 aa_revision integer unsigned NOT NULL,
2727 -- MW Timestamp
Index: trunk/extensions/ArticleFeedback/sql/AddPropertiesTable.sql
@@ -0,0 +1,12 @@
 2+CREATE TABLE /*_*/article_feedback_properties (
 3+ -- Keys to the primary key fields in article_feedback, except aa_rating_id
 4+ -- article_feedback doesn't have a nice PK, blegh
 5+ afp_revision integer unsigned NOT NULL,
 6+ afp_user_text varbinary(255) NOT NULL,
 7+ afp_user_anon_token binary(32) DEFAULT '',
 8+
 9+ -- Key/value pairs
 10+ afp_key varbinary(255) NOT NULL,
 11+ afp_value integer signed NOT NULL
 12+) /*$wgDBTableOptions*/;
 13+CREATE UNIQUE INDEX /*i*/afp_rating_key ON /*_*/article_feedback_properties (afp_revision, afp_user_text, afp_user_anon_token, afp_key);
Property changes on: trunk/extensions/ArticleFeedback/sql/AddPropertiesTable.sql
___________________________________________________________________
Added: svn:eol-style
114 + native
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php
@@ -31,9 +31,13 @@
3232 'articlefeedback-pitch-makefirstedit-title',
3333 'articlefeedback-pitch-makefirstedit-message',
3434 'articlefeedback-pitch-makefirstedit-accept',
 35+ 'articlefeedback-survey-title',
3536 ),
3637 'dependencies' => array(
 38+ 'jquery.ui.dialog',
 39+ 'jquery.ui.button',
3740 'jquery.articleFeedback',
 41+ 'jquery.cookie',
3842 ),
3943 ),
4044 'jquery.articleFeedback' => array(
@@ -55,6 +59,7 @@
5660 'jquery.localize',
5761 'jquery.ui.dialog',
5862 'jquery.ui.button',
 63+ 'jquery.cookie',
5964 ),
6065 ),
6166 );
@@ -74,23 +79,45 @@
7580 } else {
7681 $dir = dirname( __FILE__ );
7782 $db = $updater->getDB();
78 -
7983 if ( !$db->tableExists( 'article_feedback' ) ) {
 84+ // Rename tables
8085 if ( $db->tableExists( 'article_assessment' ) ) {
81 - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback',
82 - $dir . '/sql/RenameTables.sql', true ) ); // Rename tables
 86+ $updater->addExtensionUpdate( array(
 87+ 'addTable',
 88+ 'article_feedback',
 89+ $dir . '/sql/RenameTables.sql',
 90+ true
 91+ ) );
8392 } else {
84 - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback',
85 - $dir . '/sql/ArticleFeedback.sql', true ) ); // Initial install tables
 93+ // Initial install tables
 94+ $updater->addExtensionUpdate( array(
 95+ 'addTable',
 96+ 'article_feedback',
 97+ $dir . '/sql/ArticleFeedback.sql',
 98+ true
 99+ ) );
86100 }
87101 }
88 -
89102 if ( !$db->fieldExists( 'article_feedback', 'aa_design_bucket', __METHOD__ ) ) {
90 - $updater->addExtensionUpdate( array( 'addField', 'article_feedback', 'aa_design_bucket',
91 - $dir . '/sql/AddRatingBucket.sql', true ) );
 103+ $updater->addExtensionUpdate( array(
 104+ 'addField',
 105+ 'article_feedback',
 106+ 'aa_design_bucket',
 107+ $dir . '/sql/AddRatingBucket.sql',
 108+ true
 109+ ) );
92110 }
93 - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback_properties',
94 - "$dir/sql/article_feedback_properties.sql", true ) );
 111+ $updater->addExtensionUpdate( array(
 112+ 'addTable',
 113+ 'article_feedback_properties',
 114+ $dir . 'sql/AddPropertiesTable.sql',
 115+ true
 116+ ) );
 117+ $updater->addExtensionUpdate( array(
 118+ 'applyPatch',
 119+ $dir . '/sql/FixAnonTokenSchema.sql',
 120+ true
 121+ ) );
95122 }
96123 return true;
97124 }
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
@@ -208,27 +208,31 @@
209209 .each( function() {
210210 for ( var key in context.options.pitches ) {
211211 $( $.articleFeedback.tpl.pitch )
212 - .attr( 'rel', key )
213 - .find( '.articleFeedback-title' )
214 - .text( mw.msg( context.options.pitches[key].title ) )
215 - .end()
216 - .find( '.articleFeedback-message' )
217 - .text( mw.msg( context.options.pitches[key].message ) )
218 - .end()
219 - .find( '.articleFeedback-accept' )
220 - .text( mw.msg( context.options.pitches[key].accept ) )
221 - .click( function() {
222 - context.options.pitches[key].action();
223 - $(this).closest( '.articleFeedback-pitch' ).fadeOut();
224 - } )
225 - .button()
226 - .end()
227 - .find( '.articleFeedback-reject' )
228 - .text( mw.msg( context.options.pitches[key].reject ) )
229 - .click( function() {
230 - $(this).closest( '.articleFeedback-pitch' ).fadeOut();
231 - } )
232 - .end()
 212+ .attr( 'rel', key )
 213+ .find( '.articleFeedback-title' )
 214+ .text( mw.msg( context.options.pitches[key].title ) )
 215+ .end()
 216+ .find( '.articleFeedback-message' )
 217+ .text( mw.msg( context.options.pitches[key].message ) )
 218+ .end()
 219+ .find( '.articleFeedback-accept' )
 220+ .text( mw.msg( context.options.pitches[key].accept ) )
 221+ .click( function() {
 222+ var $pitch = $(this).closest( '.articleFeedback-pitch' );
 223+ var key = $pitch.attr( 'rel' );
 224+ context.options.pitches[key].action();
 225+ $pitch.fadeOut();
 226+ } )
 227+ .button()
 228+ .end()
 229+ .find( '.articleFeedback-reject' )
 230+ .text( mw.msg( context.options.pitches[key].reject ) )
 231+ .click( function() {
 232+ // Remember that the users rejected this, set a cookie to not
 233+ // show this for 3 days
 234+ $(this).closest( '.articleFeedback-pitch' ).fadeOut();
 235+ } )
 236+ .end()
233237 .appendTo( $(this) );
234238 }
235239 } )
@@ -249,6 +253,8 @@
250254 .click( function() {
251255 $.articleFeedback.fn.submit.call( context );
252256 for ( var key in context.options.pitches ) {
 257+ // Dont' bother checking the condition if there's a cookie that says
 258+ // the user has rejected this within 3 days of right now
253259 if ( context.options.pitches[key].condition() ) {
254260 context.$ui
255261 .find( '.articleFeedback-pitch[rel="' + key + '"]' )
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
@@ -34,7 +34,35 @@
3535 return true;
3636 },
3737 'action': function() {
38 - // TODO: Do something
 38+ var $dialog = $( '#articleFeedback-dialog' );
 39+ if ( $dialog.size() == 0 ) {
 40+ $dialog = $( '<div id="articleFeedback-dialog" class="loading" />' )
 41+ .dialog( {
 42+ 'width': 600,
 43+ 'height': 400,
 44+ 'bgiframe': true,
 45+ 'autoOpen': true,
 46+ 'modal': true,
 47+ 'title': mediaWiki.msg( 'articlefeedback-survey-title' ),
 48+ 'close': function() {
 49+ $( this )
 50+ .dialog( 'option', 'height', 400 )
 51+ .find( '.articleFeedback-success-msg, .articleFeedback-error-msg' )
 52+ .remove()
 53+ .end()
 54+ .find( 'form' )
 55+ .show();
 56+ }
 57+ } );
 58+ $dialog.load(
 59+ wgScript + '?title=Special:SimpleSurvey&survey=articlerating&raw=1',
 60+ function() {
 61+ //$( this ).find( 'form' ).bind( 'submit', $.ArticleAssessment.fn.submitFeedback );
 62+ $( this ).removeClass( 'loading' );
 63+ }
 64+ );
 65+ }
 66+ $dialog.dialog( 'open' );
3967 },
4068 'title': 'articlefeedback-pitch-takesurvey-title',
4169 'message': 'articlefeedback-pitch-takesurvey-message',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76893Tagging REL1_0_0 of ArticleAssessmentPilotreedy18:30, 17 November 2010

Status & tagging log