From 7fe7db84f33ace213f832010e0fe03cc805ef1fd Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Sat, 21 Nov 2009 18:45:30 +0000 Subject: [PATCH] * fixed audio vs video display height in remoteMwEmbed rewrite * added kskin "credits" page. * set "kskin" to default skin for remoteMwEmbed rewrite * setup global config inheritance for mv_embed.js * finished Tim's renaming of bObj to buttons * some refactoring, function naming updates, and comment clarity improvements --- .../example_usage/Player_RelatedVideos.html | 8 +- .../libAddMedia/mvBaseUploadInterface.js | 12 +- js2/mwEmbed/libAddMedia/mvFirefogg.js | 14 +- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 15 +- .../searchLibs/archiveOrgSearch.js | 61 +++-- .../searchLibs/baseRemoteSearch.js | 141 +++++++--- .../libAddMedia/searchLibs/mediaWikiSearch.js | 51 ++-- .../libAddMedia/searchLibs/metavidSearch.js | 29 +-- js2/mwEmbed/libEmbedVideo/embedVideo.js | 21 +- js2/mwEmbed/libEmbedVideo/vlcEmbed.js | 25 +- js2/mwEmbed/libMwApi/mw.proxy.js | 117 +++++---- js2/mwEmbed/libSequencer/mvFirefoggRender.js | 36 +-- js2/mwEmbed/libSequencer/mvPlayList.js | 8 +- js2/mwEmbed/libSequencer/mvSequencer.js | 243 ++++++++++++------ js2/mwEmbed/mv_embed.js | 75 ++---- js2/mwEmbed/php/languages/mwEmbed.i18n.php | 5 + js2/mwEmbed/skins/ctrlBuilder.js | 8 +- js2/mwEmbed/skins/kskin/kskin.js | 121 ++++++++- js2/mwEmbed/skins/kskin/playerSkin.css | 30 ++- js2/mwEmbed/tests/testLang.html | 8 +- js2/remoteMwEmbed.js | 55 ++-- 21 files changed, 685 insertions(+), 398 deletions(-) diff --git a/js2/mwEmbed/example_usage/Player_RelatedVideos.html b/js2/mwEmbed/example_usage/Player_RelatedVideos.html index f36522512e..26f5180733 100644 --- a/js2/mwEmbed/example_usage/Player_RelatedVideos.html +++ b/js2/mwEmbed/example_usage/Player_RelatedVideos.html @@ -6,16 +6,16 @@ -

Simple Video Relational Audio and Video the Commons

-This Example search primitive video in the Wikimedia Commons +

Related Videos

+

- +
- Sample Relational Video And Audio
+
Sample Related Videos
The Example Code ::: 
<video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index d9c01d7415..9833d54ee8 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -734,7 +734,7 @@ mvBaseUploadInterface.prototype = { } }; // Create the "return to form" button - bObj[ gM( 'mwe-return-to-form' ) ] = function() { + buttons[ gM( 'mwe-return-to-form' ) ] = function() { $j( this ).dialog( 'close' ); _this.form_post_override = false; } @@ -742,7 +742,7 @@ mvBaseUploadInterface.prototype = { _this.updateProgressWin( gM( 'mwe-uploadwarning' ), '

' + gM( 'mwe-uploadwarning' ) + '

' + wmsg + '

