r88358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88357‎ | r88358 | r88359 >
Date:22:25, 17 May 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
refactored to depend less on templates, you can now build most items with just an image and text
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.api.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.php (modified) (history)
  • /trunk/extensions/WikiLove/defaultTypes.js (added) (history)
  • /trunk/extensions/WikiLove/patches/WikiLoveLog.sql (modified) (history)
  • /trunk/extensions/WikiLove/wikiLove.css (modified) (history)
  • /trunk/extensions/WikiLove/wikiLove.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.php
@@ -80,7 +80,10 @@
8181
8282 $wgResourceModules += array(
8383 'ext.wikiLove' => $wikiLoveTpl + array(
84 - 'scripts' => 'wikiLove.js',
 84+ 'scripts' => array(
 85+ 'wikiLove.js',
 86+ 'defaultTypes.js',
 87+ ),
8588 'styles' => 'wikiLove.css',
8689 'messages' => array(
8790 'wikilove-dialog-title',
@@ -90,7 +93,8 @@
9194 'wikilove-get-started-list-2',
9295 'wikilove-get-started-list-3',
9396 'wikilove-add-details',
94 - 'wikilove-gallery',
 97+ 'wikilove-image',
 98+ 'wikilove-header',
9599 'wikilove-title',
96100 'wikilove-enter-message',
97101 'wikilove-omit-sig',
@@ -98,10 +102,12 @@
99103 'wikilove-preview',
100104 'wikilove-button-send',
101105 'wikilove-type-makeyourown',
 106+ 'wikilove-err-header',
102107 'wikilove-err-title',
103108 'wikilove-err-msg',
104109 'wikilove-err-image',
105110 'wikilove-err-sig',
 111+ 'wikilove-barnstar-header',
106112 ),
107113 'dependencies' => array(
108114 'jquery.ui.dialog',
Index: trunk/extensions/WikiLove/wikiLove.css
@@ -244,7 +244,7 @@
245245 width: 300px;
246246 }
247247
248 -#wikiLoveDialog #wlAddDetails .wlOmitSig {
 248+#wikiLoveDialog #wlAddDetails .wlNote {
249249 font-weight: light;
250250 font-size: 0.9em;
251251 float: right;
@@ -255,13 +255,9 @@
256256 resize: none;
257257 }
258258
259 -#wikiLoveDialog #wlAddDetails #wlNotify {
260 - float: left;
261 -}
262 -
263259 #wikiLoveDialog .wlSpinner {
264260 float: right;
265 - margin-top: 6px;
 261+ margin-top: 0.9em;
266262 display: none;
267263 }
268264
@@ -292,6 +288,9 @@
293289 #wikiLoveDialog #wlGallerySpinner .wlSpinner {
294290 float: none;
295291 position: absolute;
 292+ top: 0;
 293+ left: 50%;
 294+ margin-left: -8px;
296295 z-index: -1;
297296 }
298297
@@ -320,6 +319,12 @@
321320 display: block;
322321 }
323322
 323+#wikiLoveDialog #wlSubtypeDescription {
 324+ margin: 5px 0px 8px 15px;
 325+ font-size: 1.0em;
 326+ line-height: 1.2em;
 327+}
 328+
