From f69534d68186d8f883c085c246f2dd3262cceb30 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 9 Oct 2009 21:12:41 +0000 Subject: [PATCH] * some upload from remote api improvements * some playback fixes for native embed * loading dialog helpers in core --- .../libAddMedia/mvBaseUploadInterface.js | 4 +- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 197 +++++++++++------- .../searchLibs/archiveOrgSearch.js | 10 +- .../libAddMedia/searchLibs/metavidSearch.js | 4 +- js2/mwEmbed/libEmbedVideo/embedVideo.js | 18 +- js2/mwEmbed/libEmbedVideo/nativeEmbed.js | 15 +- js2/mwEmbed/mv_embed.js | 37 +++- js2/mwEmbed/skins/ctrlBuilder.js | 2 +- 8 files changed, 188 insertions(+), 99 deletions(-) diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index 8b37466396..758f836cba 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -303,10 +303,12 @@ mvBaseUploadInterface.prototype = { }, doHttpUpload:function( opt ){ var _this = this; + //make sure to display the progress win: + _this.dispProgressOverlay(); //set the http box to loading (in case we don't get an update for some time) $j('#dlbox-centered').html( '
' + _this.getProgressTitle() + '
' + mv_get_loading_img( 'left:40%;top:20%') - ); + ); //setup request: var req = { 'action' : 'upload', diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 37bfe8d671..8b18a69674 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -44,7 +44,9 @@ loadGM({ "mwe-update_preview" : "Update preview", "mwe-cancel_import" : "Cancel import", "mwe-importing_asset" : "Importing asset", - "mwe-preview_insert_resource" : "Preview insert of resource: $1" + "mwe-preview_insert_resource" : "Preview insert of resource: $1", + "mwe-checking-resource": "Checking for resource", + "mwe-resource-needs-import": "Resource $1 needs to be imported" }); var default_remote_search_options = { @@ -154,6 +156,9 @@ remoteSearchDriver.prototype = { 'api_url':'http://commons.wikimedia.org/w/api.php', 'lib' :'mediaWiki', 'resource_prefix': 'WC_', //prefix on imported resources (not applicable if the repository is local) + + //if we should check for shared repository asset ( generally only applicable to commons ) + 'check_shared':true, //list all the domains where commons is local? // probably should set this some other way by doing an api query @@ -949,7 +954,7 @@ remoteSearchDriver.prototype = { //get a thumb with proper resolution transform if possible: o+=''; //add a linkback to resource page in upper right: if( rItem.link ) @@ -994,7 +999,7 @@ remoteSearchDriver.prototype = { var _this = this; $j('.mv_clip_'+_this.result_display_mode+'_result').hover(function(){ $j(this).addClass('mv_clip_'+_this.result_display_mode+'_result_over'); - //also set the animated image if avaliable + //also set the animated image if available var res_id = $j(this).children('.rsd_res_item').attr('id'); var rObj = _this.getResourceFromId( res_id ); if( rObj.poster_ani ) @@ -1022,14 +1027,14 @@ remoteSearchDriver.prototype = { //add the edit layout window with loading place holders $j( _this.target_container ).append('
' + - '
' + - mv_get_loading_img('position:absolute;top:30px;left:30px') + - '
'+ '
'+ + 'left:2px;top:5px;bottom:10px;width:' + ( maxWidth + 5 ) + 'px;overflow:auto;padding:5px;">'+ mv_get_loading_img() + '
'+ + '
' + - '

Resource: ' + rObj.title + ' needs to be imported

'+ + '

' + gM('mwe-resource-needs-import', rObj.title) + '

' + '
' + - rObj.pSobj.getEmbedHTML( rObj, {'id': _this.target_container + '_rsd_pv_vid', 'max_height':'200','only_poster':true} )+ //get embedHTML with small thumb: + rObj.pSobj.getEmbedHTML( rObj, { + 'id': _this.target_container + '_rsd_pv_vid', + 'max_height':'220', + 'only_poster':true + }) + //get embedHTML with small thumb: '
'+ ''+gM('mwe-resource_page_desc') +''+ '
'+ @@ -1352,20 +1395,20 @@ remoteSearchDriver.prototype = { $j.btnHtml(gM('mwe-cancel_import'), 'rsd_import_acancel', 'close' ) + ' ' + '
'+ - //output the rendered and non-renderd version of description for easy swiching: + //output the rendered and non-rendered version of description for easy switching: '
'); //add hover: - //update video tag - rewrite_by_id(_this.target_container + '_rsd_pv_vid'); + + //update video tag (if a video) + rewrite_by_id( _this.target_container + '_rsd_pv_vid'); + //load the preview text: _this.getParsedWikiText( wt, _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ $j('#rsd_import_desc').html(o); }); //add bindings: $j( _this.target_container + ' .rsd_import_apreview').btnBind().click(function(){ - /*$j('#rsd_import_desc').show().html( - mv_get_loading_img() - );*/ + js_log("do preview asset"); //load the preview text: _this.getParsedWikiText( $j('#rsd_import_ta').val(), _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ js_log('got updated preivew: '); @@ -1373,9 +1416,10 @@ remoteSearchDriver.prototype = { }); }); $j(_this.target_container + ' .rsd_import_doimport').btnBind().click(function(){ - //check import mode: - if( _this.import_url_mode=='api'){ - _this.doImportAPI( rObj , cir_callback); + js_log("do import asset:" + _this.import_url_mode); + //check import mode: + if( _this.import_url_mode == 'api' ){ + _this.doImportAPI( rObj , callback); }else{ js_log("Error: import mode is not form or API (can not copy asset)"); } @@ -1387,6 +1431,7 @@ remoteSearchDriver.prototype = { }); }, checkForFile:function( fName, callback){ + js_log("checkForFile::"); var _this = this; reqObj={ 'action':'query', @@ -1400,27 +1445,34 @@ remoteSearchDriver.prototype = { 'data':reqObj, 'url':this.local_wiki_api_url },function(data){ - var found_title = false; - for(var i in data.query.pages){ - js_log('found title: ' + i + ':' + data.query.pages[i]['title']); - found_title = data.query.pages[i]['title']; - } - if( found_title ){ - callback( data.query.pages[i] ); - }else{ - callback( false ); + if( data.query.pages ){ + for(var i in data.query.pages){ + for(var j in data.query.pages[i]){ + if(j == 'missing' && data.query.pages[i].imagerepository != 'shared'){ + js_log(fName + " not found"); + callback( false ); + return ; + } + } + //else page is found: + js_log(fName + " found"); + callback( data.query.pages[i] ); + } } } ); }, doImportAPI:function(rObj, cir_callback){ var _this = this; + js_log(":doImportAPI:"); + $j.addLoaderDialog( gM('mwe-importing_asset') ); //baseUploadInterface mvJsLoader.doLoad([ 'mvBaseUploadInterface', '$j.ui.progressbar' ],function(){ - //initiate a download similar to url copy: + js_log('mvBaseUploadInterface ready'); + //initiate a upload object ( similar to url copy ): myUp = new mvBaseUploadInterface({ 'api_url' : _this.local_wiki_api_url, 'done_upload_cb':function(){ @@ -1433,9 +1485,13 @@ remoteSearchDriver.prototype = { return cir_callback(); } }); - //set the edit token if we have it handy + //get the edit token if we have it handy _this.getEditToken(function( token ){ myUp.etoken = token; + + //close the loader now that we are ready to present the progress dialog:: + $j.closeLoaderDialog(); + myUp.doHttpUpload({ 'url' : rObj.src, 'filename' : rObj.target_resource_title, @@ -1468,7 +1524,7 @@ remoteSearchDriver.prototype = { this.checkImportResource( rObj, function(){ //put another window ontop: $j( _this.target_container ).append('
' + + 'style="position:absolute;overflow:hidden;z-index:4;top:0px;bottom:0px;right:0px;left:0px;background-color:#FFF;">' + mv_get_loading_img('top:30px;left:30px') + '
'); @@ -1553,7 +1609,8 @@ remoteSearchDriver.prototype = { if(_this.target_render_area && _this.cur_embed_code){ //output with some padding: $j(_this.target_render_area).append( _this.cur_embed_code + '
') - //update if its video or audio: + + //update the player if video or audio: if( rObj.mime.indexOf('audio')!=-1 || rObj.mime.indexOf('video')!=-1 || rObj.mime.indexOf('/ogg') !=-1){ diff --git a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js index 2829c5553f..02bbaa745d 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js @@ -57,7 +57,7 @@ archiveOrgSearch.prototype = { //set result info: this.num_results = data.response.numFound; - for(var resource_id in data.response.docs){ + for(var resource_id in data.response.docs){ var resource = data.response.docs[resource_id]; var rObj = { //@@todo we should add .ogv or oga if video or audio: @@ -89,13 +89,15 @@ archiveOrgSearch.prototype = { } } }, + //getTitleKey:function(rObj){ + // return rObj['stream_name'] + '__' + rObj['start_time'].replace(/:/g,'.') + '_to_' + rObj['end_time'].replace(/:/g,'.') + '.ogg';; + //} getEmbedTimeMeta:function(rObj, callback){ var _this = this; do_api_req( { 'data':{'avinfo':1}, - 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' - },function(data){ - var cat = data; + 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' + },function(data){ if(data['length']) rObj.duration = data['length']; if(data['width']) diff --git a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js index a8c8d3986e..43862e92df 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js @@ -64,14 +64,14 @@ metavidSearch.prototype = { rObj['titleKey'] = _this.getTitleKey( rObj ); //default width of metavid clips: - rObj['target_width'] = 400; + rObj['target_width'] = 400; } //done loading: _this.loading=0; }); }, getTitleKey:function( rObj ){ - return rObj['stream_name'] + '_start-' + rObj['start_time'].replace(/:/g,'.') + '_end-' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; + return rObj['stream_name'] + '_part_' + rObj['start_time'].replace(/:/g,'.') + '_to_' + rObj['end_time'].replace(/:/g,'.') + '.ogv'; }, getTitle:function( rObj ){ var sn = rObj['stream_name'].replace(/_/g, ' '); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index bddf73bbc9..641d256eed 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -119,18 +119,18 @@ _global['dismissNativeWarn'] = false; * Converts all occurrences of