', - bObj ); + buttons ); return false; } // No error! @@ -783,21 +783,21 @@ mvBaseUploadInterface.prototype = { return false; } - var bObj = {}; + var buttons = {}; // "Return" button - bObj[ gM( 'mwe-return-to-form' ) ] = function() { + buttons[ gM( 'mwe-return-to-form' ) ] = function() { $j( this ).dialog( 'close' ); _this.form_post_override = false; } // "Go to resource" button - bObj[ gM('mwe-go-to-resource') ] = function() { + buttons[ gM('mwe-go-to-resource') ] = function() { window.location = url; }; _this.action_done = true; _this.updateProgressWin( gM( 'mwe-successfulupload' ), gM( 'mwe-upload_done', url), - bObj ); + buttons ); js_log( 'apiRes.upload.imageinfo::' + url ); return true; } diff --git a/js2/mwEmbed/libAddMedia/mvFirefogg.js b/js2/mwEmbed/libAddMedia/mvFirefogg.js index 3d532bd601..4149093a77 100644 --- a/js2/mwEmbed/libAddMedia/mvFirefogg.js +++ b/js2/mwEmbed/libAddMedia/mvFirefogg.js @@ -282,13 +282,15 @@ mvFirefogg.prototype = { // extends mvBaseUploadInterface return; } - // Otherwise show the "install Firefogg" message - // FIXME: getFirefoggInstallUrl() may return false, this is not handled + // Otherwise show the "install Firefogg" message var upMsg = ( _this.form_type == 'upload' ) ? gM( 'fogg-for_improved_uploads' ) : ''; - $j( _this.target_please_install ) - .html( upMsg + gM( 'fogg-please_install', _this.getFirefoggInstallUrl() ) ) - .css( 'padding', '10px' ) - .show(); + var firefoggUrl = _this.getFirefoggInstallUrl(); + if( firefoggUrl ){ + $j( _this.target_please_install ) + .html( upMsg + gM( 'fogg-please_install', firefoggUrl ) ) + .css( 'padding', '10px' ) + .show(); + } } // Set up the click handler for the "save local file" button diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 0154c629ec..49f17711a3 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -1271,7 +1271,7 @@ remoteSearchDriver.prototype = { js_log( 'media type:: ' + mediaType ); // Get any additional embedding helper meta data prior to doing the actual embed // normally this meta should be provided in the search result (but archive.org has another query for more media meta) - rObj.pSobj.getEmbedTimeMeta( rObj, function() { + rObj.pSobj.addResourceInfoCallback( rObj, function() { // Make sure we have the embedVideo libs: var runFlag = false; mvJsLoader.embedVideoCheck( function() { @@ -1292,13 +1292,14 @@ remoteSearchDriver.prototype = { js_log( "about to call rewrite_by_id::embed_vid" ); // Rewrite by id rewrite_by_id( 'embed_vid', function() { - // Grab any information that we got from the ROE xml or parsed from the media file - rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' ); + // Grab information avaliable from the embed instance + rObj.pSobj.addResourceInfoFromEmbedInstance( rObj, 'embed_vid' ); + // Add the re-sizable to the doLoad request: clibs.push( '$j.ui.resizable' ); - clibs.push( '$j.fn.hoverIntent' ); + clibs.push( '$j.fn.hoverIntent' ); mvJsLoader.doLoad( clibs, function() { - // Make sure the rsd_edit_img is hidden: + // Make sure the rsd_edit_img is removed: $j( '#rsd_edit_img' ).remove(); // Run the image clip tools _this.cEdit = new mvClipEdit( mvClipInit ); @@ -1390,9 +1391,7 @@ remoteSearchDriver.prototype = { }, doImportInterface : function( rObj, callback ) { var _this = this; - js_log( "doImportInterface:: update:" + _this.cFileNS + ':' + rObj.target_resource_title ); - // update the rObj with import info - rObj.pSobj.updateDataForImport( rObj ); + js_log( "doImportInterface:: update:" + _this.cFileNS + ':' + rObj.target_resource_title ); // setup the resource description from resource description: var wt = '{{Information ' + "\n"; diff --git a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js index ab179005cc..78ceee1be1 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js @@ -1,17 +1,24 @@ -// archive.org uses solr engine: -// more about solr here: -// http://lucene.apache.org/solr/ +/* +* Archive.org Search +* +* archive.org uses the solr engine: +* more about solr here: +* http://lucene.apache.org/solr/ +*/ var archiveOrgSearch = function ( iObj ) { return this.init( iObj ); } archiveOrgSearch.prototype = { // Archive.org constants: - dnUrl:'http://www.archive.org/download/', - dtUrl:'http://www.archive.org/details/', - init:function( iObj ) { - // Init base class and inherit: - var baseSearch = new baseRemoteSearch( iObj ); + downloadUrl : 'http://www.archive.org/download/', + detailsUrl : 'http://www.archive.org/details/', + /* + * Inititalize the archiveOrgSearch class. + * archiveOrgSearch inherits the baseSearch class + */ + init:function( options ) { + var baseSearch = new baseRemoteSearch( options ); for ( var i in baseSearch ) { if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; @@ -19,8 +26,10 @@ archiveOrgSearch.prototype = { this['parent_' + i] = baseSearch[i]; } } - // Inherit the cp settings for }, + /** + * Gets the search results from the api query + */ getSearchResults:function() { // call parent: this.parent_getSearchResults(); @@ -49,10 +58,13 @@ archiveOrgSearch.prototype = { } ); }, + /** + * Adds the search results to the local resultsObj + */ addResults:function( data ) { var _this = this; if ( data.response && data.response.docs ) { - // set result info: + // Set result info: this.num_results = data.response.numFound; for ( var resource_id in data.response.docs ) { @@ -61,17 +73,17 @@ archiveOrgSearch.prototype = { // @@todo we should add .ogv or oga if video or audio: 'titleKey' : resource.identifier + '.ogg', 'resourceKey': resource.identifier, - 'link' : _this.dtUrl + resource.identifier, + 'link' : _this.detailsUrl + resource.identifier, 'title' : resource.title, - 'poster' : _this.dnUrl + resource.identifier + '/format=thumbnail', - 'poster_ani' : _this.dnUrl + resource.identifier + '/format=Animated+Gif', + 'poster' : _this.downloadUrl + resource.identifier + '/format=thumbnail', + 'poster_ani' : _this.downloadUrl + resource.identifier + '/format=Animated+Gif', 'thumbwidth' : 160, 'thumbheight': 110, 'desc' : resource.description, - 'src' : _this.dnUrl + resource.identifier + '/format=Ogg+video', - 'mime' : 'application/ogg', - // set the license: (rsd is a pointer to the parent remoteSearchDriver ) - 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ), + 'src' : _this.downloadUrl + resource.identifier + '/format=Ogg+video', + 'mime' : 'application/ogg', + // Set the license: (rsd is a pointer to the parent remoteSearchDriver ) + 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ), 'pSobj' :_this }; @@ -79,14 +91,14 @@ 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 ) { + /** + * Gets some media metadata via a archive.org special entry point "avinfo" + */ + addResourceInfoCallback:function( rObj, callback ) { var _this = this; do_api_req( { - 'data': { 'avinfo':1 }, - 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' + 'data': { 'avinfo' : 1 }, + 'url':_this.downloadUrl + rObj.resourceKey + '/format=Ogg+video' }, function( data ) { if ( data['length'] ) rObj.duration = data['length']; @@ -98,6 +110,9 @@ archiveOrgSearch.prototype = { callback(); } ); }, + /* + * Returns html to embed a given result Object ( rObj ) + */ getEmbedHTML: function( rObj , options ) { js_log( 'getEmbedHTML:: ' + rObj.poster ); if ( !options ) diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 969ab76aad..24398b511a 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -1,16 +1,26 @@ -// base remote search obj - +/* +* Base remote search Object. +* provies the base class for the other search system to extend. +*/ loadGM( { "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information." } ) -// @key is name of rObj variable -// @value is where to find the value in the item xml -// -// *format:* -// . indicates multiple tags @ separates the tag from attribute list -// {.}tag_name@{attribute1|attribute12} -// @@todo should probably switch this over to something like Xpath if we end up parsing a lot of rss formats +/* +* rsd_default_rss_item_mapping +* +* @key is name of rObj variable +* @value is where to find the value in the item xml +* +* *value format:* +* . indicates multiple tags +* @ separates the tag from attribute list +* {.}tag_name@{attribute1|attribute2} +* +* Also see mapAttributeToResource function bellow +* +* FIXME should switch this over to something like Xpath if we end up parsing a lot of rss formats +*/ var rsd_default_rss_item_mapping = { 'poster' : 'media:thumbnail@url', 'roe_url' : 'media:roe_embed@url', @@ -31,36 +41,41 @@ baseRemoteSearch.prototype = { completed_req:0, num_req:0, - + + // ResultsObj holds the array of results resultsObj: { }, - // default search result values for paging: + // Default search result values for paging: offset :0, limit : 30, more_results : false, num_results : 0, - // init the object: - init: function( iObj ) { + /** + * Initialise the baseRemoteSearch + */ + init: function( options ) { js_log( 'mvBaseRemoteSearch:init' ); - for ( var i in iObj ) { - this[i] = iObj[i]; + for ( var i in options ) { + this[i] = options[i]; } return this; }, getSearchResults:function() { - // empty out the current results before issuing a request + // Empty out the current results before issuing a request this.resultsObj = { }; - // do global getSearchResults bindings + + // Do global getSearchResults bindings this.last_query = $j( '#rsd_q' ).val(); this.last_offset = this.cp.offset; - // set the loading flag: + + // Set the loading flag: this.loading = true; }, /* * Parses and adds video rss based input format - * @param $data XML data to parse - * @param provider_url the source url (used to generate absolute links) + * @param {XML Nodes} data the data to be parsed + * @param {String} provider_url the source url (used to generate absolute links) */ addRSSData:function( data , provider_url ) { js_log( 'f:addRSSData' ); @@ -102,7 +117,15 @@ baseRemoteSearch.prototype = { _this.num_results++; } ); }, - mapAttributeToResource: function(rObj, item, attr){ + /* + * Maps a given attribute to a resource object per mapping defined in + * rsd_default_rss_item_mapping + * + * @param {Object} rObj the resource object + * @param {XML Node} the xml result node + * @param {attr} the name attribute we are maping to the resource object + */ + mapAttributeToResource: function( rObj, item, attr ){ var selector = rsd_default_rss_item_mapping[ attr ].split( '@' ); var flag_multiple = ( selector[0].substr( 0, 1 ) == '.' ) ? true : false; if ( flag_multiple ) { @@ -147,6 +170,10 @@ baseRemoteSearch.prototype = { } ); // Nothing to return we update the "rObj" directly }, + + /** + * Get the html representation of the resource Object paramater + */ getEmbedHTML: function( rObj , options ) { if ( !options ) options = { }; @@ -185,6 +212,9 @@ baseRemoteSearch.prototype = { js_log( "ERROR:: no embed code for mime type: " + rObj.mime ); return 'Error missing embed code for: ' + escape( rObj.mime ); }, + /** + * Get the embed html specificaly for an image type resource Object. + */ getImageEmbedHTML:function( rObj, options ) { // if crop is null do base output: var imgHtml = ''; @@ -197,13 +227,22 @@ baseRemoteSearch.prototype = { '' + ''; }, - // by default just return the existing image with callback + /** + * Gets an image object from a requested transformation via callback + * ( letting api search implementations query the remote server for a + * given transformation ) + * + * By default just return the existing image. + */ getImageObj:function( rObj, size, callback ) { callback( { 'url' : rObj.poster } ); }, - // by default just return the rObj.desc + /* + * Gets the inline wikiText description of the resource Object + * By default just return the rObj description value + */ getInlineDescWiki:function( rObj ) { // return striped html & trim white space if ( rObj.desc ) @@ -211,11 +250,21 @@ baseRemoteSearch.prototype = { // no desc avaliable: return ''; }, - // default license permission wiki text is cc based template mapping (does not confirm the templates actually exist) + /** + * Get the licence wikiText tag for a given resource Object. + * + * By default license permission wiki text is cc based template mapping + * (does not confirm the templates actually exist) + */ getPermissionWikiTag: function( rObj ) { if ( !rObj.license ) return '';// no license info - // check that its a defined creative commons licnese key: + + // First check if we have a special license template tag already set: + if( rObj.license_template_tag ) + return '{{' + rObj.license_template_tag + '}}'; + + // Check that its a defined creative commons license key: if ( this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ) { return '{{Cc-' + rObj.license.key + '}}'; } else if ( rObj.license.lurl ) { @@ -223,23 +272,51 @@ baseRemoteSearch.prototype = { } }, + /** + * Gets the resource import description text + */ getImportResourceDescWiki:function( rObj ) { return gM( 'mwe-imported_from', [rObj.title, this.cp.homepage, gM('rsd-' + this.cp.id + '-title'), rObj.link] ); }, - // for thigns like categories and the like + /** + * Get any extra wikitext description for the given resource object. + * For content outside of the main template description, + * like categories or additional wikitext notes. + * + * By default its an empty string. + */ getExtraResourceDescWiki:function( rObj ) { return ''; }, - // by default just return the poster (clients can override) + + /** + * Gets a image transformation + * by default it just return the poster + */ getImageTransform:function( rObj, opt ) { return rObj.poster; }, - getEmbedObjParsedInfo:function( rObj, eb_id ) { + + /** + * Adds additional resource information post clip embedding. + */ + addResourceInfoFromEmbedInstance : function( rObj, eb_id ) { return rObj; }, - getEmbedTimeMeta:function( rObj, callback ) { + + /** + * Adds resource info with a callback function + * + * Usefull for grabbing extra info that is not avaliable in the innitial + * search results api request. + */ + addResourceInfoCallback:function( rObj, callback ) { callback(); }, + + /** + * Get the wiki embed code for a given resource object + */ getEmbedWikiCode:function( rObj ) { var layout = ( rObj.layout ) ? rObj.layout:"right" var o = '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|' + layout; @@ -257,11 +334,11 @@ baseRemoteSearch.prototype = { o += ']]'; return o; }, + /** + * Updates / normalizes the target_resource_title + */ updateTargetResourceTitle:function( rObj ) { rObj.target_resource_title = rObj.titleKey.replace( / File: | Image: / , '' ); rObj.target_resource_title = this.cp.resource_prefix + rObj.target_resource_title; - }, - updateDataForImport:function( rObj ) { - return rObj; } } diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index 7de90cd6d2..583fbc82c1 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -110,15 +110,15 @@ mediaWikiSearch.prototype = { } ); }, getSearchResults:function() { - // call parent: + // Call parent: this.parent_getSearchResults(); - // set local ref: + // Set local ref: var _this = this; js_log( 'f:getSearchResults for:' + $j( '#rsd_q' ).val() ); - // do two queries against the Image / File / MVD namespace: + // Do two queries against the Image / File / MVD namespace: - // build the image request object: + // Build the image request object: var reqObj = { 'action':'query', 'generator':'search', @@ -132,11 +132,11 @@ mediaWikiSearch.prototype = { 'iiurlwidth': parseInt( this.rsd.thumb_width ), 'rvprop':'content' }; - // set up the number of request: + // Set up the number of request: this.completed_req = 0; this.num_req = 1; - // setup the number of requests result flag: - // also do a request for page titles (would be nice if api could query both at the same time) + // Setup the number of requests result flag: + // Also do a request for page titles (would be nice if api could query both at the same time) reqObj['gsrwhat'] = 'text'; do_api_req( { 'data':reqObj, @@ -161,24 +161,24 @@ mediaWikiSearch.prototype = { if ( typeof data['query-continue'].search != 'undefined' ) this.more_results = true; } - // make sure we have pages to idorate: + // Make sure we have pages to idorate: if ( data.query && data.query.pages ) { for ( var page_id in data.query.pages ) { var page = data.query.pages[ page_id ]; - // make sure the reop is shared (don't show for now it confusing things) + // Make sure the reop is shared (don't show for now it confusing things) // @@todo support remote repository better if ( page.imagerepository == 'shared' ) { continue; } - // make sure the page is not a redirect + // Make sure the page is not a redirect if ( page.revisions && page.revisions[0] && page.revisions[0]['*'] && page.revisions[0]['*'].indexOf( '#REDIRECT' ) === 0 ) { // skip page is redirect continue; } - // skip if its an empty or missing imageinfo: + // Skip if its an empty or missing imageinfo: if ( !page.imageinfo ) continue; var rObj = { @@ -204,10 +204,11 @@ mediaWikiSearch.prototype = { //to use once we get the wiki-text parser in shape var pObj = mw.parser.pNew( rObj.desc ); //structured data on commons is based on the "information" template: - var tmplInfo = pObj.templates( 'information' ); + var tmplInfo = pObj.templates( 'information' ); + rObj.desc = tmplInfo.description */ - // attempt to parse out the description current user desc from the commons template: + // Attempt to parse out the description current user desc from the commons template: // @@todo these could be combined to a single regEx // or better improve the wiki-text parsing and use above var desc = rObj.desc.match( /\|\s*description\s*=\s*(([^\n]*\n)*)\|\s*source=/i ); @@ -231,15 +232,15 @@ mediaWikiSearch.prototype = { } } - // likely a audio clip if no poster and type application/ogg + // Likely a audio clip if no poster and type application/ogg // @@todo we should return audio/ogg for the mime type or some other way to specify its "audio" if ( ! rObj.poster && rObj.mime == 'application/ogg' ) { rObj.mime = 'audio/ogg'; } - // add to the resultObj + // Add to the resultObj this.resultsObj[page_id] = rObj; - // if returnFirst flag: + // If returnFirst flag: if ( returnFirst ) return this.resultsObj[page_id]; @@ -253,9 +254,9 @@ mediaWikiSearch.prototype = { js_log( 'no results:' + data ); } }, - // check request done used for when we have multiple requests to check before formating results. + // Check request done used for when we have multiple requests to check before formating results. checkRequestDone:function() { - // display output if done: + // Display output if done: this.completed_req++; if ( this.completed_req == this.num_req ) { this.loading = 0; @@ -265,7 +266,7 @@ mediaWikiSearch.prototype = { if ( rObj.mime == 'application/ogg' ) return callback( { 'url':rObj.src, 'poster' : rObj.url } ); - // his could be depreciated if thumb.php improves + // This could be depreciated if thumb.php support is standard var reqObj = { 'action':'query', 'format':'json', @@ -273,7 +274,7 @@ mediaWikiSearch.prototype = { 'prop':'imageinfo', 'iiprop':'url|size|mime' } - // set the width: + // Set the width: if ( size.width ) reqObj['iiurlwidth'] = size.width; js_log( 'going to do req: ' + this.cp.api_url + ' ' + reqObj ); @@ -310,10 +311,10 @@ mediaWikiSearch.prototype = { getInlineDescWiki:function( rObj ) { var desc = this.parent_getInlineDescWiki( rObj ); - // strip categories for inline Desc: (should strip license tags too but not as easy) + // Strip categories for inline Desc: (should strip license tags too but not as easy) desc = desc.replace( /\[\[Category\:[^\]]*\]\]/gi, '' ); - // just grab the description tag for inline desc: + // Just grab the description tag for inline desc: var descMatch = new RegExp( /Description=(\{\{en\|)?([^|]*|)/ ); var dparts = desc.match( descMatch ); @@ -333,14 +334,14 @@ mediaWikiSearch.prototype = { js_log( 'Error: No Description Tag, Using::' + desc ); return desc; }, - // returns the inline wikitext for insertion (template based crops for now) + // Returns the inline wikitext for insertion (template based crops for now) getEmbedWikiCode: function( rObj ) { - // set default layout to right justified + // Set default layout to right justified var layout = ( rObj.layout ) ? rObj.layout:"right" // if crop is null do base output: if ( rObj.crop == null ) return this.parent_getEmbedWikiCode( rObj ); - // using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop + // Using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop // @@todo should be replaced with server side cropping return '{{Preview Crop ' + "\n" + '|Image = ' + rObj.target_resource_title + "\n" + diff --git a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js index 2f141d8894..135ca5512c 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js @@ -73,6 +73,15 @@ metavidSearch.prototype = { // Default width of metavid clips: rObj['target_width'] = 400; + + rObj['author'] = 'US Government'; + + // Add in the date as UTC "toDateString" : + var d = _this.getDateFromLink( rObj.link ); + rObj['date'] = d.toDateString(); + + // Set the license_template_tag ( all metavid content is PD-USGov ) + rObj['license_template_tag'] = 'PD-USGov'; } // done loading: _this.loading = 0; @@ -89,10 +98,6 @@ metavidSearch.prototype = { sn = sn.charAt( 0 ).toUpperCase() + sn.substr( 1 ); return gM( 'mwe-stream_title', [ sn, rObj.start_time, rObj.end_time ] ); }, - // metavid descption tied to public domain license key (government produced content) - getPermissionWikiTag:function( rObj ) { - return '{{PD-USGov}}'; - }, getExtraResourceDescWiki:function( rObj ) { var o = "\n"; // check for person @@ -180,8 +185,8 @@ metavidSearch.prototype = { return getURLParamReplace( rObj.poster, { 'size' : 'full' } ) } }, - getEmbedObjParsedInfo:function( rObj, eb_id ) { - var sources = $j( '#' + eb_id ).get( 0 ).media_element.getSources(); + addResourceInfoFromEmbedInstance : function( rObj, embed_id ) { + var sources = $j( '#' + embed_id ).get( 0 ).media_element.getSources(); rObj.other_versions = '*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]' + "\n"; for ( var i in sources ) { var cur_source = sources[i]; @@ -192,18 +197,6 @@ metavidSearch.prototype = { // js_log('set url to: ' + rObj['url']); return rObj; }, - // update rObj for import: - updateDataForImport:function( rObj ) { - rObj['author'] = 'US Government'; - // convert data to UTC type date: - var d = this.getDateFromLink( rObj.link ); - rObj['date'] = d.toDateString(); - rObj['license_template_tag'] = 'PD-USGov'; - // update based on new start time: - js_log( 'url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time ); - - return rObj; - }, getDateFromLink:function( link ) { var dateExp = new RegExp( /_([0-9]+)\-([0-9]+)\-([0-9]+)/ ); var dParts = link.match ( dateExp ); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index 12b88f9492..a4df8a7307 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -909,8 +909,11 @@ embedVideo.prototype = { var dcss = parseInt( $j(element).css( dim ).replace( 'px' , '' ) ); var dattr = parseInt( $j(element).attr( dim ) ); this[ dim ] = ( dcss )? dcss : dattr; - if(!this[ dim ]){ - // Grab width/height from default value + if( !this[ dim ] ){ + //special height default for audio tag: + if( element.tagName.toLowerCase() == 'audio' && dim == 'height' ) + return this[ dim ] = 0; + // Grab width/height from default value (for video) var dwh = mw.conf['video_size'].split( 'x' ); this[ dim ] = ( dim == 'width' )? dwh[0] : dwh[1]; } @@ -1868,7 +1871,7 @@ embedVideo.prototype = { } ); return false; // onclick action return false }, - showPlayerselect:function( $target ) { + showPlayerselect:function( $target ) { // Get id (in case where we have a parent container) var this_id = ( this.pc != null ) ? this.pc.pp.id:this.id; var _this = this; @@ -1949,9 +1952,9 @@ embedVideo.prototype = { } ); if ( dl_list != '' ) - out += gM( 'mwe-download_full' ) + '

