r72110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72109‎ | r72110 | r72111 >
Date:15:32, 1 September 2010
Author:dale
Status:deferred
Tags:
Comment:
* added jQuery 1.4 loader
* stubs for commons description page
* add asset description on upload
Modified paths:
  • /branches/MwEmbedStandAlone/libraries/jquery/jquery-1.4.2.js (modified) (history)
  • /branches/MwEmbedStandAlone/libraries/jquery/plugins/jquery.menu/jquery.menu.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js
@@ -277,7 +277,9 @@
278278 */
279279 getRefElementsRecurse: function( $node, startOffset, callback ){
280280 var _this = this;
281 -
 281+ if( ! $node ){
 282+ $node = this.getDom();
 283+ }
282284 // Make sure $node is wrapped in jQuery object
283285 $node = $j( $node );
284286
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -142,7 +142,7 @@
143143 'gsrlimit': this.provider.limit,
144144 'gsroffset': this.provider.offset,
145145 'prop':'imageinfo|revisions|categories',
146 - 'iiprop':'url|mime|size',
 146+ 'iiprop':'url|mime|size|metadata',
147147 'iiurlwidth': parseInt( this.rsd.thumb_width ),
148148 'rvprop':'content'
149149 };
@@ -230,6 +230,7 @@
231231 'categories':page.categories
232232 }
233233 };
 234+
