r73343 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73342‎ | r73343 | r73344 >
Date:21:48, 19 September 2010
Author:dale
Status:deferred
Tags:
Comment:
added 'File:' import key support per sugestion on Commons_talk:Sequencer
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js (added) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js (deleted) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1636,8 +1636,9 @@
16371637 callback( provider );
16381638 } );
16391639 },
 1640+
16401641 /**
1641 - * get a resource from a url loads the provider if not already initialized
 1642+ * Get a resource from a url loads the provider if not already initialized
16421643 */
16431644 getResourceFromUrl: function ( provider, url, callback){
16441645 if (!provider.sObj) {
@@ -1650,8 +1651,20 @@
16511652 }
16521653 },
16531654
1654 -
16551655 /**
 1656+ * Get a resource from a titleKey loads the provider if not already initialized
 1657+ */
 1658+ getResourceFromTitleKey: function ( provider, title, callback){
 1659+ if (!provider.sObj) {
 1660+ this.loadSearchLib( provider, function( provider ){
 1661+ provider.sObj.getByTitle( title, callback);
 1662+ });
 1663+ }
 1664+ else {
 1665+ provider.sObj.getByTitle( title, callback);
 1666+ }
 1667+ },
 1668+ /**
16561669 * Get a resource object from a resource id
16571670 *
16581671 * NOTE: We could bind resource objects to html elements to avoid this lookup
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -106,11 +106,14 @@
107107
108108 // If the player controls should be overlaid
109109 //( Global default via config EmbedPlayer.OverlayControls in module loader.js)
110 - "overlayControls" : true,
 110+ "overlaycontrols" : true,
111111
112112 // Attribute to use 'native' controls
113113 "usenativecontrols" : false,
114114
 115+ // If the player should include an attribution button:
 116+ 'attributionbutton' : true,
 117+
115118 // ROE url ( for xml based metadata )
116119 // also see: http://wiki.xiph.org/ROE
117120 "roe" : null,
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -166,7 +166,7 @@
167167 this.supportedComponets['timedText'] = true;
168168 }
169169 // Check for Attribution button
170 - if( mw.getConfig( 'EmbedPlayer.AttributionButton' ) ){
 170+ if( mw.getConfig( 'EmbedPlayer.AttributionButton' ) && embedPlayer.attributionbutton ){
171171 this.supportedComponets[ 'attributionButton' ] = true;
172172 }
173173
@@ -640,7 +640,7 @@
641641 }
642642
643643 // If disabled via the player
644 - if( this.embedPlayer.overlayControls === false ){
 644+ if( this.embedPlayer.overlaycontrols === false ){
645645 return false;
646646 }
647647
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js
@@ -1,126 +0,0 @@
2 -/**
3 -* Sequencer add by url support ( ties into mwEmbed AddMedia remoteSearchDriver module )
4 -*/
5 -
6 -//Wrap in mw closure
7 -( function( mw ) {
8 -
9 -mw.SequencerAddByUrl = function( sequencer ) {
10 - return this.init( sequencer );
11 -};
12 -mw.SequencerAddByUrl.prototype = {
13 - init: function( sequencer ){
14 - this.sequencer = sequencer;
15 - },
16 -
17 - /**
18 - * Does a basic parseUri check to see if a string is likely a url:
19 - */
20 - isUrl: function( inputString ){
21 - return ( mw.parseUri( inputString ).protocol ) ;
22 - },
23 -
24 - /**
25 - * Try to add media via url and present a dialog if failed
26 - * or user input is required
27 - *
28 - * Uses remoteSearchDriver to help in retrieving entry info
29 - * @param {Object} remoteSearchDriver The remote search driver
30 - */
31 - addByUrlDialog: function( remoteSearchDriver, importUrl ){
32 - var _this = this;
33 - var importUrl = unescape( importUrl );
34 - mw.log('SequencerAddByUrl::addByUrlDialog:'+ importUrl);
35 - var $dialog = mw.addLoaderDialog( gM( 'mwe-sequencer-loading-asset' ) );
36 -
37 - // Close / empty the toolWindow
38 - _this.sequencer.getTools().setDefaultText();
39 -
40 - var foundImportUrl = false;
41 - // See if the asset matches the detailsUrl key type of any enabled content provider:
42 - $j.each( remoteSearchDriver.getEnabledProviders(), function(providerName, provider){
43 - if( mw.parseUri( provider.detailsUrl ).host == mw.parseUri( importUrl).host ){
44 - foundImportUrl = true;
45 - mw.log( "addByUrlDialog: matching host getResourceFromUrl::"
46 - + mw.parseUri( provider.detailsUrl ).host
47 - + ' == ' + mw.parseUri( importUrl ).host );
48 -
49 - // Do special check for mediawiki templates and pages as 'special' smil types
50 - if( provider.lib == 'mediaWiki' ){
51 - // xxx we should do a query to the api to determine namespace instead of hard coded checks
52 - remoteSearchDriver.loadSearchLib( provider, function( provider ){
53 - var titleKey = provider.sObj.getTitleKeyFromMwUrl( importUrl );
54 - if( !titleKey ){
55 - $dialog.html( gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) )
56 - // continue for loop ( if we can't get a title from the mediaWiki url )
57 - return true;
58 - }
59 -
60 - // Check the title type
61 - // xxx should use wgFormattedNamespacess
62 - if( titleKey.indexOf('File:') == 0 ){
63 - // Asset is a file import resource as a file:
64 - remoteSearchDriver.getResourceFromUrl( provider, importUrl, function( resource ){
65 - if( ! resource ){
66 - $dialog.html( 'Error loading asset');
67 - return ;
68 - }
69 - // Get convert resource to smilClip and insert into the timeline
70 - _this
71 - .sequencer
72 - .getAddMedia()
73 - .getSmilClipFromResource( resource, function( smilClip ) {
74 - _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
75 - mw.closeLoaderDialog();
76 - });
77 - });
78 - } else if( titleKey.indexOf('Template:') == 0 ) {
79 - // Parse any parameters we can find:
80 - var apiProvider = '';
81 - if( mw.parseUri(provider.apiUrl ).host == 'commons.wikimedia.org' ){
82 - apiProvider = 'commons'
83 - } else {
84 - // xxx we need to abstract the remoteSearch driver provider logic
85 - // into a provider class
86 - apiProvider = 'local';
87 - }
88 - // Get template smilClip:
89 - var smilClip = _this
90 - .sequencer
91 - .getAddMedia()
92 - .getSmilClipFromWikiTemplate( titleKey, apiProvider );
93 -
94 - // Add the smil clip to the sequencer
95 - _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
96 -
97 - // Close the dialog loading:
98 - mw.closeLoaderDialog();
99 -
100 - /*
101 - * Soon sequence transclution fun:
102 - * else if( titleKey.indexOf('Sequence:') == 0 ) {
103 - */
104 -
105 - } else {
106 - $dialog.html( 'Error loading asset type');
107 - }
108 -
109 - });
110 - } else {
111 - mw.log(" only MediaWiki URLs supported as resources right now");
112 - }
113 - }
114 - });
115 -
116 - if( ! foundImportUrl ){
117 - $dialog.html( gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) );
118 - }
119 -
120 - // xxx support direct asset include
121 - if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
122 - // try directly adding the asset
123 - }
124 - }
125 -};
126 -
127 -} )( window.mw );
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/Sequencer/loader.js
@@ -19,7 +19,7 @@
2020
2121 "mw.SequencerServer" : "mw.SequencerServer.js",
2222 "mw.SequencerAddMedia" : "mw.SequencerAddMedia.js",
23 - "mw.SequencerAddByUrl" : "mw.SequencerAddByUrl.js",
 23+ "mw.SequencerAddByUri" : "mw.SequencerAddByUri.js",