' + dl_list + '
'; + out += '

' + gM( 'mwe-download_full' ) + '

    ' + dl_list + '
'; if ( dl_txt_list != '' ) - out += gM( 'mwe-download_text' ) + '
' + dl_txt_list + '
'; + out += '

' +gM( 'mwe-download_text' ) + '

    ' + dl_txt_list + '
'; out += ''; return out; } @@ -1967,9 +1970,6 @@ embedVideo.prototype = { $target.html( getShowVideoDownload() ); } }, - showCredits:function( $target ) { - $target.html( '

' + gM( 'mwe-credits' ) + '

' ); - }, /* * Base embed controls * The Play Action: @@ -2332,10 +2332,11 @@ mediaPlayer.prototype = { return gM( 'mwe-ogg-player-' + this.id ); }, - load : function( callback ) { + load : function( callback ) { mvJsLoader.doLoad( [ this.library + 'Embed' - ], function() { + ], function() { + js_log("wtf: " + typeof( vlcEmbed ) ); callback(); } ); } diff --git a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js index af20394123..6c1fd2499d 100644 --- a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js @@ -4,8 +4,9 @@ * assume version > 0.8.5.1 */ var vlcEmbed = { - instanceOf:'vlcEmbed', - supports: { 'play_head':true, + instanceOf : 'vlcEmbed', + supports : { + 'play_head':true, 'pause':true, 'stop':true, 'fullscreen':true, @@ -260,7 +261,7 @@ var vlcEmbed = { this.parent_stop(); }, pause : function() { - this.parent_pause(); // update the inteface if paused via native control + this.parent_pause(); // update the interface if paused via native control if ( this.vlc ) { this.vlc.playlist.togglePause(); } @@ -271,13 +272,13 @@ var vlcEmbed = { if ( this.vlc ) this.vlc.audio.toggleMute(); }, - // @@ Suport UpDateVolumen + // @@ Support UpDateVolumen updateVolumen:function( perc ) { this.getVLC(); if ( this.vlc ) this.vlc.audio.volume = perc * 100; }, - // @@ Get Volumen + // @@ Get Volumen getVolumen:function() { this.getVLC(); if ( this.vlc ) @@ -288,19 +289,7 @@ var vlcEmbed = { if ( this.vlc.video ) this.vlc.video.toggleFullscreen(); } - }, - /* returns current time in float seconds - * as per html5 we should just have an attribute by name of CurrentTime - * http://www.whatwg.org/specs/web-apps/current-work/#currenttime - currentTime : function(){ - if(typeof this.vlc != 'undefined' ){ - if(typeof this.vlc.input != 'undefined' ){ - return this.vlc.input.time/1000; - } - } - return '0'; - }, - */ + }, // get the embed vlc object getVLC : function() { this.vlc = this.getPluginEmbed(); diff --git a/js2/mwEmbed/libMwApi/mw.proxy.js b/js2/mwEmbed/libMwApi/mw.proxy.js index e513b5b257..c3cd6da032 100644 --- a/js2/mwEmbed/libMwApi/mw.proxy.js +++ b/js2/mwEmbed/libMwApi/mw.proxy.js @@ -2,11 +2,10 @@ * * Api proxy system * -* Built to support cross domain uploading, and api actions for a approved set of domains. -* mwProxy enables a system for fluid contributions across wikis domains for which your logged in. +* Supports cross domain uploading, and api actions for a approved set of domains. * -* The framework support a request approval system for per-user domain approval -* and a central blacklisting of domains controlled by site or system administrators. +* The framework /will/ support a request approval system for per-user domain approval +* and a central blacklisting of domains controlled by the site * * Flow outline below: * @@ -56,34 +55,38 @@ loadGM( { */ $.proxy.client = function( pConf, conf ) { var _this = this; - // do setup: + // Do client setup: if ( pConf.server_frame ) $.proxy.server_frame = pConf.server_frame; if ( pConf.client_frame_path ) { $.proxy.client_frame_path = pConf.client_frame_path; } else { - // guess the client frame path: + // Set to default mwEmbed iframe path: $.proxy.client_frame_path = wgScriptPath + '/js2/mwEmbed/libMwApi/NestedCallbackIframe.html'; } if ( mw.parseUri( $.proxy.server_frame ).host == mw.parseUri( document.URL ).host ) { - js_log( "Error: why are you trying to proxy yourself? " ); + js_log( "Error: trying to proxy local domain? " ); return false; } return true; } - // set the frameProxy Flag: + // Set the frameProxy Flag: var frameProxyOk = false; - /* setup a iframe request hash */ - $.proxy.doFrameProxy = function( reqObj ) { + + /** + * doFrameProxy + * Writes an iframe with a hashed value of the requestQuery + */ + $.proxy.doFrameProxy = function( requestQuery ) { var hashPack = { 'cd': mw.parseUri( document.URL ).host, 'cfp': $.proxy.client_frame_path, - 'req': reqObj + 'req': requestQuery } js_log( "Do frame proxy request on src: \n" + $.proxy.server_frame + "\n" + - JSON.stringify( reqObj ) ); + JSON.stringify( requestQuery ) ); // we can't update src's so we have to remove and add all the time :( // @@todo we should support frame msg system $j( '#frame_proxy' ).remove(); @@ -106,57 +109,70 @@ loadGM( { } var lastApiReq = { }; $.proxy.proxyNotReadyDialog = function() { - var btn = { }; - btn[ gM( 'mwe-re-try' ) ] = function() { + var buttons = { }; + buttons[ gM( 'mwe-re-try' ) ] = function() { $j.addLoaderDialog( gM( 'mwe-re-trying' ) ); $.proxy.doFrameProxy( lastApiReq ); } - btn[ gM( 'mwe-cancel' ) ] = function() { + buttons[ gM( 'mwe-cancel' ) ] = function() { $j.closeLoaderDialog(); } var pUri = mw.parseUri( $.proxy.server_frame ); - // this is sort of a temporary hack if we change the MediaWiki:ApiProxy key - // we will have to deal with that here as well: - var login_url = pUri.protocol + '://' + pUri.host + - pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' ); - $j.addDialog( gM( 'mwe-proxy-not-ready' ), gM( 'mwe-please-login', [ login_url, pUri.host] ) + - '

