Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -4,8 +4,7 @@ |
5 | 5 | * Do not modify this file, instead use localsettings.php and set: |
6 | 6 | * $wgUploadWizardConfig[ 'name'] = 'value'; |
7 | 7 | */ |
8 | | -global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules, |
9 | | -$wgTimedMediaHandlerFileExtensions, $wgAutoloadClasses; |
| 8 | +global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules; |
10 | 9 | return array( |
11 | 10 | // Upload wizard has an internal debug flag |
12 | 11 | 'debug' => false, |
— | — | @@ -22,20 +21,6 @@ |
23 | 22 | // Check if we have the firefogg upload api module enabled: |
24 | 23 | 'enableFirefoggChunkUpload' => isset( $wgAPIModules['firefoggupload'] )? true : false, |
25 | 24 | |
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 | | - |
40 | 25 | // The default api url is for the current wiki ( can override at run time ) |
41 | 26 | 'apiUrl' => $wgServer . $wgScriptPath . '/api.php', |
42 | 27 | |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -57,11 +57,6 @@ |
58 | 58 | // workhorse libraries |
59 | 59 | 'resources/mw.IframeTransport.js', |
60 | 60 | 'resources/mw.ApiUploadHandler.js', |
61 | | - |
62 | | - // firefogg support |
63 | | - 'resources/mw.FirefoggHandler.js', |
64 | | - 'resources/mw.FirefoggTransport.js', |
65 | | - |
66 | 61 | 'resources/mw.DestinationChecker.js', |
67 | 62 | 'resources/mw.UploadWizardUtil.js', |
68 | 63 | |
— | — | @@ -69,8 +64,9 @@ |
70 | 65 | 'resources/mw.GroupProgressBar.js', |
71 | 66 | |
72 | 67 | // UploadWizard specific abstractions |
| 68 | + 'resources/mw.UploadWizardDeed.js', |
73 | 69 | 'resources/mw.UploadWizardLicenseInput.js', |
74 | | - |
| 70 | + |
75 | 71 | // main library |
76 | 72 | 'resources/mw.UploadWizard.js', |
77 | 73 | |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js |
— | — | @@ -14,7 +14,8 @@ |
15 | 15 | _this.div = $j('<div class="mwe-upwiz-file"></div>').get(0); |
16 | 16 | _this.isFilled = false; |
17 | 17 | |
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(); } ); |
19 | 20 | |
20 | 21 | _this.$indicator = $j( '<div class="mwe-upwiz-file-indicator"></div>' ); |
21 | 22 | |
— | — | @@ -337,10 +338,6 @@ |
338 | 339 | * @return boolean if extension was acceptable |
339 | 340 | */ |
340 | 341 | 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 | | - } |
345 | 342 | return $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1; |
346 | 343 | } |
347 | 344 | |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -22,17 +22,17 @@ |
23 | 23 | this.transportWeight = 1; // default |
24 | 24 | this.detailsWeight = 1; // default |
25 | 25 | |
26 | | - // details |
| 26 | + // details |
27 | 27 | this.ui = new mw.UploadWizardUploadInterface( this, filesDiv ); |
28 | 28 | |
29 | 29 | // 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 ); |
31 | 33 | }; |
32 | 34 | |
33 | 35 | mw.UploadWizardUpload.prototype = { |
34 | | - // Upload handler for the UploadWizardUpload |
35 | | - uploadHandler: null, // lazy init |
36 | | - |
| 36 | + |
37 | 37 | acceptDeed: function( deed ) { |
38 | 38 | var _this = this; |
39 | 39 | _this.deed.applyDeed( _this ); |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | }, |
51 | 51 | |
52 | 52 | /** |
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 |
54 | 54 | */ |
55 | 55 | remove: function() { |
56 | 56 | this.state = 'aborted'; |
— | — | @@ -199,28 +199,8 @@ |
200 | 200 | */ |
201 | 201 | } |
202 | 202 | }, |
| 203 | + |
203 | 204 | /** |
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 | | - /** |
225 | 205 | * Fetch a thumbnail for a stashed upload of the desired width. |
226 | 206 | * It is assumed you don't call this until it's been transported. |
227 | 207 | * |
— | — | @@ -282,7 +262,7 @@ |
283 | 263 | |
284 | 264 | var _this = this; |
285 | 265 | if ( typeof width === 'undefined' || width === null || width <= 0 ) { |
286 | | - width = mw.UploadWizard.config[ 'thumbnailWidth' ]; |
| 266 | + width = mw.UploadWizard.config[ 'thumbnailWidth' ]; |
287 | 267 | } |
288 | 268 | width = parseInt( width, 10 ); |
289 | 269 | height = null; |
— | — | @@ -339,6 +319,38 @@ |
340 | 320 | stepNames: [ 'tutorial', 'file', 'deeds', 'details', 'thanks' ], |
341 | 321 | currentStepName: undefined, |
342 | 322 | |
| 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 | + |
343 | 355 | /** |
344 | 356 | * Reset the entire interface so we can upload more stuff |
345 | 357 | * 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 @@ |
11 | 11 | * Represents an object which configures a form to upload its files via an iframe talking to the MediaWiki API. |
12 | 12 | * @param an UploadInterface object, which contains a .form property which points to a real HTML form in the DOM |
13 | 13 | */ |
14 | | -mw.ApiUploadHandler = function( upload ) { |
| 14 | +mw.ApiUploadHandler = function( upload, api ) { |
15 | 15 | 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 | + |
18 | 33 | }; |
19 | 34 | |
20 | 35 | mw.ApiUploadHandler.prototype = { |
— | — | @@ -44,40 +59,7 @@ |
45 | 60 | } |
46 | 61 | */ |
47 | 62 | }, |
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 | + |
82 | 64 | /** |
83 | 65 | * Modify our form to have a fresh edit token. |
84 | 66 | * If successful, return true to a callback. |
— | — | @@ -100,8 +82,8 @@ |
101 | 83 | * @param value the value of the input |
102 | 84 | */ |
103 | 85 | 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 } )); |
106 | 88 | } |
107 | 89 | }, |
108 | 90 | |
— | — | @@ -115,7 +97,7 @@ |
116 | 98 | _this.beginTime = ( new Date() ).getTime(); |
117 | 99 | _this.upload.ui.setStatus( 'mwe-upwiz-transport-started' ); |
118 | 100 | _this.upload.ui.showTransportProgress(); |
119 | | - _this.getForm().submit(); |
| 101 | + _this.$form.submit(); |
120 | 102 | }; |
121 | 103 | var err = function( code, info ) { |
122 | 104 | _this.upload.setError( code, info ); |