r59433 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59432‎ | r59433 | r59434 >
Date:19:34, 25 November 2009
Author:dale
Status:deferred
Tags:
Comment:
* restored basic firefogg upload functionality per r59320 breakage
* show preview of encoding video by default
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js (modified) (history)
  • /trunk/phase3/js2/uploadPage.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -28,11 +28,8 @@
2929
3030 var default_firefogg_options = {
3131 // Callback for upload completion
32 - 'done_upload_cb': false,
 32+ 'done_upload_cb': false,
3333
34 - // True if Firefogg is enabled in the client
35 - 'have_firefogg': false,
36 -
3734 // The API URL to upload to
3835 'api_url': null,
3936
@@ -86,7 +83,10 @@
8784 'firefogg_form_action': true,
8885
8986 // True if we should show a preview of the encoding progress
90 - 'show_preview': false
 87+ 'show_preview': true,
 88+
 89+ //If we should enable chunk uploads ( mediaWiki api supports chunk uploads)
 90+ 'enable_chunks' : false
9191 };
9292
9393
@@ -242,7 +242,6 @@
243243
244244 // Now show the form
245245 $j( _this.selector ).show();
246 -
247246 if ( _this.getFirefogg() ) {
248247 // Firefogg enabled
249248 // If we're in upload mode, show the input filename
@@ -395,10 +394,11 @@
396395 * Display an upload progress overlay. Overrides the function in mvBaseUploadInterface.
397396 */
398397 displayProgressOverlay: function() {
399 - this.pe_displayProgressOverlay();
 398+ this.pe_displayProgressOverlay();
400399 // If we are uploading video (not in passthrough mode), show preview button
401 - if( this.getFirefogg() && !this.getEncoderSettings()['passthrough']
402 - && !this.isCopyUpload() )
 400+ if( this.getFirefogg()
 401+ && !this.isCopyUpload()
 402+ && !this.getEncoderSettings()['passthrough'] )
403403 {
404404 this.createPreviewControls();
405405 }
@@ -409,10 +409,19 @@
410410 */
411411 createPreviewControls: function() {
412412 var _this = this;
 413+
 414+ // Set the initial button html:
 415+ var buttonHtml = '';
 416+ if( _this.show_preview == true ){
 417+ buttonHtml = $j.btnHtml( gM( 'fogg-hidepreview' ), 'fogg_preview', 'triangle-1-s' );
 418+ } else {
 419+ buttonHtml = $j.btnHtml( gM( 'fogg-preview' ), 'fogg_preview', 'triangle-1-e' );
 420+ }
 421+
413422 // Add the preview button and canvas
414423 $j( '#upProgressDialog' ).append(
415424 '<div style="clear:both;height:3em"/>' +
416 - $j.btnHtml( gM( 'fogg-preview' ), 'fogg_preview', 'triangle-1-e' ) +
 425+ buttonHtml +
417426 '<div style="padding:10px;">' +
418427 '<canvas style="margin:auto;" id="fogg_preview_canvas" />' +
419428 '</div>'
@@ -421,14 +430,6 @@
422431 // Set the initial state
423432 if ( _this.show_preview == true ) {
424433 $j( '#fogg_preview_canvas' ).show();
425 - } else {
426 - // Fix the icon class
427 - $j( this ).children( '.ui-icon' )
428 - .removeClass( 'ui-icon-triangle-1-s' )
429 - .addClass( 'ui-icon-triangle-1-e' );
430 - // Set the button text
431 - $j( this ).children( '.btnText' ).text( gM( 'fogg-preview' ) );
432 - $j( '#fogg_preview_canvas' ).hide();
433434 }
434435
435436 // Bind the preview button
@@ -556,7 +557,7 @@
557558 */
558559 updateSourceFileUI: function() {
559560 js_log( 'videoSelectReady' );
560 -
 561+ var _this = this;
561562 if ( !_this.fogg.sourceInfo || !_this.fogg.sourceFilename ) {
562563 // Something wrong with the source file?
563564 js_log( 'selectSourceFile: sourceInfo/sourceFilename missing' );
@@ -620,7 +621,7 @@
621622 return false;
622623 }
623624 try {
624 - this.sourceFileInfo = JSON.parse( firefogg.sourceInfo );
 625+ this.sourceFileInfo = JSON.parse( this.fogg.sourceInfo );
625626 } catch ( e ) {
626627 js_error( 'error could not parse fogg sourceInfo' );
627628 return false;
@@ -797,21 +798,23 @@
798799 js_log( "firefogg: doUpload:: " +
799800 ( this.getFirefogg() ? 'on' : 'off' ) +
800801 ' up mode:' + _this.upload_mode );
801 -
802 - // If Firefogg is disabled, just invoke the parent method
803 - if( !this.getFirefogg() || !this.firefogg_form_action ) {
 802+
 803+ // If Firefogg is disabled or doing an copyByUrl upload, just invoke the parent method
 804+ if( !this.getFirefogg() || this.isCopyUpload() ) {
804805 _this.pe_doUpload();
805806 return;
806807 }
807 -
808 - if ( _this.upload_mode == 'post' ) {
 808+ // We can do a chunk upload
 809+ if( _this.upload_mode == 'post' && _this.enable_chunks ){
 810+ _this.doChunkUpload();
 811+ } else if ( _this.upload_mode == 'post' ) {
809812 // Encode and then do a post upload
810813 _this.doEncode(
811814 function /* onProgress */ ( progress ) {
812815 _this.updateProgress( progress );
813816 },
814817 function /* onDone */ () {
815 - js_log( 'done with encoding do POST upload:' + _this.editForm.action );
 818+ js_log( 'done with encoding do POST upload:' + _this.form.action );
816819 // ignore warnings & set source type
817820 //_this.formData[ 'wpIgnoreWarning' ]='true';
818821 _this.formData['wpSourceType'] = 'upload';
@@ -824,9 +827,6 @@
825828 _this.doUploadStatus();
826829 }
827830 );
828 - } else if ( _this.upload_mode == 'api' ) {
829 - // We have the API so we can do a chunk upload
830 - _this.doChunkUpload();
831831 } else {
832832 js_error( 'Error: unrecongized upload mode: ' + _this.upload_mode );
833833 }
@@ -1027,34 +1027,30 @@
10281028 js_log( 'Error:firefogg upload error: ' + _this.fogg.state );
10291029 return;
10301030 }
1031 -
1032 - if ( _this.upload_mode == 'api' ) {
1033 - if ( apiResult && apiResult.resultUrl ) {
1034 - var buttons = {};
1035 - buttons[ gM( 'mwe-go-to-resource' ) ] = function() {
1036 - window.location = apiResult.resultUrl;
1037 - }
1038 - var go_to_url_txt = gM( 'mwe-go-to-resource' );
1039 - var showMessage = true;
1040 - if ( typeof _this.done_upload_cb == 'function' ) {
1041 - // Call the callback
1042 - // It will return false if it doesn't want us to show our own "done" message
1043 - showMessage = _this.done_upload_cb( _this.formData );
1044 - }
1045 - if ( showMessage ) {
1046 - _this.updateProgressWin( gM( 'mwe-successfulupload' ),
1047 - gM( 'mwe-upload_done', apiResult.resultUrl ), buttons );
1048 - } else {
1049 - this.action_done = true;
1050 - $j( '#upProgressDialog' ).empty().dialog( 'close' );
1051 - }
 1031+ if ( apiResult && apiResult.resultUrl ) {
 1032+ var buttons = {};
 1033+ buttons[ gM( 'mwe-go-to-resource' ) ] = function() {
 1034+ window.location = apiResult.resultUrl;
 1035+ }
 1036+ var go_to_url_txt = gM( 'mwe-go-to-resource' );
 1037+ var showMessage = true;
 1038+ if ( typeof _this.done_upload_cb == 'function' ) {
 1039+ // Call the callback
 1040+ // It will return false if it doesn't want us to show our own "done" message
 1041+ showMessage = _this.done_upload_cb( _this.formData );
 1042+ }
 1043+ if ( showMessage ) {
 1044+ _this.updateProgressWin( gM( 'mwe-successfulupload' ),
 1045+ gM( 'mwe-upload_done', apiResult.resultUrl ), buttons );
10521046 } else {
1053 - // Done state with error? Not really possible given how firefogg works...
1054 - js_log( " Upload done in chunks mode, but no resultUrl!" );
 1047+ this.action_done = true;
 1048+ $j( '#upProgressDialog' ).empty().dialog( 'close' );
10551049 }
10561050 } else {
1057 - js_log( "Error:: not supported upload mode" + _this.upload_mode );
 1051+ // Done state with error? Not really possible given how firefogg works...
 1052+ js_log( " Upload done in chunks mode, but no resultUrl!" );
10581053 }
 1054+
10591055 }
10601056 uploadStatus();
10611057 },
@@ -1068,7 +1064,7 @@
10691065 }
10701066 js_log( 'firefogg:cancel' )
10711067 if ( confirm( gM( 'mwe-cancel-confim' ) ) ) {
1072 - // FIXME: sillyness
 1068+ // FIXME: sillyness ( upstream firefogg cancel fix needed )
10731069 if ( navigator.oscpu && navigator.oscpu.search( 'Win' ) >= 0 ) {
10741070 alert( 'sorry we do not yet support cancel on windows' );
10751071 } else {
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js
@@ -133,9 +133,15 @@
134134 // set up the binding per the config
135135 if ( opt.enable_fogg ) {
136136 $j( "#wpUploadFile" ).firefogg( {
137 - // an api url (we won't submit directly to action of the form)
 137+ // An api url (we won't submit directly to action of the form)
138138 'api_url' : opt.api_target,
 139+
 140+ // If we should do a form rewrite
139141 'form_rewrite': true,
 142+
 143+ // MediaWiki API supports chunk uploads:
 144+ 'enable_chunks' : true,
 145+
140146 'edit_form_selector' : '#suf-upload',
141147 'new_source_cb' : function( orgFilename, oggName ) {
142148 $j( "#wpDestFile" ).val( oggName ).doDestCheck( {
Index: trunk/phase3/js2/uploadPage.js
@@ -10,7 +10,7 @@
1111 var _this = this;
1212 // If wgEnableFirefogg is not boolean false, set to true
1313 if ( typeof wgEnableFirefogg == 'undefined' )
14 - wgEnableFirefogg = true;
 14+ wgEnableFirefogg = true;
1515
1616 if ( wgEnableFirefogg ) {
1717 // Set up the upload handler to Firefogg. Should work with the HTTP uploads too.
@@ -18,6 +18,8 @@
1919 // An API URL (we won't submit directly to action of the form)
2020 'api_url': wgServer + wgScriptPath + '/api.php',
2121 'form_rewrite': true,
 22+ // MediaWiki API supports chunk uploads:
 23+ 'enable_chunks' : true,
2224 'edit_form_selector': mwUploadFormSelector,
2325 'new_source_cb': function( orgFilename, oggName ) {
2426 $j( '#wpDestFile' ).val( oggName );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59320* fixed audio vs video display height in remoteMwEmbed rewrite...dale18:45, 21 November 2009

Status & tagging log