' + gM( 'mwe-remember-loging' ) + '

', - btn + + // FIXME we should have a Hosted iframe once we deploy mwEmbed on the servers. + // A hosted iframe would be much faster since than a normal page view + + var login_url = pUri.protocol + '://' + pUri.host; + login_url += pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' ); + + $j.addDialog( + gM( 'mwe-proxy-not-ready' ), + gM( 'mwe-please-login', [ login_url, pUri.host] ) + + '

' + + gM( 'mwe-remember-loging' ) + + '

', + buttons ) } - /* the do_api_request with callback: */ - $.proxy.doRequest = function( reqObj, callback ) { + /* + * doRequest + * Takes a requestQuery, executes the query and then calls the callback + */ + $.proxy.doRequest = function( requestQuery, callback ) { js_log( "doRequest:: " + JSON.stringify( reqObj ) ); lastApiReq = reqObj; // setup the callback: $.proxy.callback = callback; // do the proxy req: - $.proxy.doFrameProxy( reqObj ); + $.proxy.doFrameProxy( requestQuery ); } /** - * The nested iframe action that passes its msg back up to the top instance + * The nested iframe action that passes its result back up to the top frame instance */ $.proxy.nested = function( hashResult ) { - // close the loader if present: + // Close the loader if present: $j.closeLoaderDialog(); js_log( '$.proxy.nested callback :: ' + unescape( hashResult ) ); frameProxyOk = true; - // try to parse the hash result: + + // Try to parse the hash result: try { var rObj = JSON.parse( unescape( hashResult ) ); } catch ( e ) { js_log( "Error could not parse hashResult" ); } - // special callback to frameProxyOk flag (not an api result, don't call callback) + + // Special callback to frameProxyOk flag + // (only used to test the proxy connection) if ( rObj.state == 'ok' ) return ; - // if all good pass it to the callback: + // Pass the callback: $.proxy.callback( rObj ); } /** - * The serverApiProxy handles the actual proxy - * and child frames pointing to the parent "blank" frames + * The server handles the actual proxy + * it adds child frames pointing to the parent "blank" frames * * This is (Domain B) in the above described setup */ @@ -180,30 +196,30 @@ loadGM( { ' client from: ' + aObj.cd + ' to nested target: ' + aObj.cfp ); - // make sure we are logged in + // Make sure we are logged in // (its a normal mediaWiki page so all site vars should be defined) if ( !wgUserName ) { - js_log( 'error Not logged in' ); + js_log( 'Error Not logged in' ); return false; } var domain = aObj.cd; var nested_frame_src = 'http://' + aObj.cd + aObj.cfp; - // check the master whitelist + // Check the master whitelist for ( var i in pConf.master_whitelist ) { if ( domain == pConf.master_whitelist[ i ] ) { - // do the request: + // Do the request: return doNestedProxy( aObj.req ); } } - // check master blacklist + // Check master blacklist for ( var i in pConf.master_blacklist ) { if ( domain == pConf.master_blacklist ) { js_log( 'domain: ' + domain + ' is blacklisted' ); return false; } } - // @@todo grab the users whitelist for our current domain + // FIXME grab the users whitelist for our current domain /*var local_api = wgScriptPath + '/index' + wgScriptExtension + '?title=' + 'User:' + wgUserName + '/apiProxyDomainList.js' + '&action=raw&smaxage=0&gen=js'; @@ -214,31 +230,34 @@ loadGM( { // if still not found: js_log( "domain " + domain + " not approved" ); - // offer the user the ability to "approve" requested domain save to their user page + // FIXME :: offer the user the ability to "approve" requested domain save to + // their user/ apiProxyDomainList.js page function doNestedProxy( reqObj ) { js_log( "doNestedProxy to: " + nested_frame_src ); - // output iframe prior to running api request - // (so we can fail faster / cache the nested page / simotaniusly load things) + + // Do a quick response to establish the proxy is working + // ( before we actually run the api-request ) doNestedFrame ( 'nested_ok' , { 'state':'ok' } ); var outputhash = escape( JSON.stringify( reqObj ) ); - // add some api stuff: - reqObj['format'] = 'json'; - // process the api request + + // Add some api stuff: + reqObj[ 'format' ] = 'json'; + + // Process the api request $j.post( wgScriptPath + '/api' + wgScriptExtension, reqObj, - function( data ) { - // js_log("Proxy GOT Res: " + data ); - // put it into the nested frame hash string: + function( data ) { + // Put it into the nested frame hash string: doNestedFrame( 'nested_push', JSON.parse( data ) ); } ); } - // add the doNestedFrame iframe: + // Add the doNestedFrame iframe: function doNestedFrame( nestname, resultObj ) { $j( '#nested_push' ).remove(); - // setup the nested proxy that points back to top domain: + // Setup the nested proxy that points back to top domain: $j( 'body' ).append( '