http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73343

Revision: 73343
Author:   dale
Date:     2010-09-19 21:48:32 +0000 (Sun, 19 Sep 2010)

Log Message:
-----------
added 'File:' import key support per sugestion on Commons_talk:Sequencer

Modified Paths:
--------------
    branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
    branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
    
branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
    branches/MwEmbedStandAlone/modules/Sequencer/loader.js
    branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
    branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
    branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
    branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js

Added Paths:
-----------
    branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js

Removed Paths:
-------------
    branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js

Modified: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
===================================================================
--- branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js        
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js        
2010-09-19 21:48:32 UTC (rev 73343)
@@ -1636,8 +1636,9 @@
                        callback( provider );
                } );
        },
+       
        /**
-        * get a resource from a url loads the provider if not already 
initialized 
+        * Get a resource from a url loads the provider if not already 
initialized 
         */
        getResourceFromUrl: function ( provider, url, callback){                
                if (!provider.sObj) {
@@ -1650,8 +1651,20 @@
                }
        },
        
-       
        /**
+        * Get a resource from a titleKey loads the provider if not already 
initialized 
+        */
+       getResourceFromTitleKey: function ( provider, title, callback){         
+               if (!provider.sObj) {
+                       this.loadSearchLib( provider, function( provider ){     
                        
+                               provider.sObj.getByTitle( title, callback);
+                       });
+               }
+               else {
+                       provider.sObj.getByTitle( title, callback);
+               }
+       },
+       /**
        * Get a resource object from a resource id
        *
        * NOTE: We could bind resource objects to html elements to avoid this 
lookup

Modified: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js    
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js    
2010-09-19 21:48:32 UTC (rev 73343)
@@ -106,11 +106,14 @@
        
        // If the player controls should be overlaid 
        //( Global default via config EmbedPlayer.OverlayControls in module 
loader.js)  
-       "overlayControls" : true,
+       "overlaycontrols" : true,
        
        // Attribute to use 'native' controls 
        "usenativecontrols" : false,
        
+       // If the player should include an attribution button:
+       'attributionbutton' : true,
+       
        // ROE url ( for xml based metadata )
        // also see: http://wiki.xiph.org/ROE
        "roe" : null,

Modified: 
branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
===================================================================
--- 
branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js 
    2010-09-19 21:24:13 UTC (rev 73342)
+++ 
branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js 
    2010-09-19 21:48:32 UTC (rev 73343)
@@ -166,7 +166,7 @@
                        this.supportedComponets['timedText'] = true;
                }               
                // Check for Attribution button         
-               if( mw.getConfig( 'EmbedPlayer.AttributionButton' ) ){
+               if( mw.getConfig( 'EmbedPlayer.AttributionButton' ) && 
embedPlayer.attributionbutton ){
                        this.supportedComponets[ 'attributionButton' ] = true;
                }
                
@@ -640,7 +640,7 @@
                }
                
                // If disabled via the player
-               if( this.embedPlayer.overlayControls === false ){
+               if( this.embedPlayer.overlaycontrols === false ){
                        return false;
                } 
                

Modified: branches/MwEmbedStandAlone/modules/Sequencer/loader.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/loader.js      2010-09-19 
21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/loader.js      2010-09-19 
21:48:32 UTC (rev 73343)
@@ -19,7 +19,7 @@
                
                "mw.SequencerServer" : "mw.SequencerServer.js",
                "mw.SequencerAddMedia" : "mw.SequencerAddMedia.js",
-               "mw.SequencerAddByUrl" : "mw.SequencerAddByUrl.js",
+               "mw.SequencerAddByUri" : "mw.SequencerAddByUri.js",
                "mw.SequencerPlayer" : "mw.SequencerPlayer.js",
                "mw.SequencerTimeline" : "mw.SequencerTimeline.js",
                "mw.SequencerKeyBindings" : "mw.SequencerKeyBindings.js",
@@ -68,7 +68,7 @@
                        [                                                       
                        
                                '$j.contextMenu',                               
                                'mw.SequencerServer',                           
-                               'mw.SequencerAddByUrl',
+                               'mw.SequencerAddByUri',
                                'mw.SequencerAddMedia',
                                'mw.SequencerPlayer',
                                'mw.SequencerRender',

Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js        
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js        
2010-09-19 21:48:32 UTC (rev 73343)
@@ -294,11 +294,11 @@
                }
                return this.addMedia;
        },
-       getAddByUrl: function(){
-               if( ! this.addByUrl ){
-                       this.addByUrl = new mw.SequencerAddByUrl( this );
+       getAddByUri: function(){
+               if( ! this.addByUri ){
+                       this.addByUri = new mw.SequencerAddByUri( this );
                }
-               return this.addByUrl
+               return this.addByUri
        },
        getKeyBindings:function(){
                if( ! this.keyBindings ){

Copied: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js 
(from rev 73258, 
branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js)
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js        
                        (rev 0)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js        
2010-09-19 21:48:32 UTC (rev 73343)
@@ -0,0 +1,157 @@
+/**
+* Sequencer add by url support ( ties into mwEmbed AddMedia remoteSearchDriver 
module )
+*/
+
+//Wrap in mw closure
+( function( mw ) {
+       
+mw.SequencerAddByUri = function( sequencer ) {
+       return this.init( sequencer );
+};
+mw.SequencerAddByUri.prototype = {
+       init: function( sequencer ){
+               this.sequencer = sequencer;
+       },
+       
+       /**
+        * Does a basic parseUri check to see if a string is likely a url:
+        */
+       isUri: function( inputString ){
+               // Check for file: type key
+               if( inputString.indexOf('File:') === 0 ){
+                       return true;
+               }
+               return ( mw.parseUri( inputString ).protocol ) ;
+       },
+       
+       /**
+        * Try to add media via url and present a dialog if failed 
+        *  or user input is required
+        *  
+        *  Uses remoteSearchDriver to help in retrieving entry info
+        *  @param  {Object} remoteSearchDriver The remote search driver
+        */ 
+       addByUriDialog: function( remoteSearchDriver, importString ){           
+               var _this = this;
+               var importString = unescape( importString );
+               mw.log('SequencerAddByUri::addByUrlDialog:'+ importString);
+               var $dialog = mw.addLoaderDialog( gM( 
'mwe-sequencer-loading-asset' ) );
+               
+               // Close / empty the toolWindow
+               _this.sequencer.getTools().setDefaultText();            
+               
+               // Check for file type uri direct key with local   
+               if( importString.indexOf('File:') === 0 ){
+                       // make sure we have commons or local_wiki as a 
resource source: 
+                       var provider = remoteSearchDriver.content_providers[ 
'this_wiki' ];
+                       if( ! provider ){
+                                provider = 
remoteSearchDriver.content_providers[ 'wiki_commons' ];
+                       }
+                       // Try to import from the given provider: 
+                       if( provider ){                 
+                               remoteSearchDriver.getResourceFromTitleKey( 
provider, importString, function( resource ){
+                                       if( ! resource ){
+                                               $dialog.html( 'Error loading 
asset');
+                                               return ; 
+                                       }
+                                       // Get convert resource to smilClip and 
insert into the timeline
+                                       _this
+                                       .sequencer
+                                       .getAddMedia()
+                                       .getSmilClipFromResource( resource, 
function( smilClip ) {
+                                               
_this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
+                                               mw.closeLoaderDialog();
+                                       });                                     
                                
+                               });     
+                               return ;
+                       }                       
+               }
+               
+               var foundImportUrl = false;
+               // See if the asset matches the detailsUrl key type of any 
enabled content provider: 
+               $j.each( remoteSearchDriver.getEnabledProviders(), 
function(providerName, provider){                    
+                       if( mw.parseUri( provider.detailsUrl ).host  ==  
mw.parseUri( importString).host ){                     
+                               foundImportUrl = true;
+                               mw.log( "addByUrlDialog: matching host 
getResourceFromUrl::"
+                                               + mw.parseUri( 
provider.detailsUrl ).host 
+                                               + ' == ' + mw.parseUri( 
importString ).host );
+                               
+                               // Do special check for mediawiki templates and 
pages as 'special' smil types 
+                               if( provider.lib == 'mediaWiki' ){
+                                       // xxx we should do a query to the  api 
to determine namespace instead of hard coded checks
+                                       remoteSearchDriver.loadSearchLib( 
provider, function( provider ){
+                                               var titleKey = 
provider.sObj.getTitleKeyFromMwUrl( importString );
+                                               if( !titleKey ){
+                                                       $dialog.html( 
gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) )
+                                                       // continue for loop ( 
if we can't get a title from the mediaWiki url )
+                                                       return true;
+                                               }
+                                               
+                                               // Check the title type 
+                                               // xxx should use 
wgFormattedNamespacess
+                                               if( titleKey.indexOf('File:') 
== 0 ){
+                                                       // Asset is a file 
import resource as a file: 
+                                                       
remoteSearchDriver.getResourceFromUrl( provider, importString, function( 
resource ){
+                                                               if( ! resource 
){
+                                                                       
$dialog.html( 'Error loading asset');
+                                                                       return 
; 
+                                                               }
+                                                               // Get convert 
resource to smilClip and insert into the timeline
+                                                               _this
+                                                               .sequencer
+                                                               .getAddMedia()
+                                                               
.getSmilClipFromResource( resource, function( smilClip ) {
+                                                                       
_this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
+                                                                       
mw.closeLoaderDialog();
+                                                               });             
                                                        
+                                                       });     
+                                               } else if( 
titleKey.indexOf('Template:') == 0 ) {
+                                                       // Parse any parameters 
we can find:                            
+                                                       var apiProvider = '';
+                                                       if( 
mw.parseUri(provider.apiUrl ).host == 'commons.wikimedia.org' ){
+                                                               apiProvider = 
'commons'
+                                                       } else {
+                                                               // xxx we need 
to abstract the remoteSearch driver provider logic
+                                                               // into a 
provider class
+                                                               apiProvider = 
'local';
+                                                       }
+                                                       // Get template 
smilClip: 
+                                                       var smilClip = _this
+                                                       .sequencer
+                                                       .getAddMedia()
+                                                       
.getSmilClipFromWikiTemplate( titleKey, apiProvider );
+
+                                                       // Add the smil clip to 
the sequencer
+                                                       
_this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
+                                                       
+                                                       // Close the dialog 
loading: 
+                                                       mw.closeLoaderDialog();
+                                               
+                                               /*
+                                                * Soon sequence transclution 
fun: 
+                                                * else if( 
titleKey.indexOf('Sequence:') == 0 ) {
+                                                */
+                                               
+                                               } else {
+                                                       $dialog.html( 'Error 
loading asset type');
+                                               }
+                                                                               
+                                       });
+                               } else {
+                                       mw.log(" only MediaWiki URLs supported 
as resources right now");                                        
+                               }                               
+                       }
+               });     
+               
+               if( ! foundImportUrl ){
+                       $dialog.html( 
gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) );
+               }
+               
+               // xxx support direct asset include
+               if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
+                       // try directly adding the asset
+               }
+       }       
+};
+
+} )( window.mw );      
\ No newline at end of file

