r102694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102693‎ | r102694 | r102695 >
Date:21:11, 10 November 2011
Author:neilk
Status:ok
Tags:
Comment:
give up on auto-centering, does not work for templates with width=100%. Look up template with exact case. Recognize self and other such license filtering templates, transform their args into templates for further checking
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -216,6 +216,10 @@
217217
218218 // Custom wikitext must have at least one template that is a descendant of this category
219219 'licenseCategory' => 'License tags',
 220+
 221+ // When checking custom wikitext licenses, parse these templates as "filters";
 222+ // their arguments look like strings but they are really templates
 223+ 'licenseTagFilters' => array( 'self' ),
220224
221225 // radio button selection of some licenses
222226 'licensesOwnWork' => array(
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js
@@ -19,6 +19,7 @@
2020 mw.UploadWizardLicenseInput = function( selector, values, config, count, api ) {
2121 var _this = this;
2222 _this.count = count;
 23+
2324 _this.api = api;
2425
2526 if ( ! ( mw.isDefined(config.type)
@@ -57,14 +58,14 @@
5859 .css( 'padding', 10 )
5960 .dialog( {
6061 autoOpen: false,
61 - minWidth: 500,
 62+ width: 800,
6263 zIndex: 200000,
6364 modal: true
6465 } );
6566
6667 _this.$spinner = $j( '<div></div>' )
6768 .addClass( 'mwe-upwiz-status-progress mwe-upwiz-file-indicator' )
68 - .css( { width: 200, padding: 20 } );
 69+ .css( { 'width': 200, 'padding': 20, 'float': 'none', 'margin': '0 auto' } );
6970
7071 return _this;
7172 };
@@ -488,9 +489,21 @@
489490
490491 function accumTemplates( node, templates ) {
491492 if ( typeof node === 'object' ) {
492 - var operation = node[0].toLowerCase();
493 - if ( typeof mw.language.htmlEmitter.prototype[operation] !== 'function' ) {
494 - templates.push( operation );
 493+ var nodeName = node[0];
 494+ var lcNodeName = nodeName.toLowerCase();
 495+ // templates like Self are special cased, as it is not a license tag and also reparses its string arguments into templates
 496+ // e.g. {{self|Cc-by-sa-3.0}} --> we should add 'Cc-by-sa-3.0' to the templates
 497+ if ( mw.UploadWizard.config.licenseTagFilters
 498+ &&
 499+ mw.UploadWizard.config.licenseTagFilters.indexOf( lcNodeName ) !== -1 ) {
 500+ // upgrade all the arguments to be nodes in their own right (by making them the first element of an array)
 501+ // so, [ "self", "Cc-by-sa-3.0", "GFDL" ] --> [ "self", [ "Cc-by-sa-3.0" ], [ "GFDL" ] ];
 502+ // $.map seems to strip away arrays of one element so have to use an array within an array.
 503+ node = $j.map( node, function( n, i ) {
 504+ return i == 0 ? n : [[n]];
 505+ } );
 506+ } else if ( typeof mw.language.htmlEmitter.prototype[lcNodeName] !== 'function' ) {
 507+ templates.push( nodeName );
495508 }
496509 $j.map( node.slice( 1 ), function( n ) {
497510 accumTemplates( n, templates );
@@ -500,7 +513,6 @@
501514 var templates = [];
502515 accumTemplates( ast, templates );
503516
504 -
505517 // TODO caching
506518 var found = false;
507519 function recurseCategories( desiredCatTitle, title, depthToContinue ) {
@@ -547,12 +559,8 @@
548560
549561 var _this = this;
550562 function show( html ) {
551 - // apparently it is necessary to reaffirm all this every time if you want auto-resizing in jQuery 1.6
552 - _this.$previewDialog.dialog( 'option', 'width', 'auto' );
553 - _this.$previewDialog.dialog( 'option', 'height', 'auto' );
554563 _this.$previewDialog.html( html );
555564 _this.$previewDialog.dialog( 'open' );
556 - _this.$previewDialog.dialog( 'option', 'position', { 'at': 'center' } );
557565 }
558566
559567 var error = function( error ) {
@@ -561,6 +569,7 @@
562570 $j( '<p></p>' ).append( error['info'] )
563571 ) );
564572 };
 573+
565574 this.api.parse( wikiText, show, error );
566575 }
567576

Status & tagging log