r84067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84066‎ | r84067 | r84068 >
Date:23:34, 15 March 2011
Author:neilk
Status:deferred
Tags:
Comment:
reverting change r84000 - moving firefogg integration to uploadwizard-firefogg branch for now
Modified paths:
  • /trunk/extensions/UploadWizard/UploadWizard.config.php (modified) (history)
  • /trunk/extensions/UploadWizard/UploadWizardHooks.php (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.config.php
@@ -4,8 +4,7 @@
55 * Do not modify this file, instead use localsettings.php and set:
66 * $wgUploadWizardConfig[ 'name'] = 'value';
77 */
8 -global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules,
9 -$wgTimedMediaHandlerFileExtensions, $wgAutoloadClasses;
 8+global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules;
109 return array(
1110 // Upload wizard has an internal debug flag
1211 'debug' => false,
@@ -22,20 +21,6 @@
2322 // Check if we have the firefogg upload api module enabled:
2423 'enableFirefoggChunkUpload' => isset( $wgAPIModules['firefoggupload'] )? true : false,
2524
26 - // Firefogg encode settings ( if timed media handler extension is installed use HD webm, else mid-rage ogg )
27 - 'firefoggEncodeSettings' => ( class_exists( 'WebVideoTranscode' ) )?
28 - WebVideoTranscode::$derivativeSettings[ WebVideoTranscode::ENC_WEBM_HQ_VBR ] :
29 - array(
30 - 'maxSize' => '480',
31 - 'videoBitrate' => '512',
32 - 'audioBitrate' => '96',
33 - 'noUpscaling' => 'true',
34 - 'twopass' => 'true',
35 - 'keyframeInterval' => '128',
36 - 'bufDelay' => '256',
37 - 'codec' => 'theora',
38 - ),
39 -
4025 // The default api url is for the current wiki ( can override at run time )
4126 'apiUrl' => $wgServer . $wgScriptPath . '/api.php',
4227
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php
@@ -57,11 +57,6 @@
5858 // workhorse libraries
5959 'resources/mw.IframeTransport.js',
6060 'resources/mw.ApiUploadHandler.js',
61 -
62 - // firefogg support
63 - 'resources/mw.FirefoggHandler.js',
64 - 'resources/mw.FirefoggTransport.js',
65 -
6661 'resources/mw.DestinationChecker.js',
6762 'resources/mw.UploadWizardUtil.js',
6863
@@ -69,8 +64,9 @@
7065 'resources/mw.GroupProgressBar.js',
7166
7267 // UploadWizard specific abstractions
 68+ 'resources/mw.UploadWizardDeed.js',
7369 'resources/mw.UploadWizardLicenseInput.js',
74 -
 70+
7571 // main library
7672 'resources/mw.UploadWizard.js',
7773
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -14,7 +14,8 @@
1515 _this.div = $j('<div class="mwe-upwiz-file"></div>').get(0);
1616 _this.isFilled = false;
1717
18 - _this.$fileInputCtrl = _this.upload.getUploadHandler().getInputControl();
 18+ _this.$fileInputCtrl = $j('<input size="1" class="mwe-upwiz-file-input" name="file" type="file"/>')
 19+ .change( function() { _this.fileChanged(); } );
1920
2021 _this.$indicator = $j( '<div class="mwe-upwiz-file-indicator"></div>' );
2122
@@ -337,10 +338,6 @@
338339 * @return boolean if extension was acceptable
339340 */
340341 isGoodExtension: function( ext ) {
341 - // ugly but we don't have a base "uploadHandler" class
342 - if( this.upload.getUploadHandler().isGoodExtension ){
343 - return this.upload.getUploadHandler().isGoodExtension( ext );
344 - }
345342 return $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1;
346343 }
347344
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -22,17 +22,17 @@
2323 this.transportWeight = 1; // default
2424 this.detailsWeight = 1; // default
2525
26 - // details
 26+ // details
2727 this.ui = new mw.UploadWizardUploadInterface( this, filesDiv );
2828
2929 // handler -- usually ApiUploadHandler
30 - this.handler = this.getUploadHandler();
 30+ // this.handler = new ( mw.UploadWizard.config[ 'uploadHandlerClass' ] )( this );
 31+ // this.handler = new mw.MockUploadHandler( this );
 32+ this.handler = new mw.ApiUploadHandler( this, api );
3133 };
3234
3335 mw.UploadWizardUpload.prototype = {
34 - // Upload handler for the UploadWizardUpload
35 - uploadHandler: null, // lazy init
36 -
 36+
3737 acceptDeed: function( deed ) {
3838 var _this = this;
3939 _this.deed.applyDeed( _this );
@@ -49,7 +49,7 @@
5050 },
5151
5252 /**
53 - * Remove this upload. n.b. we trigger a removeUpload this is usually triggered from
 53+ * remove this upload. n.b. we trigger a removeUpload this is usually triggered from
5454 */
5555 remove: function() {
5656 this.state = 'aborted';
@@ -199,28 +199,8 @@
200200 */
201201 }
202202 },
 203+
203204 /**
204 - * Set the upload handler per browser capabilities
205 - */
206 - getUploadHandler: function( api ){
207 - if( this.uploadHandler ){
208 - return this.uploadHandler ;
209 - }
210 - if( typeof( Firefogg ) != 'undefined'
211 - &&
212 - mw.UploadWizard.config[ 'enableFirefogg' ]
213 - ) {
214 - mw.log("mw.UploadWizard::getUploadHandler> FirefoggHandler");
215 - this.uploadHandler = new mw.FirefoggHandler( this );
216 - return this.uploadHandler
217 - }
218 - // By default use the apiUploadHandler
219 - mw.log("mw.UploadWizard::getUploadHandler> ApiUploadHandler");
220 - this.uploadHandler = new mw.ApiUploadHandler( this );
221 - return this.uploadHandler;
222 - },
223 -
224 - /**
225205 * Fetch a thumbnail for a stashed upload of the desired width.
226206 * It is assumed you don't call this until it's been transported.
227207 *
@@ -282,7 +262,7 @@
283263
284264 var _this = this;
285265 if ( typeof width === 'undefined' || width === null || width <= 0 ) {
286 - width = mw.UploadWizard.config[ 'thumbnailWidth' ];
 266+ width = mw.UploadWizard.config[ 'thumbnailWidth' ];
287267 }
288268 width = parseInt( width, 10 );
289269 height = null;
@@ -339,6 +319,38 @@
340320 stepNames: [ 'tutorial', 'file', 'deeds', 'details', 'thanks' ],
341321 currentStepName: undefined,
342322
 323+ /*
 324+ // list possible upload handlers in order of preference
 325+ // these should all be in the mw.* namespace
 326+ // hardcoded for now. maybe some registry system might work later, like, all
 327+ // things which subclass off of UploadHandler
 328+ uploadHandlers: [
 329+ 'FirefoggUploadHandler',
 330+ 'XhrUploadHandler',
 331+ 'ApiIframeUploadHandler',
 332+ 'SimpleUploadHandler',
 333+ 'NullUploadHandler'
 334+ ],
 335+
 336+ * We can use various UploadHandlers based on the browser's capabilities. Let's pick one.
 337+ * For example, the ApiUploadHandler should work just about everywhere, but XhrUploadHandler
 338+ * allows for more fine-grained upload progress
 339+ * @return valid JS upload handler class constructor function
 340+ getUploadHandlerClass: function() {
 341+ // return mw.MockUploadHandler;
 342+ return mw.ApiUploadHandler;
 343+ var _this = this;
 344+ for ( var i = 0; i < uploadHandlers.length; i++ ) {
 345+ var klass = mw[uploadHandlers[i]];
 346+ if ( klass != undefined && klass.canRun( this.config )) {
 347+ return klass;
 348+ }
 349+ }
 350+ // this should never happen; NullUploadHandler should always work
 351+ return null;
 352+ },
 353+ */
 354+
343355 /**
344356 * Reset the entire interface so we can upload more stuff
345357 * Depending on whether we split uploading / detailing, it may actually always be as simple as loading a URL
Index: trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js
@@ -10,10 +10,25 @@
1111 * Represents an object which configures a form to upload its files via an iframe talking to the MediaWiki API.
1212 * @param an UploadInterface object, which contains a .form property which points to a real HTML form in the DOM
1313 */
14 -mw.ApiUploadHandler = function( upload ) {
 14+mw.ApiUploadHandler = function( upload, api ) {
1515 this.upload = upload;
16 - // setup up local pointer to api:
17 - this.api = upload.api;
 16+ this.api = api;
 17+ this.$form = $j( this.upload.ui.form );
 18+ this.configureForm();
 19+
 20+ // the Iframe transport is hardcoded for now because it works everywhere
 21+ // can also use Xhr Binary depending on browser
 22+ var _this = this;
 23+ this.transport = new mw.IframeTransport(
 24+ this.$form,
 25+ function( fraction ) {
 26+ _this.upload.setTransportProgress( fraction );
 27+ },
 28+ function( result ) {
 29+ _this.upload.setTransported( result );
 30+ }
 31+ );
 32+
1833 };
1934
2035 mw.ApiUploadHandler.prototype = {
@@ -44,40 +59,7 @@
4560 }
4661 */
4762 },
48 - getTransport: function(){
49 - if( this.transport ){
50 - return this.transport;
51 - }
52 - this.transport = new mw.IframeTransport(
53 - this.getForm(),
54 - function( fraction ) {
55 - _this.upload.setTransportProgress( fraction );
56 - },
57 - function( result ) {
58 - _this.upload.setTransported( result );
59 - }
60 - );
61 - return this.transport ;
62 - },
63 - getForm: function(){
64 - if( this.upload && this.upload.ui && this.upload.ui.form ){
65 - this.configureForm();
66 - return $j( this.upload.ui.form );
67 - }
68 - mw.log("Error:: could not get form")
69 - return false;
70 - },
71 - /**
72 - * Get a pointer to the "file" input control
73 - */
74 - getInputControl: function(){
75 - var _this = this;
76 - return $j('<input size="1" class="mwe-upwiz-file-input" name="file" type="file"/>')
77 - .change( function() {
78 - _this.upload.ui.fileChanged();
79 - } );
80 - },
81 -
 63+
8264 /**
8365 * Modify our form to have a fresh edit token.
8466 * If successful, return true to a callback.
@@ -100,8 +82,8 @@
10183 * @param value the value of the input
10284 */
10385 addFormInputIfMissing: function( name, value ) {
104 - if ( this.getForm().find( "[name='" + name + "']" ).length === 0 ) {
105 - this.getForm().append( $j( '<input />' ) .attr( { 'type': "hidden", 'name': name, 'value': value } ));
 86+ if ( this.$form.find( "[name='" + name + "']" ).length === 0 ) {
 87+ this.$form.append( $j( '<input />' ) .attr( { 'type': "hidden", 'name': name, 'value': value } ));
10688 }
10789 },
10890
@@ -115,7 +97,7 @@
11698 _this.beginTime = ( new Date() ).getTime();
11799 _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' );
118100 _this.upload.ui.showTransportProgress();
119 - _this.getForm().submit();
 101+ _this.$form.submit();
120102 };
121103 var err = function( code, info ) {
122104 _this.upload.setError( code, info );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84000* initial stubs for firefogg transport...dale06:20, 15 March 2011

Status & tagging log