Deleted: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js        
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js        
2010-09-19 21:48:32 UTC (rev 73343)
@@ -1,126 +0,0 @@
-/**
-* Sequencer add by url support ( ties into mwEmbed AddMedia remoteSearchDriver 
module )
-*/
-
-//Wrap in mw closure
-( function( mw ) {
-       
-mw.SequencerAddByUrl = function( sequencer ) {
-       return this.init( sequencer );
-};
-mw.SequencerAddByUrl.prototype = {
-       init: function( sequencer ){
-               this.sequencer = sequencer;
-       },
-       
-       /**
-        * Does a basic parseUri check to see if a string is likely a url:
-        */
-       isUrl: function( inputString ){
-               return ( mw.parseUri( inputString ).protocol ) ;
-       },
-       
-       /**
-        * Try to add media via url and present a dialog if failed 
-        *  or user input is required
-        *  
-        *  Uses remoteSearchDriver to help in retrieving entry info
-        *  @param  {Object} remoteSearchDriver The remote search driver
-        */ 
-       addByUrlDialog: function( remoteSearchDriver, importUrl ){              
-               var _this = this;
-               var importUrl = unescape( importUrl );
-               mw.log('SequencerAddByUrl::addByUrlDialog:'+ importUrl);
-               var $dialog = mw.addLoaderDialog( gM( 
'mwe-sequencer-loading-asset' ) );
-               
-               // Close / empty the toolWindow
-               _this.sequencer.getTools().setDefaultText();            
-               
-               var foundImportUrl = false;
-               // See if the asset matches the detailsUrl key type of any 
enabled content provider: 
-               $j.each( remoteSearchDriver.getEnabledProviders(), 
function(providerName, provider){
-                       if( mw.parseUri( provider.detailsUrl ).host  ==  
mw.parseUri( importUrl).host ){                        
-                               foundImportUrl = true;
-                               mw.log( "addByUrlDialog: matching host 
getResourceFromUrl::"
-                                               + mw.parseUri( 
provider.detailsUrl ).host 
-                                               + ' == ' + mw.parseUri( 
importUrl ).host );
-                               
-                               // Do special check for mediawiki templates and 
pages as 'special' smil types 
-                               if( provider.lib == 'mediaWiki' ){
-                                       // xxx we should do a query to the  api 
to determine namespace instead of hard coded checks
-                                       remoteSearchDriver.loadSearchLib( 
provider, function( provider ){
-                                               var titleKey = 
provider.sObj.getTitleKeyFromMwUrl( importUrl );
-                                               if( !titleKey ){
-                                                       $dialog.html( 
gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) )
-                                                       // continue for loop ( 
if we can't get a title from the mediaWiki url )
-                                                       return true;
-                                               }
-                                               
-                                               // Check the title type 
-                                               // xxx should use 
wgFormattedNamespacess
-                                               if( titleKey.indexOf('File:') 
== 0 ){
-                                                       // Asset is a file 
import resource as a file: 
-                                                       
remoteSearchDriver.getResourceFromUrl( provider, importUrl, function( resource 
){
-                                                               if( ! resource 
){
-                                                                       
$dialog.html( 'Error loading asset');
-                                                                       return 
; 
-                                                               }
-                                                               // Get convert 
resource to smilClip and insert into the timeline
-                                                               _this
-                                                               .sequencer
-                                                               .getAddMedia()
-                                                               
.getSmilClipFromResource( resource, function( smilClip ) {
-                                                                       
_this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
-                                                                       
mw.closeLoaderDialog();
-                                                               });             
                                                        
-                                                       });     
-                                               } else if( 
titleKey.indexOf('Template:') == 0 ) {
-                                                       // Parse any parameters 
we can find:                            
-                                                       var apiProvider = '';
-                                                       if( 
mw.parseUri(provider.apiUrl ).host == 'commons.wikimedia.org' ){
-                                                               apiProvider = 
'commons'
-                                                       } else {
-                                                               // xxx we need 
to abstract the remoteSearch driver provider logic
-                                                               // into a 
provider class
-                                                               apiProvider = 
'local';
-                                                       }
-                                                       // Get template 
smilClip: 
-                                                       var smilClip = _this
-                                                       .sequencer
-                                                       .getAddMedia()
-                                                       
.getSmilClipFromWikiTemplate( titleKey, apiProvider );
-
-                                                       // Add the smil clip to 
the sequencer
-                                                       
_this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
-                                                       
-                                                       // Close the dialog 
loading: 
-                                                       mw.closeLoaderDialog();
-                                               
-                                               /*
-                                                * Soon sequence transclution 
fun: 
-                                                * else if( 
titleKey.indexOf('Sequence:') == 0 ) {
-                                                */
-                                               
-                                               } else {
-                                                       $dialog.html( 'Error 
loading asset type');
-                                               }
-                                                                               
-                                       });
-                               } else {
-                                       mw.log(" only MediaWiki URLs supported 
as resources right now");                                        
-                               }                               
-                       }
-               });     
-               
-               if( ! foundImportUrl ){
-                       $dialog.html( 
gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) );
-               }
-               
-               // xxx support direct asset include
-               if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
-                       // try directly adding the asset
-               }
-       }       
-};
-
-} )( window.mw );      
\ No newline at end of file

Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js        
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js        
2010-09-19 21:48:32 UTC (rev 73343)
@@ -117,9 +117,10 @@
                
                this.getSearchDriver( function( remoteSearchDriver ){
                        // Check if input value can be handled by url
-                       var inputValue = 
_this.sequencer.getMenuTarget().find('input.searchMedia').val();
-                       if( _this.sequencer.getAddByUrl().isUrl( inputValue) ){
-                                _this.sequencer.getAddByUrl().addByUrlDialog( 
remoteSearchDriver, inputValue );
+                       var inputValue = 
_this.sequencer.getMenuTarget().find('input.searchMedia').val();                
               
+                       
+                       if( _this.sequencer.getAddByUri().isUri( inputValue) ){
+                                _this.sequencer.getAddByUri().addByUriDialog( 
remoteSearchDriver, inputValue );
                        } else {
                                // Else just use the remoteSearchDriver search 
interface
                                remoteSearchDriver.createUI();

Modified: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js  
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js  
2010-09-19 21:48:32 UTC (rev 73343)
@@ -34,7 +34,9 @@
                                $video.css(
                                        _this.getPlayerSize()
                                ).attr({
-                                       'id' : _this.getSmilPlayerId()
+                                       'id' : _this.getSmilPlayerId(),
+                                       'attributionbutton' : false,
+                                       'overlaycontrols' : false
                                }).append(
                                        $j('<source />').attr({
                                                'type' : 'application/smil',
@@ -46,9 +48,7 @@
                        // Draw the player ( keep the playhead for now )
                        // xxx we will eventually replace the playhead with 
sequence 
                        // based playhead interface for doing easy trims
-                       $j( '#' + _this.getSmilPlayerId() ).embedPlayer({
-                               'overlayControls' : false
-                       }, function(){
+                       $j( '#' + _this.getSmilPlayerId() ).embedPlayer({}, 
function(){
                                // Set the player interface to autoMargin ( 
need to fix css propagation in embed player)                        
                                $j( '#' + _this.getSmilPlayerId() 
).parent('.interface_wrap').css('margin', 'auto');
                                if( callback ){

Modified: 
branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js
===================================================================
--- branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js     
2010-09-19 21:24:13 UTC (rev 73342)
+++ branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js     
2010-09-19 21:48:32 UTC (rev 73343)
@@ -605,7 +605,7 @@
                                                return ;
                                        }
                                        $j( target ).empty().append( 
-                                               $j('<h3 />').text( 
gM('mwe-sequencer-editTemplate-params') )
+                                               $j('<h3 />').text( 
gM('mwe-sequencer-edittemplate-params') )
                                        )
                                        
                                        // This is not supposed to be perfect 
.. 



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to