324329 #wikiLoveDialog input[type=checkbox] {
325330 display:inline-box;
326331 margin: 5px 0px 5px 0px;
Index: trunk/extensions/WikiLove/defaultTypes.js
@@ -0,0 +1,57 @@
 2+$.wikiLove.types = {
 3+ // example type, could be removed later (also no i18n)
 4+ 'barnstar': {
 5+ name: 'Barnstar', // name of the type (appears in the types menu)
 6+ fields: [ 'header', 'title', 'image' ], // fields to ask for in form if not specified in config
 7+ select: 'Select a barnstar:', // subtype select label
 8+ subtypes: { // some different subtypes
 9+ // note that when not using subtypes you should use these subtype options
 10+ // for the top-level type
 11+ 'original': {
 12+ option: 'Original barnstar', // option listed in the select list
 13+ descr: 'This barnstar is given to recognize particularly fine contributions to Wikipedia, to let people know that their hard work is seen and appreciated.', // description
 14+ header: mw.msg( 'wikilove-barnstar-header' ), // header that appears at the top of the talk page post (optional)
 15+ title: 'The Original Barnstar', // title that appears inside the award box (optional)
 16+ image: 'Original Barnstar Hires.png', // image for the award
 17+ mail: 'Hello $7!\n\nI just awarded you a barnstar.' // message to use in email notification; $7 is replaced by the recipient's username
 18+ },
 19+ 'editors': {
 20+ option: 'Editor\'s barnstar',
 21+ descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.',
 22+ header: mw.msg( 'wikilove-barnstar-header' ),
 23+ title: 'The Editor\'s Barnstar',
 24+ image: 'Editors Barnstar Hires.png',
 25+ mail: 'Hello $7!\n\nI just awarded you a barnstar.'
 26+ },
 27+ 'tireless': {
 28+ option: 'Tireless contributor barnstar',
 29+ descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.',
 30+ header: mw.msg( 'wikilove-barnstar-header' ),
 31+ title: 'The Editor\'s Barnstar',
 32+ image: 'Tireless Contributor Barnstar Hires.gif',
 33+ mail: 'Hello $7!\n\nI just awarded you a barnstar.'
 34+ }
 35+ },
 36+ showNotify: true, // add email notices as an option for each award of this type
 37+ icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu
 38+ },
 39+ 'cats': {
 40+ name: 'Cat',
 41+ fields: [ 'header' ],
 42+ header: 'A kitten for you!',
 43+ text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename
 44+ gallery: {
 45+ // right now we can only query the local wiki (not e.g. commons)
 46+ category: 'Category:Cats',
 47+ total: 100, // total number of pictures to retrieve, and to randomise
 48+ num: 3, // number of pictures to show from the randomised set
 49+ width: 145 // width of each picture in pixels in the interface (not in the template)
 50+ }
 51+ },
 52+ // default type, nice to leave this one in place when adding other types
 53+ 'makeyourown': {
 54+ name: mw.msg( 'wikilove-type-makeyourown' ),
 55+ fields: [ 'header', 'title', 'image' ],
 56+ imageSize: '150px'
 57+ }
 58+}