2424 "mw.SequencerPlayer" : "mw.SequencerPlayer.js",
2525 "mw.SequencerTimeline" : "mw.SequencerTimeline.js",
2626 "mw.SequencerKeyBindings" : "mw.SequencerKeyBindings.js",
@@ -68,7 +68,7 @@
6969 [
7070 '$j.contextMenu',
7171 'mw.SequencerServer',
72 - 'mw.SequencerAddByUrl',
 72+ 'mw.SequencerAddByUri',
7373 'mw.SequencerAddMedia',
7474 'mw.SequencerPlayer',
7575 'mw.SequencerRender',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
@@ -294,11 +294,11 @@
295295 }
296296 return this.addMedia;
297297 },
298 - getAddByUrl: function(){
299 - if( ! this.addByUrl ){
300 - this.addByUrl = new mw.SequencerAddByUrl( this );
 298+ getAddByUri: function(){
 299+ if( ! this.addByUri ){
 300+ this.addByUri = new mw.SequencerAddByUri( this );
301301 }
302 - return this.addByUrl
 302+ return this.addByUri
303303 },
304304 getKeyBindings:function(){
305305 if( ! this.keyBindings ){
Index: branches/MwEmbedStandAlone/modules/Sequencer/tools/mw.SequencerTools.js
@@ -605,7 +605,7 @@
606606 return ;
607607 }
608608 $j( target ).empty().append(
609 - $j('<h3 />').text( gM('mwe-sequencer-editTemplate-params') )
 609+ $j('<h3 />').text( gM('mwe-sequencer-edittemplate-params') )
610610 )
611611
612612 // This is not supposed to be perfect ..
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -117,9 +117,10 @@
118118
119119 this.getSearchDriver( function( remoteSearchDriver ){
120120 // Check if input value can be handled by url
121 - var inputValue = _this.sequencer.getMenuTarget().find('input.searchMedia').val();
122 - if( _this.sequencer.getAddByUrl().isUrl( inputValue) ){
123 - _this.sequencer.getAddByUrl().addByUrlDialog( remoteSearchDriver, inputValue );
 121+ var inputValue = _this.sequencer.getMenuTarget().find('input.searchMedia').val();
 122+
 123+ if( _this.sequencer.getAddByUri().isUri( inputValue) ){
 124+ _this.sequencer.getAddByUri().addByUriDialog( remoteSearchDriver, inputValue );
124125 } else {
125126 // Else just use the remoteSearchDriver search interface
126127 remoteSearchDriver.createUI();
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerPlayer.js
@@ -34,7 +34,9 @@
3535 $video.css(
3636 _this.getPlayerSize()
3737 ).attr({
38 - 'id' : _this.getSmilPlayerId()
 38+ 'id' : _this.getSmilPlayerId(),
 39+ 'attributionbutton' : false,
 40+ 'overlaycontrols' : false
3941 }).append(
4042 $j('<source />').attr({
4143 'type' : 'application/smil',
@@ -46,9 +48,7 @@
4749 // Draw the player ( keep the playhead for now )
4850 // xxx we will eventually replace the playhead with sequence
4951 // based playhead interface for doing easy trims
50 - $j( '#' + _this.getSmilPlayerId() ).embedPlayer({
51 - 'overlayControls' : false
52 - }, function(){
 52+ $j( '#' + _this.getSmilPlayerId() ).embedPlayer({}, function(){
5353 // Set the player interface to autoMargin ( need to fix css propagation in embed player)
5454 $j( '#' + _this.getSmilPlayerId() ).parent('.interface_wrap').css('margin', 'auto');
5555 if( callback ){
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUri.js
@@ -0,0 +1,157 @@
 2+/**
 3+* Sequencer add by url support ( ties into mwEmbed AddMedia remoteSearchDriver module )
 4+*/
 5+
 6+//Wrap in mw closure
 7+( function( mw ) {
 8+
 9+mw.SequencerAddByUri = function( sequencer ) {
 10+ return this.init( sequencer );
 11+};
 12+mw.SequencerAddByUri.prototype = {
 13+ init: function( sequencer ){
 14+ this.sequencer = sequencer;
 15+ },
 16+
 17+ /**
 18+ * Does a basic parseUri check to see if a string is likely a url:
 19+ */
 20+ isUri: function( inputString ){
 21+ // Check for file: type key
 22+ if( inputString.indexOf('File:') === 0 ){
 23+ return true;
 24+ }
 25+ return ( mw.parseUri( inputString ).protocol ) ;
 26+ },
 27+
 28+ /**
 29+ * Try to add media via url and present a dialog if failed
 30+ * or user input is required
 31+ *
 32+ * Uses remoteSearchDriver to help in retrieving entry info
 33+ * @param {Object} remoteSearchDriver The remote search driver
 34+ */
 35+ addByUriDialog: function( remoteSearchDriver, importString ){
 36+ var _this = this;
 37+ var importString = unescape( importString );
 38+ mw.log('SequencerAddByUri::addByUrlDialog:'+ importString);
 39+ var $dialog = mw.addLoaderDialog( gM( 'mwe-sequencer-loading-asset' ) );
 40+
 41+ // Close / empty the toolWindow
 42+ _this.sequencer.getTools().setDefaultText();
 43+
 44+ // Check for file type uri direct key with local
 45+ if( importString.indexOf('File:') === 0 ){
 46+ // make sure we have commons or local_wiki as a resource source:
 47+ var provider = remoteSearchDriver.content_providers[ 'this_wiki' ];
 48+ if( ! provider ){
 49+ provider = remoteSearchDriver.content_providers[ 'wiki_commons' ];
 50+ }
 51+ // Try to import from the given provider:
 52+ if( provider ){
 53+ remoteSearchDriver.getResourceFromTitleKey( provider, importString, function( resource ){
 54+ if( ! resource ){
 55+ $dialog.html( 'Error loading asset');
 56+ return ;
 57+ }
 58+ // Get convert resource to smilClip and insert into the timeline
 59+ _this
 60+ .sequencer
 61+ .getAddMedia()
 62+ .getSmilClipFromResource( resource, function( smilClip ) {
 63+ _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
 64+ mw.closeLoaderDialog();
 65+ });
 66+ });
 67+ return ;
 68+ }
 69+ }
 70+
 71+ var foundImportUrl = false;
 72+ // See if the asset matches the detailsUrl key type of any enabled content provider:
 73+ $j.each( remoteSearchDriver.getEnabledProviders(), function(providerName, provider){
 74+ if( mw.parseUri( provider.detailsUrl ).host == mw.parseUri( importString).host ){
 75+ foundImportUrl = true;
 76+ mw.log( "addByUrlDialog: matching host getResourceFromUrl::"
 77+ + mw.parseUri( provider.detailsUrl ).host
 78+ + ' == ' + mw.parseUri( importString ).host );
 79+
 80+ // Do special check for mediawiki templates and pages as 'special' smil types
 81+ if( provider.lib == 'mediaWiki' ){
 82+ // xxx we should do a query to the api to determine namespace instead of hard coded checks
 83+ remoteSearchDriver.loadSearchLib( provider, function( provider ){
 84+ var titleKey = provider.sObj.getTitleKeyFromMwUrl( importString );
 85+ if( !titleKey ){
 86+ $dialog.html( gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) )
 87+ // continue for loop ( if we can't get a title from the mediaWiki url )
 88+ return true;
 89+ }
 90+
 91+ // Check the title type
 92+ // xxx should use wgFormattedNamespacess
 93+ if( titleKey.indexOf('File:') == 0 ){
 94+ // Asset is a file import resource as a file:
 95+ remoteSearchDriver.getResourceFromUrl( provider, importString, function( resource ){
 96+ if( ! resource ){
 97+ $dialog.html( 'Error loading asset');
 98+ return ;
 99+ }
 100+ // Get convert resource to smilClip and insert into the timeline
 101+ _this
 102+ .sequencer
 103+ .getAddMedia()
 104+ .getSmilClipFromResource( resource, function( smilClip ) {
 105+ _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
 106+ mw.closeLoaderDialog();
 107+ });
 108+ });
 109+ } else if( titleKey.indexOf('Template:') == 0 ) {
 110+ // Parse any parameters we can find:
 111+ var apiProvider = '';
 112+ if( mw.parseUri(provider.apiUrl ).host == 'commons.wikimedia.org' ){
 113+ apiProvider = 'commons'
 114+ } else {
 115+ // xxx we need to abstract the remoteSearch driver provider logic
 116+ // into a provider class
 117+ apiProvider = 'local';
 118+ }
 119+ // Get template smilClip:
 120+ var smilClip = _this
 121+ .sequencer
 122+ .getAddMedia()
 123+ .getSmilClipFromWikiTemplate( titleKey, apiProvider );
 124+
 125+ // Add the smil clip to the sequencer
 126+ _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
 127+
 128+ // Close the dialog loading:
 129+ mw.closeLoaderDialog();
 130+
 131+ /*
 132+ * Soon sequence transclution fun:
 133+ * else if( titleKey.indexOf('Sequence:') == 0 ) {
 134+ */
 135+
 136+ } else {
 137+ $dialog.html( 'Error loading asset type');
 138+ }
 139+
 140+ });
 141+ } else {
 142+ mw.log(" only MediaWiki URLs supported as resources right now");
 143+ }
 144+ }
 145+ });
 146+
 147+ if( ! foundImportUrl ){
 148+ $dialog.html( gM('mwe-sequencer-import-url-not-supported', 'commons.wikimedia.org' ) );
 149+ }
 150+
 151+ // xxx support direct asset include
 152+ if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
 153+ // try directly adding the asset
 154+ }
 155+ }
 156+};
 157+
 158+} )( window.mw );
\ No newline at end of file

Status & tagging log