From e781b8ff1de5f6ee3238191367fe1e6559de3b3b Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Tue, 24 Nov 2009 19:49:52 +0000 Subject: [PATCH] * added remote_insert_description (for adding linkback in html inserts of media) * added stream names for embed video streams. * some comment and variable name cleanup --- js2/README | 3 +- .../example_usage/Add_Media_Wizard.html | 1 + .../searchLibs/baseRemoteSearch.js | 108 ++++++++----- js2/mwEmbed/libEmbedVideo/embedVideo.js | 43 ++++-- .../libSequencer/seqRemoteSearchDriver.js | 11 +- js2/mwEmbed/php/languages/mwEmbed.i18n.php | 145 ++++-------------- js2/mwEmbed/skins/mvpcf/styles.css | 4 + 7 files changed, 146 insertions(+), 169 deletions(-) diff --git a/js2/README b/js2/README index 062bbd53eb..d82b80f501 100644 --- a/js2/README +++ b/js2/README @@ -1,3 +1,4 @@ MediaWiki Javascript phase 2 -Documentation to follow:. \ No newline at end of file +See Documentation on wiki: +http://www.mediawiki.org/wiki/JS2_Overview \ No newline at end of file diff --git a/js2/mwEmbed/example_usage/Add_Media_Wizard.html b/js2/mwEmbed/example_usage/Add_Media_Wizard.html index 05c4811235..b6cbfbba77 100644 --- a/js2/mwEmbed/example_usage/Add_Media_Wizard.html +++ b/js2/mwEmbed/example_usage/Add_Media_Wizard.html @@ -20,6 +20,7 @@ 'target_textbox': '#wpTextbox1', 'target_render_area':'#inline_append', 'import_url_mode':'remote_link', + 'remote_insert_description' : true, //note selections in the textbox will take over the default query 'default_query': 'fish', diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 24398b511a..a81720a288 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -1,9 +1,10 @@ /* * Base remote search Object. -* provies the base class for the other search system to extend. +* provides 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." + "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information.", + "mwe-import-description" : "$1, imported from $2" } ) /* @@ -53,6 +54,7 @@ baseRemoteSearch.prototype = { /** * Initialise the baseRemoteSearch + * @param {Object} options The set of options for the remote search class */ init: function( options ) { js_log( 'mvBaseRemoteSearch:init' ); @@ -107,9 +109,9 @@ baseRemoteSearch.prototype = { } } } - // force a mime type for now.. in the future generalize for other RSS feeds and conversions + // Force a mime type. In the future generalize for other RSS feeds rObj['mime'] = 'video/ogg'; - // add pointer to parent search obj:( this.cp.limit )? this.cp.limit : this.limit, + // Add pointer to parent search obj:( this.cp.limit )? this.cp.limit : this.limit, rObj['pSobj'] = _this; // add the result to the result set: @@ -172,60 +174,91 @@ baseRemoteSearch.prototype = { }, /** - * Get the html representation of the resource Object paramater + * Get the html representation of the resource Object parameter */ getEmbedHTML: function( rObj , options ) { if ( !options ) - options = { }; + options = { }; // Set up the output var with the default values: - var eWidth = rObj.width; - var eHeight = rObj.height; + if(! options.width ) + options.width = rObj.width; + if(! options.height ) + options.height = rObj.height + + var outHtml = ''; if ( options['max_height'] ) { - eHeight = ( options.max_height > rObj.height ) ? rObj.height : options.max_height; - eWidth = ( rObj.width / rObj.height ) * outOpt.height; + options.height = ( options.max_height > rObj.height ) ? rObj.height : options.max_height; + options.width = ( rObj.width / rObj.height ) * options.height; } - var style_attr = 'style="'; - if( eWidth ) - style_attr += 'width:' + eWidth + 'px;'; + options.style = ''; + if( options.height ) + options.style += 'height:' + options.height + 'px;'; - if( eHeight ) - style_attr += 'height:' + eHeight + 'px;'; - - var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; + if( options.width ) + options.style += 'width:' + options.width + 'px;'; if ( rObj.mime.indexOf( 'image' ) != -1 ) - return this.getImageEmbedHTML( rObj, options ); + outHtml = this.getImageEmbedHTML( rObj, options ); if ( rObj.mime == 'application/ogg' || rObj.mime == 'video/ogg' || rObj.mime == 'audio/ogg' ) { - var ahtml = id_attr + - ' src="' + rObj.src + '" ' + - style_attr + - ' poster="' + rObj.poster + '" '; + // Setup the attribute html: + var ahtml = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; + ahtml+= 'src="' + rObj.src + '" ' + + 'style="' + options.style + '" ' + + 'poster="' + rObj.poster + '" '; + if ( rObj.mime == 'application/ogg' || rObj.mime == 'video/ogg' ) { - return ''; + outHtml = ''; } - if ( rObj.mime.indexOf( 'audio/ogg' ) != -1 ) { - return ''; + if ( rObj.mime == 'audio/ogg' ) { + outHtml = ''; } } + + // Return the output. Wrap with a description div if remote_insert_description is on. + if( outHtml != '') + return ( this.rsd['remote_insert_description'] ) ? + this.wrapHtmlDesc(rObj, options, outHtml) : + outHtml; + + // No output give error: js_log( "ERROR:: no embed code for mime type: " + rObj.mime ); return 'Error missing embed code for: ' + escape( rObj.mime ); }, + wrapHtmlDesc: function( rObj, options, outHtml ) { + var stripedTitle = rObj.title.replace( /File:|Image:|.jpg|.png|.ogg|.ogv|.oga|.svg/ig, ''); + + var titleLink = '' + + stripedTitle + ''; + var cpTitle = gM('rsd-' + this.cp.id + '-title'); + var remoteProviderLink = '' + + cpTitle + ''; + return '
' + + outHtml + + gM( 'mwe-import-description', [titleLink, remoteProviderLink]) + + '
'; + }, /** - * Get the embed html specificaly for an image type resource Object. + * Get the embed html specifically for an image type resource Object. */ getImageEmbedHTML:function( rObj, options ) { // if crop is null do base output: - var imgHtml = ''; + var imgHtml = ''; if ( rObj.crop == null ) - return imgHtml - // else do crop output: - return '
' + - '
' + - imgHtml + - '
' + - '
'; + return imgHtml; + // Else do crop output: + return '
' + + '
' + + imgHtml + + '
' + + '
'; }, /** * Gets an image object from a requested transformation via callback @@ -241,13 +274,12 @@ baseRemoteSearch.prototype = { }, /* * 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 ) return $j.trim( rObj.desc.replace(/(<([^>]+)>)/ig,"") ); - // no desc avaliable: + // No Description available: return ''; }, /** @@ -307,7 +339,7 @@ baseRemoteSearch.prototype = { /** * Adds resource info with a callback function * - * Usefull for grabbing extra info that is not avaliable in the innitial + * Use full for grabbing extra info that is not available in the initial * search results api request. */ addResourceInfoCallback:function( rObj, callback ) { @@ -319,7 +351,7 @@ baseRemoteSearch.prototype = { */ getEmbedWikiCode:function( rObj ) { var layout = ( rObj.layout ) ? rObj.layout:"right" - var o = '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|' + layout; + var o = '[[' + this.rsd.fileNS + ':' + rObj.target_resource_title + '|thumb|' + layout; if ( !rObj.target_width && rObj.width ) { rObj.target_width = ( rObj.width < 640 ) ? rObj.width: '640'; diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index a4df8a7307..c025f17c36 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -52,7 +52,11 @@ loadGM( { "mwe-embed_site_or_blog" : "Embed on a page", "mwe-related_videos" : "Related videos", "mwe-seeking" : "seeking", - "mwe-copy-code" : "Copy code" + "mwe-copy-code" : "Copy code", + "mwe-video-h264" : "H.264 video", + "mwe-video-flv" : "Flash video", + "mwe-video-ogg" : "Ogg video", + "mwe-video-audio" : "Ogg audio" } ); var default_video_attributes = { @@ -345,11 +349,7 @@ mediaSource.prototype = { else if ( $j( element ).attr( 'content-type' ) ) this.mime_type = $j( element ).attr( 'content-type' ); else - this.mime_type = this.detectType( this.src ); - - // Set the title if unset: - if ( !this.title ) - this.title = this.mime_type; + this.mime_type = this.detectType( this.src ); this.parseURLDuration(); }, @@ -427,8 +427,27 @@ mediaSource.prototype = { @return the title of the source. @type String */ - getTitle : function() { - return this.title; + getTitle : function() { + if( this.title ) + return this.title; + + // Return a title based on mime type: + switch( this.mime_type ){ + case 'video/h264' : + return gM( 'mwe-video-h264' ); + break; + case 'video/x-flv' : + return gM( 'mwe-video-flv' ); + break; + case 'video/ogg' : + return gM( 'mwe-video-ogg' ); + break; + case 'audio/ogg' : + return gM( 'mwe-video-audio' ); + break; + } + // Return the mime type string if not known type. + return this.mime_type; }, /** Index accessor function. @return the source's index within the enclosing mediaElement container. @@ -1879,12 +1898,14 @@ embedVideo.prototype = { o += '

' + gM( 'mwe-chose_player' ) + '

'; var _this = this; $j.each( this.media_element.getPlayableSources(), function( source_id, source ) { - var default_player = embedTypes.players.defaultPlayer( source.getMIMEType() ); + var playable = embedTypes.players.defaultPlayer( source.getMIMEType() ); var is_selected = ( source == _this.media_element.selected_source ); var image_src = mv_skin_img_path ; - - if ( default_player ) { + + o += '

' + source.getTitle() + '

'; + + if ( playable ) { o += '