\ No newline at end of file
Index: trunk/extensions/WikiLove/wikiLove.js
@@ -1,51 +1,5 @@
22 ( function( $ ) { $.wikiLove = {
3 - types: {
4 - // example type, could be removed later (also no i18n)
5 - 'barnstar': {
6 - descr: 'Barnstar', // description in the types menu
7 - select: 'Select a barnstar:', // subtype select label
8 - subtypes: { // some different subtypes
9 - // note that when not using subtypes you should use these subtype options
10 - // for the top-level type
11 - 'original': {
12 - title: 'An Original Barnstar for you!', // subject title for the message
13 - descr: 'Original barnstar', // description in the menu
14 - text: '{{subst:The Original Barnstar|$1 ~~~~}}', // message text, $1 is replaced by the user message
15 - template: 'The Original Barnstar', // template that is used, for statistics
16 - mail: 'Hello $2!\n\nI just awarded you a barnstar.' // message to use in email notification; $2 is replaced by the recipient's username
17 - },
18 - 'special': {
19 - title: null, // no predefined title, allows the user to enter a title
20 - descr: 'Special barnstar',
21 - text: '{{subst:The Special Barnstarl|$1 ~~~~}}',
22 - template: 'The Special Barnstar',
23 - mail: 'Hello $2!\n\nI just awarded you the special barnstar.'
24 - }
25 - },
26 - showNotify: true, // add email notices as an option for each award of this type
27 - icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png'
28 - },
29 - 'cat': {
30 - descr: 'Cat',
31 - title: null,
32 - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename
33 - template: '',
34 - gallery: {
35 - // right now we can only query the local wiki (not e.g. commons)
36 - category: 'Category:Cats',
37 - total: 100, // total number of pictures to retrieve, and to randomise
38 - num: 3, // number of pictures to show from the randomised set
39 - width: 145 // width of each picture in pixels in the interface (not in the template)
40 - }
41 - },
42 - // default type, nice to leave this one in place when adding other types
43 - 'makeyourown': {
44 - title: null,
45 - descr: mw.msg( 'wikilove-type-makeyourown' ),
46 - text: "$1",
47 - template: ''
48 - }
49 - },
 3+
504 $dialog: null, // dialog jQuery object
515 editToken: '', // edit token used for the final AJAX call
526 currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown')
@@ -54,7 +8,15 @@
559 previewData: null, // data of the currently previewed thing is set here
5610 emailable: false,
5711 gallery: {},
58 - imageTitle: '',
 12+ defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
 13+|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\
 14+|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\
 15+|-\n\
 16+|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\
 17+|}',
 18+ defaultBackgroundColor: '#fdffe7',
 19+ defaultBorderColor: '#fceb92',
 20+ defaultImageSize: '100px',
5921
6022 /*
6123 * Opens the dialog and builds it if necessary.
@@ -62,8 +24,8 @@
6325 openDialog: function() {
6426 if ( $.wikiLove.$dialog === null ) {
6527 // Load local configuration
66 - var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } );
67 - mw.loader.load( wikiLoveConfigUrl );
 28+ //var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } );
 29+ //mw.loader.load( wikiLoveConfigUrl );
6830
6931 // Find out if we can email the user
7032 $.wikiLove.getEmailable();
@@ -86,7 +48,7 @@
8749 $buttonInside.addClass( 'wlNoIcon' );
8850 }
8951
90 - $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].descr + '</div>' );
 52+ $buttonInside.append( '<div class="wlLinkText">' + $.wikiLove.types[typeId].name + '</div>' );
9153
9254 $button.append( '<div class="wlLeftCap"></div>');
9355 $button.append( $buttonInside );
@@ -113,16 +75,21 @@
11476 var $addDetails = $( '<div id="wlAddDetails"></div>' )
11577 .append( '<span class="wlNumber">2</span>' )
11678 .append( '<h3>' + mw.msg( 'wikilove-add-details' ) + '</h3>' )
117 - .append( '<label for="wlSubtype" id="wlSubtypeLabel"></label>' )
11879 .append( $( '<form id="wlPreviewForm"></form>' )
 80+ .append( '<label for="wlSubtype" id="wlSubtypeLabel"></label>' )
11981 .append( '<select id="wlSubtype"></select>' )
120 - .append( '<label id="wlGalleryLabel">' + mw.msg( 'wikilove-gallery' ) + '</label>' )
 82+ .append( '<div id="wlSubtypeDescription"/>' )
 83+ .append( '<label id="wlGalleryLabel">' + mw.msg( 'wikilove-image' ) + '</label>' )
12184 .append( '<div id="wlGallerySpinner">' + spinner + '</div>' )
12285 .append( '<div id="wlGallery"/>' )
123 - .append( '<label for="wlTitle" id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' )
 86+ .append( '<label for="wlHeader" id="wlHeaderLabel">' + mw.msg( 'wikilove-header' ) + '</label>' )
 87+ .append( '<input type="text" class="text" id="wlHeader"/>' )
 88+ .append( '<label for="wlTitle" id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' )
12489 .append( '<input type="text" class="text" id="wlTitle"/>' )
125 - .append( '<label for="wlMessage" id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' )
126 - .append( '<span class="wlOmitSig">' + mw.msg( 'wikilove-omit-sig' ) + '</span>' )
 90+ .append( '<label for="wlImage" id="wlImageLabel">' + mw.msg( 'wikilove-image' ) + '</label>' )
 91+ .append( '<input type="text" class="text" id="wlImage"/>' )
 92+ .append( '<label for="wlMessage" id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' )
 93+ .append( '<span class="wlNote">' + mw.msg( 'wikilove-omit-sig' ) + '</span>' )
12794 .append( '<textarea id="wlMessage"></textarea>' )
12895 .append( $('<div id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox" name="notify"/> <label for="wlNotifyCheckbox">Notify user by email</label>') )
12996 .append( $('<button class="submit" id="wlButtonPreview" type="submit"></button>').button({ label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } }) )
@@ -149,6 +116,7 @@
150117 .append( $preview )
151118 .dialog({
152119 width: 800,
 120+ position: ['center', 80],
153121 autoOpen: false,
154122 title: mw.msg( 'wikilove-dialog-title' ),
155123 modal: true,
@@ -190,7 +158,7 @@
191159 // add all the subtypes to the menu while setting their subtype ids in jQuery data
192160 var subtype = $.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId];
193161 $( '#wlSubtype' ).append(
194 - $( '<option>' + subtype.descr + '</option>' ).data( 'subtypeId', subtypeId )
 162+ $( '<option>' + subtype.option + '</option>' ).data( 'subtypeId', subtypeId )
195163 );
196164 }
197165 $( '#wlSubtype' ).show();
@@ -225,6 +193,7 @@
226194 $.wikiLove.currentSubtypeId = newSubtypeId;
227195 $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId]
228196 .subtypes[$.wikiLove.currentSubtypeId];
 197+ $( '#wlSubtypeDescription' ).html( $.wikiLove.currentTypeOrSubtype.descr );
229198 $.wikiLove.updateAllDetails();
230199 $( '#wlPreview' ).hide();
231200 $.wikiLove.previewData = null;
@@ -259,30 +228,64 @@
260229 },
261230
262231 /*
263 - * Called when type or subtype changes, updates controls. Currently only updates title label and textbox.
 232+ * Called when type or subtype changes, updates controls.
264233 */
265234 updateAllDetails: function() {
266235 $( '#wikiLoveDialog' ).find( '.wlError' ).remove();
267236
 237+ // only show the description if it exists for this type or subtype
 238+ if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) {
 239+ $( '#wlSubtypeDescription').show();
 240+ } else {
 241+ $( '#wlSubtypeDescription').hide();
 242+ }
 243+
 244+ // show or hide header label and textbox depending on whether a predefined header exists
 245+ var needsHeader = $.inArray( 'header', $.wikiLove.types[$.wikiLove.currentTypeId].fields );
 246+ if( typeof $.wikiLove.currentTypeOrSubtype.header == 'string' || needsHeader == -1 ) {
 247+ $( '#wlHeaderLabel').hide();
 248+ $( '#wlHeader' ).hide();
 249+ $( '#wlHeader' ).val( $.wikiLove.currentTypeOrSubtype.header );
 250+ } else if ( needsHeader != -1 ) {
 251+ $( '#wlHeaderLabel').show();
 252+ $( '#wlHeader' ).show();
 253+ $( '#wlHeader' ).val( '' );
 254+ }
 255+
268256 // show or hide title label and textbox depending on whether a predefined title exists
269 - if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' ) {
 257+ var needsTitle = $.inArray( 'title', $.wikiLove.types[$.wikiLove.currentTypeId].fields );
 258+ if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' || needsTitle == -1 ) {
270259 $( '#wlTitleLabel').hide();
271260 $( '#wlTitle' ).hide();
272261 $( '#wlTitle' ).val( $.wikiLove.currentTypeOrSubtype.title );
273 - } else {
 262+ } else if ( needsTitle != -1 ) {
274263 $( '#wlTitleLabel').show();
275264 $( '#wlTitle' ).show();
276265 $( '#wlTitle' ).val( '' );
277266 }
278267
 268+ // show or hide image label and textbox depending on whether a predefined image exists
 269+ var needsTitle = $.inArray( 'image', $.wikiLove.types[$.wikiLove.currentTypeId].fields );
 270+ if( typeof $.wikiLove.currentTypeOrSubtype.image == 'string' || needsTitle == -1 ) {
 271+ $( '#wlImageLabel').hide();
 272+ $( '#wlImage' ).hide();
 273+ $( '#wlImage' ).val( $.wikiLove.currentTypeOrSubtype.image );
 274+ } else if ( needsTitle != -1 ) {
 275+ $( '#wlImageLabel').show();
 276+ $( '#wlImage' ).show();
 277+ $( '#wlImage' ).val( '' );
 278+ }
 279+
279280 if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
280281 $( '#wlGalleryLabel' ).show();
281282 $( '#wlGallery' ).show();
 283+ $( '#wlGallerySpinner' ).show();
282284 $.wikiLove.makeGallery();
283285 }
284286 else {
285287 $( '#wlGalleryLabel' ).hide();
286288 $( '#wlGallery' ).hide();
 289+ $( '#wlGallerySpinner' ).hide();
287290 }
288291
289292 if( $.wikiLove.types[$.wikiLove.currentTypeId].showNotify ) {
@@ -302,12 +305,12 @@
303306 $( '#wikiLoveDialog' ).find( '.wlError' ).remove();
304307
305308 if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
306 - if ( !$.wikiLove.imageTitle ) {
 309+ if ( $( '#wlImage' ).val().length <= 0 ) {
307310 $.wikiLove.showError( 'wikilove-err-image' ); return false;
308311 }
309312 }
310 - if( $( '#wlTitle' ).val().length <= 0 ) {
311 - $.wikiLove.showError( 'wikilove-err-title' ); return false;
 313+ if( $( '#wlHeader' ).val().length <= 0 ) {
 314+ $.wikiLove.showError( 'wikilove-err-header' ); return false;
312315 }
313316 if( $( '#wlMessage' ).val().length <= 0 ) {
314317 $.wikiLove.showError( 'wikilove-err-msg' ); return false;
@@ -318,15 +321,24 @@
319322 $.wikiLove.showError( 'wikilove-err-sig' ); return false;
320323 }
321324
322 - var msg = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.text );
 325+ if ( $.wikiLove.currentTypeOrSubtype.text ) {
 326+ var text = $.wikiLove.currentTypeOrSubtype.text;
 327+ } else {
 328+ var text = $.wikiLove.defaultText;
 329+ }
 330+ var msg = $.wikiLove.prepareMsg(
 331+ text,
 332+ $.wikiLove.currentTypeOrSubtype.imageSize,
 333+ $.wikiLove.currentTypeOrSubtype.backgroundColor,
 334+ $.wikiLove.currentTypeOrSubtype.borderColor
 335+ );
323336
324 - $.wikiLove.doPreview( '==' + $( '#wlTitle' ).val() + "==\n" + msg );
 337+ $.wikiLove.doPreview( '==' + $( '#wlHeader' ).val() + "==\n" + msg );
325338 $.wikiLove.previewData = {
326 - 'title': $( '#wlTitle' ).val(),
 339+ 'header': $( '#wlHeader' ).val(),
327340 'msg': msg,
328341 'type': $.wikiLove.currentTypeId
329342 + ($.wikiLove.currentSubtypeId != null ? '-' + $.wikiLove.currentSubtypeId : ''),
330 - 'template': $.wikiLove.currentTypeOrSubtype.template,
331343 'notify': $( '#wlNotifyCheckbox:checked' ).val()
332344 };
333345 return false;
@@ -339,21 +351,40 @@
340352 /*
341353 * Prepares a message or e-mail body by replacing placeholders.
342354 * $1: message entered by the user
343 - * $2: username of the recipient
344 - * $3: title of the chosen image
 355+ * $2: title of the item
 356+ * $3: title of the image
 357+ * $4: image size
 358+ * $5: background color
 359+ * $6: border color
 360+ * $7: username of the recipient
345361 */
346 - prepareMsg: function( msg ) {
347 - // replace the raw message
348 - msg = msg.replace( '$1', $( '#wlMessage' ).val() );
 362+ prepareMsg: function( msg, imageSize, backgroundColor, borderColor ) {
349363
350 - // replace the username we're sending to
351 - msg = msg.replace( '$2', wgTitle );
 364+ msg = msg.replace( '$1', $( '#wlMessage' ).val() ); // replace the raw message
 365+ msg = msg.replace( '$2', $( '#wlTitle' ).val() ); // replace the title
 366+ msg = msg.replace( '$3', $( '#wlImage' ).val() ); // replace the image
352367
353 - // replace the image filename
354 - if ( $.wikiLove.imageTitle ) {
355 - msg = msg.replace( '$3', $.wikiLove.imageTitle );
 368+ if ( imageSize ) {
 369+ var myImageSize = imageSize;
 370+ } else {
 371+ var myImageSize = $.wikiLove.defaultImageSize;
356372 }
 373+ if ( backgroundColor ) {
 374+ var myBackgroundColor = backgroundColor;
 375+ } else {
 376+ var myBackgroundColor = $.wikiLove.defaultBackgroundColor;
 377+ }
 378+ if ( borderColor ) {
 379+ var myBorderColor = borderColor;
 380+ } else {
 381+ var myBorderColor = $.wikiLove.defaultBorderColor;
 382+ }
 383+ msg = msg.replace( '$4', myImageSize ); // replace the image size
 384+ msg = msg.replace( '$5', myBackgroundColor ); // replace the background color
 385+ msg = msg.replace( '$6', myBorderColor ); // replace the border color
357386
 387+ msg = msg.replace( '$7', wgTitle ); // replace the username we're sending to
 388+
358389 return msg;
359390 },
360391
@@ -395,15 +426,15 @@
396427 */
397428 submitSend: function( e ) {
398429 e.preventDefault();
399 - $.wikiLove.doSend( $.wikiLove.previewData.title, $.wikiLove.previewData.msg,
400 - $.wikiLove.previewData.type, $.wikiLove.previewData.template, $.wikiLove.previewData.notify );
 430+ $.wikiLove.doSend( $.wikiLove.previewData.header, $.wikiLove.previewData.msg,
 431+ $.wikiLove.previewData.type, $.wikiLove.previewData.notify );
401432 return false;
402433 },
403434
404435 /*
405436 * Fires the final AJAX request and then redirects to the talk page where the content is added.
406437 */
407 - doSend: function( subject, wikitext, type, template, notify ) {
 438+ doSend: function( subject, wikitext, type, notify ) {
408439 $( '#wlPreview .wlSpinner' ).fadeIn( 200 );
409440 $.ajax({
410441 url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
@@ -411,7 +442,6 @@
412443 'action': 'wikiLove',
413444 'format': 'json',
414445 'title': mw.config.get( 'wgPageName' ),
415 - 'template': template,
416446 'type': type,
417447 'text': wikitext,
418448 'subject': subject,
@@ -505,9 +535,8 @@
506536 .attr( 'src', page.imageinfo[0].url )
507537 .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
508538 .hide()
509 - .load( function() { $( this ).fadeIn( 400 ); } );
 539+ .load( function() { $( this ).css( 'display', 'inline-block' ); } );
510540
511 -
512541 // append the image to the gallery and also make sure it's selectable
513542 $( '#wlGallery' ).append(
514543 $( '<a href="#"></a>' )
@@ -517,7 +546,7 @@
518547 e.preventDefault();
519548 $( '#wlGallery a' ).removeClass( 'selected' );
520549 $( this ).addClass( 'selected' );
521 - $.wikiLove.imageTitle = $.wikiLove.gallery[$( this ).attr( 'id' )];
 550+ $( '#wlImage' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
522551 return false;
523552 })
524553 );
Index: trunk/extensions/WikiLove/WikiLove.api.php
@@ -15,10 +15,6 @@
1616 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
1717 }
1818
19 - if ( strlen( $params['template'] ) > 0 && stripos( $params['text'], $params['template'] ) === false ) {
20 - $this->dieUsage( 'Template could not be found in the message!', 'invalidtemplate' );
21 - }
22 -
2319 if ( $wgWikiLoveLogging ) {
2420 $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] );
2521 }
@@ -48,7 +44,6 @@
4945 * @param $subject
5046 * @param $text
5147 * @param $type
52 - * @param $template
5348 * @return void
5449 */
5550 private function saveInDb( $talk, $subject, $text, $type, $template ) {
@@ -59,7 +54,6 @@
6055 'wl_sender_id' => $wgUser->getId(),
6156 'wl_receiver_id' => User::newFromName( $talk->getSubjectPage()->getBaseText() )->getId(),
6257 'wl_type' => $type,
63 - 'wl_template' => $template,
6458 'wl_subject' => $subject,
6559 'wl_message' => $text,
6660 'wl_email' => 0,
@@ -90,9 +84,6 @@
9185 ApiBase::PARAM_TYPE => 'string',
9286 ApiBase::PARAM_REQUIRED => true,
9387 ),
94 - 'template' => array(
95 - ApiBase::PARAM_TYPE => 'string',
96 - ),
9788 'type' => array(
9889 ApiBase::PARAM_TYPE => 'string',
9990 ),
@@ -102,10 +93,9 @@
10394 public function getParamDescription() {
10495 return array(
10596 'title' => 'Title of the user or user talk page to send WikiLove to',
106 - 'text' => 'Raw ikitext to add in the new section',
 97+ 'text' => 'Raw wikitext to add in the new section',
10798 'token' => 'Edit token. You can get one of these through prop=info',
10899 'subject' => 'Subject header of the new section',
109 - 'template' => 'Template name used in the wikitext (for statistics)',
110100 'type' => array( 'Type of WikiLove (for statistics); this corresponds with a type',
111101 'selected in the left menu, and optionally a subtype after that',
112102 '(e.g. "barnstar-normal" or "kitten")',
@@ -117,9 +107,9 @@
118108 return array(
119109 'Give WikiLove to another user.',
120110 "WikiLove is a positive message posted to a user's talk page through a",
121 - 'convenient interface with preset images and templates. This action adds',
122 - 'the specified wikitext to a certain talk page. For statistical purposes,',
123 - 'the type and template (among the other data) are logged.',
 111+ 'convenient interface with preset or locally defined templates. This action',
 112+ 'adds the specified wikitext to a certain talk page. For statistical purposes,',
 113+ 'the type and other data are logged.',
124114 );
125115 }
126116
@@ -130,10 +120,6 @@
131121 'code' => 'nologging',
132122 'info' => 'Warning: action was not logged!'
133123 ),
134 - array(
135 - 'code' => 'invalidtemplate',
136 - 'info' => 'Template could not be found in the message!'
137 - ),
138124 ) );
139125 }
140126
Index: trunk/extensions/WikiLove/patches/WikiLoveLog.sql
@@ -9,7 +9,6 @@
1010 `wl_sender_id` int(11) NOT NULL,
1111 `wl_receiver_id` int(11) NOT NULL,
1212 `wl_type` varchar(64) NOT NULL,
13 - `wl_template` varchar(64) NOT NULL,
1413 `wl_subject` varchar(255) NOT NULL,
1514 `wl_message` blob NOT NULL,
1615 `wl_email` bool NOT NULL default '0'

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87995Updated documentationjanpaul12315:44, 13 May 2011

Comments

#Comment by Kaldari (talk | contribs)   22:30, 17 May 2011

Also, I moved the default configuration out of the main file and into a separate file so that it's easier to manage

Status & tagging log