234235 for( var i in page.imageinfo[0].metadata ){
235236 if( page.imageinfo[0].metadata[i].name == 'length' ){
236237 resource.duration = page.imageinfo[0].metadata[i].value;
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -2031,31 +2031,34 @@
20322032 * On clip done action. Called once a clip is done playing
20332033 */
20342034 onClipDone: function() {
2035 - mw.log( 'EmbedPlayer::onClipDone:' + this.id + ' doneCount:' + this.donePlayingCount );
 2035+ mw.log( 'EmbedPlayer::onClipDone:' + this.id + ' doneCount:' + this.donePlayingCount + ' stop state:' +this.isStopped() );
20362036 var _this = this;
2037 -
2038 -
 2037+
20392038 // Only run stopped once:
20402039 if( !this.isStopped() ){
20412040 // Stop the monitor:
20422041 this.stopMonitor();
20432042
 2043+ // Show the control bar:
 2044+ this.controlBuilder.showControlBar();
 2045+
20442046 // Update the clip done playing count:
20452047 this.donePlayingCount ++;
20462048
20472049 // Fire the html5 ended binding
2048 - mw.log( "ended" );
20492050 var onDoneActionObject = {
20502051 'runBaseControlDone' : true
20512052 }
20522053
2053 - // Run the ended trigger ( allow the ended object to prevent default actions )
 2054+ // Run the ended trigger ( allow the ended object to prevent default actions )
 2055+ mw.log("EmbedPlayer::onClipDone:Trigger ended");
20542056 $j( this ).trigger( 'ended', onDoneActionObject );
20552057
20562058 if( onDoneActionObject.runBaseControlDone ){
20572059
20582060 // Check if we have the "loop" property set
20592061 if( this.loop ) {
 2062+ this.stop();
20602063 this.play();
20612064 return;
20622065 }
@@ -2754,6 +2757,7 @@
27552758 var _this = this;
27562759 if( this.paused === false ){
27572760 this.paused = true;
 2761+ mw.log('EmbedPlayer:trigger pause');
27582762 $j( this ).trigger('pause');
27592763 }
27602764 mw.log('mwEmbed:embedPlayer::pause() ');
@@ -2783,38 +2787,34 @@
27842788 */
27852789 stop: function() {
27862790 var _this = this;
2787 - mw.log( 'mvEmbed:stop:' + this.id );
 2791+ mw.log( 'mvEmbed:stop:' + this.id );
 2792+
27882793 // no longer seeking:
27892794 this.didSeekJump = false;
27902795
2791 - // reset current time and prev time and seek offset
2792 - this.currentTime = this.previousTime = this.serverSeekTime = 0;
 2796+ // Reset current time and prev time and seek offset
 2797+ this.currentTime = this.previousTime = this.serverSeekTime = 0;
27932798
2794 - // Previous player set time
 2799+ // Issue pause to update interface (only call this parent)
 2800+ if( !this.paused ){
 2801+ this.paused = true;
 2802+ // update the interface
 2803+ if ( this['parent_pause'] ) {
 2804+ this.parent_pause();
 2805+ } else {
 2806+ this.pause();
 2807+ }
 2808+ }
27952809
2796 - // First issue pause to update interface (only call this parent)
2797 - if ( this['parent_pause'] ) {
2798 - this.parent_pause();
2799 - } else {
2800 - this.pause();
2801 - }
 2810+ // Rewrite the html to thumbnail disp
 2811+ this.showThumbnail();
 2812+ this.bufferedPercent = 0; // reset buffer state
 2813+ this.controlBuilder.setStatus( this.getTimeRange() );
28022814
2803 - // Reset the currentTime:
2804 - this.currentTime = 0;
 2815+ // Reset the playhead
 2816+ mw.log("EmbedPlayer::Stop:: Reset play head")
 2817+ this.updatePlayHead( 0 );
28052818
2806 - // Check if thumbnail is being displayed in which case do nothing
2807 - if ( this.thumbnail_disp ) {
2808 - // already in stooped state
2809 - mw.log( 'already in stopped state' );
2810 - this.controlBuilder.setStatus( this.getTimeRange() );
2811 - } else {
2812 - // rewrite the html to thumbnail disp
2813 - this.showThumbnail();
2814 - this.bufferedPercent = 0; // reset buffer state
2815 - this.updatePlayHead( 0 );
2816 - this.controlBuilder.setStatus( this.getTimeRange() );
2817 - }
2818 -
28192819 //Bind play-btn-large play
28202820 this.$interface.find( '.play-btn-large' )
28212821 .unbind( 'click' )
@@ -3134,10 +3134,10 @@
31353135 * @param {Float} perc Value between 0 and 1 for position of playhead
31363136 */
31373137 updatePlayHead: function( perc ) {
3138 - $play_head = this.$interface.find( '.play_head' );
3139 - if ( this.controls && $play_head.length != 0 ) {
 3138+ $playHead = this.$interface.find( '.play_head' );
 3139+ if ( this.controls && $playHead.length != 0 ) {
31403140 var val = parseInt( perc * 1000 );
3141 - $play_head.slider( 'value', val );
 3141+ $playHead.slider( 'value', val );
31423142 }
31433143 },
31443144
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -1309,7 +1309,7 @@
13101310 var $textList = $j( '<ul />' );
13111311 $j.each( embedPlayer.mediaElement.getSources(), function( index, source ) {
13121312 if( source.getSrc() ) {
1313 - mw.log("add src: " + source.getTitle() );
 1313+ mw.log("showDownloadWithSources:: Add src: " + source.getTitle() );
13141314 var $dl_line = $j( '<li />').append(
13151315 $j('<a />')
13161316 .attr( 'href', source.getSrc() )
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -342,7 +342,7 @@
343343 pause: function() {
344344 this.getPlayerElement();
345345 this.parent_pause(); // update interface
346 - if ( this.playerElement ) {
 346+ if ( this.playerElement ) { // update player
347347 this.playerElement.pause();
348348 }
349349 },
@@ -495,7 +495,7 @@
496496 * Handle the native paused event
497497 */
498498 onPaused: function(){
499 - mw.log("native:paused");
 499+ mw.log( "embedPlayer:native:paused" );
500500 this.pause();
501501 },
502502
@@ -503,7 +503,7 @@
504504 * Handle the native play event
505505 */
506506 onPlay: function(){
507 - mw.log("native::play");
 507+ mw.log("embedPlayer:native::play");
508508 if( !this.isPlaying () ){
509509 this.play();
510510 }
@@ -556,11 +556,7 @@
557557 */
558558 onended: function() {
559559 var _this = this;
560 - //mw.log( 'native:onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() );
561 - // run abstract player onEned if the abstract player still things we are playing
562 -
563 - if( this.isPlaying() ){
564 - this.onClipDone();
565 - }
 560+ mw.log( 'EmbedPlayer:native:onended:' + this.playerElement.currentTime + ' real dur:' + this.getDuration() );
 561+ this.onClipDone();
566562 }
567563 };
Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -125,6 +125,8 @@
126126 'mwe-sequencer-publishing-status' => 'Publish status:',
127127 'mwe-sequencer-publishing-error' => 'Publish error',
128128 'mwe-sequencer-publishing-error-upload-desc' => 'There was an error in uploading the published file',
 129+ 'mwe-sequencer-publishing-uploading' => 'Uploading published file',
 130+ 'mwe-sequencer-publishing-updatepage' => 'Updating sequence description',
129131
130132 'mwe-sequencer-publishing-success' => 'Publish success',
131133 'mwe-sequencer-publishing-success-desc' => 'Sequence has successfully been published. [$1 Published file]',
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
@@ -371,13 +371,14 @@
372372 foggRender.doRender();
373373 });
374374 },
 375+
375376 // Upload the video from a supplied fogg target
376377 // note xx this might be better in the firefogg library since it has firefogg specific calls
377378 // @param {jQuery Object } $dialog
378379 // @param {firefogg Object}
379380 uploadRenderedVideo: function( $dialog, fogg ){
380381 var _this = this;
381 - $j( '#firefoggStatusTarget' ).text( 'uploading' );
 382+ $j( '#firefoggStatusTarget' ).text( gM('mwe-sequencer-publishing-uploading' ) );
382383 var updateUploadStatus = function(){
383384 if( fogg.status() == 'uploading' ){
384385 $j('#firefoggPercentDone').text(
@@ -410,7 +411,17 @@
411412 var apiResult = null;
412413 }
413414 }
414 - _this.uploadDone( $dialog, apiResult );
 415+ // Check the api response
 416+ if ( !apiResult || apiResult.error || ( apiResult.upload &&
 417+ ( apiResult.upload.result == "Failure" || apiResult.upload.error ) ) ) {
 418+
 419+ $dialog.dialog( 'option', 'title', gM('mwe-sequencer-publishing-error' ) );
 420+ // xxx improve error handling
 421+ $dialog.empty().text( gM( 'mwe-sequencer-publishing-error-upload-desc' ) )
 422+ return ;
 423+ }
 424+
 425+ _this.uploadSuccess( $dialog );
415426 return ;
416427 }
417428 }
@@ -419,18 +430,17 @@
420431 updateUploadStatus();
421432 })
422433 },
423 - uploadDone: function($dialog, apiResult){
424 - var _this = this;
425 - // Check the api response
426 - if ( !apiResult || apiResult.error || ( apiResult.upload &&
427 - ( apiResult.upload.result == "Failure" || apiResult.upload.error ) ) ) {
 434+ uploadSuccess: function($dialog, apiResult){
 435+ var _this = this;
 436+ // Update the description page:
 437+ $dialog.html( gM('mwe-sequencer-publishing-updatepage' ) );
 438+
 439+ // Update the file description
 440+ this.sequencer.getServer().updateSequenceFileDescription(function(){
428441
429 - $dialog.dialog( 'option', 'title', gM('mwe-sequencer-publishing-error' ) );
430 - // xxx improve error handling
431 - $dialog.empty().text( gM( 'mwe-sequencer-publishing-error-upload-desc' ) )
432 - return ;
433 - }
434 -
 442+ });
 443+
 444+
435445 // Success link to the sequence page / ok closes dialog
436446 $dialog.dialog( 'option', 'title', gM('mwe-sequencer-publishing-success' ) );
437447 var button = {};
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -211,7 +211,6 @@
212212 // By default the imported resource is its entire duration
213213 $smilRef.attr( 'dur', resource.duration );
214214 }
215 -
216215 // Set all available params
217216 var resourceAttributeMap = {
218217 'type' : 'mime',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
@@ -59,13 +59,19 @@
6060 this.pagePathUrl = serverConfig.pagePathUrl;
6161 }
6262
 63+ if( serverConfig.userName ){
 64+ this.userName = serverConfig.userName;
 65+ }
 66+
6367 }
6468 if( this.isConfigured() ){
6569 mw.log("Error: Sequencer server needs a full serverConfig to be initialized")
6670 return false;
6771 }
6872 },
69 -
 73+ getUserName: function(){
 74+ return this.userName;
 75+ },
7076
7177 // Check if the server exists / is configured
7278 isConfigured: function( ){
@@ -216,6 +222,52 @@
217223 callback( false );
218224 });
219225 },
 226+
 227+ updateSequenceFileDescription: function(){
 228+ var _this = this;
 229+ mw.getToken( apiUrl, title, function( token ){
 230+ var pageText = ''
 231+ if( mw.parseUri( apiUrl ).host == 'commons.wikimedia.org' ){
 232+ pageText = _this.getCommonsDescriptionText()
 233+ } else {
 234+ pageText = _this.getBaseFileDescription()
 235+ }
 236+ var request = {
 237+ 'action':'edit',
 238+ 'token' : token,
 239+ 'title' : 'File:' + _this.getVideoFileName(),
 240+ 'summary' : 'Automated sequence description page for published sequence: ' + _this.getTitle(),
 241+ 'text' : pageText
 242+ }
 243+ })
 244+ },
 245+ getBaseFileDescription: function(){
 246+ return 'Published sequence file for [[Sequence:' + _this.getTitle() + ']]';
 247+ },
 248+ getCommonsDescriptionText: function(){
 249+ var descText ="{{Information\n" +
 250+ "|Description=" + _this.getSequenceFileBaseDescription() + "\n" +
 251+ "|Source= Sequence Sources assets include:\n";
 252+
 253+ // loop over every asset:
 254+ this.sequencer.getSmil().getBody().getRefElementsRecurse(null, 0, function( $node ){
 255+ var $apiKeyParam = $node.children("param[name='apiTitleKey']");
 256+ if( $apiKeyParam.length ){
 257+ descText+= "*[[" + $apiKeyParam.attr('value') + "]]\n";
 258+ }
 259+ });
 260+ var dt = new Date();
 261+ descText+='|Date=' + dt.getFullYear() + '-' +
 262+ pad2(dt.getMonth()+1) + '-' +
 263+ pad2(dt.getDate()) + "\n" +
 264+ "|Author=Last edit by [[User:" + _this.getUserName() + "\n" +
 265+ "|Permission= {{Cc-by-nc-sa-2.0-dual}}" + "\n" +
 266+ "}}";
 267+
 268+ // Add Published Sequence category ( for now )
 269+ descText += "\n[[Category:Published Sequence]]\n";
 270+ },
 271+
220272 /**
221273 * Get the sequence description page url
222274 * @param {String} Optional Sequence title key
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -468,6 +468,7 @@
469469 },
470470
471471 handleReorder: function ( movedClip ){
 472+ mw.log("SequencerTimeline:: handleReorder");
472473 var _this = this;
473474 var smil = this.sequencer.getSmil();
474475 var movedIndex = null;
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js
@@ -79,25 +79,21 @@
8080 if( mw.getConfig( 'Sequencer.KalturaPlayerEditOverlay' )){
8181 var embedPlayer = $j( '#' + embedPlayerId ).get(0);
8282
83 - $j( embedPlayer ).bind( 'pause', function() {
84 - // For now don't overlay smil players ( used in editor )
85 - // xxx in the future we should have an editor class
86 - if( embedPlayer.supports['overlays'] && embedPlayer.instanceOf.toLowerCase() != 'smil' ){
87 - mw.remoteSequencerAddEditOverlay( embedPlayerId )
88 - // xxx should use getter setter
89 - embedPlayer.controlBuilder.displayOptionsMenuFlag = true;
90 - }
 83+ $j( embedPlayer ).bind( 'pause', function() {
 84+ mw.remoteSequencerAddEditOverlay( embedPlayerId )
 85+ // xxx should use getter setter
 86+ embedPlayer.controlBuilder.displayOptionsMenuFlag = true;
9187 return true;
9288 })
93 - $j( embedPlayer ).bind( 'ended', function( onDoneAction ){
 89+ $j( embedPlayer ).bind( 'ended', function( onDoneAction ){
9490 // pause event should fire
95 - //mw.remoteSequencerAddEditOverlay( embedPlayerId )
 91+ mw.remoteSequencerAddEditOverlay( embedPlayerId );
9692
9793 // show the credits screen after 3 seconds
98 - setTimeout(function(){
 94+ setTimeout(function(){
9995 $j( embedPlayer ).siblings( '.kalturaEditOverlay' ).fadeOut( 'fast' );
10096 embedPlayer.$interface.find('.k-menu').fadeIn('fast');
101 - },3000)
 97+ }, 3000)
10298
10399 // On end runs before interface bindings (give the dom 10ms to build out the menu )
104100 setTimeout(function(){
@@ -113,6 +109,16 @@
114110 });
115111 mw.remoteSequencerAddEditOverlay = function( embedPlayerId ){
116112 var embedPlayer = $j( '#' + embedPlayerId ).get(0);
 113+
 114+ // Check if we can do the overlay::
 115+ if( !embedPlayer.supports['overlays']
 116+ || embedPlayer.instanceOf.toLowerCase() == 'smil'
 117+ || embedPlayer.getHeight() < 180
 118+ || embedPlayer.getWidth() < 240
 119+ ){
 120+ return ;
 121+ }
 122+
117123 if(! $j( '#' + embedPlayerId ).siblings( '.kalturaEditOverlay' ).length ){
118124 var editLink = '#';
119125 if( mw.isLocalDomain( mw.getApiProviderURL( embedPlayer.apiProvider ) )
@@ -509,7 +515,8 @@
510516 'type' : 'mediaWiki',
511517 'url' : _this.getApiUrl(),
512518 'titleKey' : wgPageName,
513 - 'pagePathUrl' : wgServer + wgArticlePath
 519+ 'pagePathUrl' : wgServer + wgArticlePath,
 520+ 'userName' : wgUserName
514521 },
515522 // Set the add media wizard to only include commons:
516523 addMedia : {
Index: branches/MwEmbedStandAlone/libraries/jquery/plugins/jquery.menu/jquery.menu.js
@@ -328,7 +328,7 @@
329329 }
330330 },
331331 function() {
332 - if( menuitem && !menuitem.hasClass('divider') && !menuitem.hasClass('disabled') ){
 332+ if( typeof menuitem != 'undefined' && !menuitem.hasClass('divider') && !menuitem.hasClass('disabled') ){
333333 $(this).removeClass(options.linkHover).blur().parent().removeClass('active-menuitem');
334334 }
335335 }
Index: branches/MwEmbedStandAlone/libraries/jquery/jquery-1.4.2.js
@@ -13,6 +13,7 @@
1414 *
1515 * Date: Sat Feb 13 22:33:48 2010 -0500
1616 */
 17+
1718 (function( window, undefined ) {
1819
1920 // Define a local copy of jQuery
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -526,14 +526,21 @@
527527 if( typeof classSet == 'function') {
528528 callback = classSet;
529529 }
 530+
530531 // Inject mwEmbed if needed
531532 if ( typeof MW_EMBED_VERSION == 'undefined' ) {
532533 if ( mwUseScriptLoader ) {
533534 var rurl = mwEmbedHostPath + '/ResourceLoader.php?class=';
534535
535536 var coma = '';
 537+
 538+
536539 // Add jQuery too if we need it:
537 - if ( typeof window.jQuery == 'undefined' ) {
 540+ if ( typeof window.jQuery == 'undefined'
 541+ ||
 542+ // force load jquery if version 1.3.2 ( issues )
 543+ jQuery.fn.jquery == '1.3.2')
 544+ {
538545 rurl += 'window.jQuery';
539546 coma = ',';
540547 }
@@ -555,17 +562,29 @@
556563 rurl += '&' + mwGetReqArgs();
557564 importScriptURI( rurl );
558565 } else {
559 - // load mwEmbed js
560 - importScriptURI( mwEmbedHostPath + '/mwEmbed.js?' + mwGetReqArgs() );
561566
562 - // Load the class set as part of mwReady callback
563 - var instanceCallback = callback;
564 - var callback = function(){
565 - mw.load( classSet, function(){
566 - instanceCallback();
567 - })
 567+ // force load jQuery ( issues with '1.3.2' .data handling
 568+ if( jQuery && jQuery.fn.jquery== '1.3.2' ){
 569+ console.log('load: ' + mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js' );
 570+ importScriptURI( mwEmbedHostPath + '/libraries/jquery/jquery-1.4.2.js?' + mwGetReqArgs() );
568571 }
569 -
 572+ waitForJQueryUpgrade = function(){
 573+ if( jQuery && jQuery.fn.jquery== '1.3.2' ){
 574+ setTimeout( waitForJQueryUpgrade, 20);
 575+ } else {
 576+ // load mwEmbed js
 577+ importScriptURI( mwEmbedHostPath + '/mwEmbed.js?' + mwGetReqArgs() );
 578+
 579+ // Load the class set as part of mwReady callback
 580+ var instanceCallback = callback;
 581+ var callback = function(){
 582+ mw.load( classSet, function(){
 583+ instanceCallback();
 584+ })
 585+ }
 586+ }
 587+ }
 588+ waitForJQueryUpgrade();
570589 }
571590 }
572591 waitMwEmbedReady( callback );

Status & tagging log