r42795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42794‎ | r42795 | r42796 >
Date:00:49, 30 October 2008
Author:dale
Status:old
Tags:
Comment:
smil updates
* transitions library display
* api driven remote searching
* multiple display modes for search results
* new assets ( for transitions and controls )
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_SequenceTools.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_playlist.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_remote_media_search.js (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_sequencer.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon_dark.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon_dark.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/mv_sequence.css (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_crossfade.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_fadeFromColor.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/transition_wipe.png (added) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_SequenceTools.php
@@ -16,6 +16,7 @@
1717 var $valid_tools=array(
1818 'sequence_page',
1919 'add_clips_manual',
 20+ 'transition',
2021 'welcome',
2122 'cliplib',
2223 'options'
@@ -74,6 +75,9 @@
7576 case 'options':
7677 $this->add_editor_options();
7778 break;
 79+ case 'transition':
 80+ $this->add_transitions();
 81+ break;
7882 default:
7983 $wgOut->addHTML( wfMsg('mv_tool_missing', htmlspecialchars ($tool_id) ) );
8084 break;
@@ -86,7 +90,7 @@
8791 $wgOut->addHTML( '<h3>'. wfMsg('mv_resource_locator') . '</h3>' );
8892 //add the input form
8993 $wgOut->addHTML(
90 - xml::input('mv_ams_search', 255,'', array('class'=>'searchField')) .
 94+ xml::input('mv_ams_search', 255,'', array( 'id' => 'mv_ams_search' , 'class' => 'searchField' )) .
9195 xml::submitButton( wfMsg('mv_media_search'), array('id'=>'mv_ams_submit') ) .
9296 xml::element('div',array('id'=>'mv_ams_results'))
9397 );
@@ -100,6 +104,10 @@
101105 '<blockquote><input type="radio" value="advanced_editor" name="opt_editor">' .
102106 wfMsg('mv_advanced_editor_desc') . ' </blockquote>' );
103107 }
 108+ function add_transitions(){
 109+ global $wgOut;
 110+ $wgOut->addHTML('<h3>'. wfMsg('mv_transitions') .'</h3>');
 111+ }
104112 function auto_complete_stream_name( $val ) {
105113 global $mvDefaultSearchVideoPlaybackRes;
106114 $dbr =& wfGetDB( DB_SLAVE );
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -253,6 +253,8 @@
254254 'mv_simple_editor_desc'=>'simple editor (iMovie style)',
255255 'mv_advanced_editor_desc' => 'advanced editor (Final Cut style)',
256256
 257+ 'mv_transitions'=>'Transitions',
 258+
257259 'mv_save_sequence' => 'Save sequence',
258260 'mv_sequence_page_desc' => 'Save the current sequence',
259261 'mv_sequence_add' => 'Add clips',
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/transition_wipe.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/transition_wipe.png
___________________________________________________________________
Added: svn:mime-type
260262 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_fadeFromColor.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_fadeFromColor.png
___________________________________________________________________
Added: svn:mime-type
261263 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_crossfade.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/transition_images/fade_crossfade.png
___________________________________________________________________
Added: svn:mime-type
262264 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/mv_sequence.css
@@ -92,3 +92,10 @@
9393 top:0px;
9494 z-index:-1;
9595 }
 96+.mv_clip_box_result{
 97+ padding:10px;
 98+ float:left;
 99+}
 100+mv_clip_list_result{
 101+ padding:10px;
 102+}
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon.png
___________________________________________________________________
Added: svn:mime-type
96103 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon_dark.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/box_layout_icon_dark.png
___________________________________________________________________
Added: svn:mime-type
97104 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon_dark.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon_dark.png
___________________________________________________________________
Added: svn:mime-type
98105 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/images/list_layout_icon.png
___________________________________________________________________
Added: svn:mime-type
99106 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -45,6 +45,7 @@
4646 var global_req_cb = new Array();//the global request callback array
4747 var _global = this;
4848 var mv_init_done=false;
 49+var global_cb_count =0;
4950
5051
5152 /*
@@ -2966,6 +2967,7 @@
29672968 }
29682969 return new_url;
29692970 }
 2971+
29702972 function seconds2ntp(sec){
29712973 var sec = parseInt(sec);
29722974 var hours = Math.floor(sec/ 3600);
@@ -2989,10 +2991,50 @@
29902992 //return seconds float (ie take seconds float value if present):
29912993 return parseInt(times[0]*3600)+parseInt(times[1]*60)+parseFloat(times[2]);
29922994 }
 2995+
29932996 //addLoadEvent for adding functions to be run when the page DOM is done loading
29942997 function mv_addLoadEvent(func) {
29952998 mvEmbed.addLoadEvent(func);
29962999 }
 3000+
 3001+//does a remote or local api request based on request url
 3002+function do_api_req(req_param, api_url, callback){
 3003+ if(typeof req_param != 'object')
 3004+ return js_log('Error: request paramaters must be an object');
 3005+ if( !api_url){
 3006+ if(!wgServer || ! wgScriptPath)
 3007+ return js_log('Error: no api url');
 3008+
 3009+ api_url = wgServer +((wgServer == null) ? parseUri(document.URL).host + (wgScriptPath + "/api.php") : parseUri(document.URL).host + wgScript);
 3010+ //update to api.php (if index.php was in the wgScript path):
 3011+ api_url = api_url.replace('index.php', 'api.php');
 3012+ }
 3013+
 3014+ //build request string: (force the format to json):
 3015+ var req_url = api_url +'?format=json';
 3016+ for(var i in req_param){
 3017+ req_url += '&' + encodeURIComponent( i ) + '=' + encodeURIComponent( req_param[i] );
 3018+ }
 3019+
 3020+ if( parseUri(document.URL).host == parseUri(api_url).host ){
 3021+ //local request do api request directly
 3022+ $j.ajax({
 3023+ type: "GET",
 3024+ url:req_url,
 3025+ async: false,
 3026+ success:function(data){
 3027+ eval('var result_data=' + data );
 3028+ callback( result_data );
 3029+ }
 3030+ });
 3031+ }else{
 3032+ //remote request append callback
 3033+ eval('_global.mycpfn' + ( global_cb_count++ ) + ' = ' + callback );
 3034+ req_url += '&callback=mycpfn' + global_cb_count;
 3035+ loadExternalJs( req_url );
 3036+ }
 3037+}
 3038+//do a "normal" request (should be deprecated via extending the mediaWiki API)
29973039 function do_request(req_url, callback){
29983040 js_log('do request: ' + req_url);
29993041 if( parseUri(document.URL).host == parseUri(req_url).host){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_remote_media_search.js
@@ -0,0 +1,167 @@
 2+/*
 3+* a library for doing remote semantic wiki searches with a focus on media results.
 4+*/
 5+var mvRemoteSearch = function(initObj) {
 6+ return this.init(initObj);
 7+};
 8+mvRemoteSearch.prototype = {
 9+ //default values:
 10+ thumb_width:80,
 11+
 12+ completed_req:0,
 13+ num_req:0,
 14+
 15+ result_display_mode:'box', //box or list
 16+ api_mode:'mediawiki', //api mode (mediawiki api or metavid enhanced wiki api)
 17+ resultsObj:{},
 18+ //init the object:
 19+ init:function( initObj ){
 20+ js_log('f:mvRemoteSearch:init');
 21+ for(var i in initObj){
 22+ this[i] = initObj[i];
 23+ }
 24+ var _this = this;
 25+
 26+ if(this['target_submit']){
 27+ $j('#'+this['target_submit']).click(function(){
 28+ js_log('doSearch REQ');
 29+ _this.getSearchResults();
 30+ });
 31+ }
 32+ //set up bindings for interface components
 33+ //if(this['target_input'])
 34+ //@@todo autocomplete for titles
 35+
 36+ //if(this['target_results')
 37+ //@@todo error checking
 38+
 39+ //check if we are in metavid Temporal semantic media search mode
 40+ //add an "advanced search" button
 41+
 42+ //add in controls: (find a better place for these / use css )
 43+ var box_dark = (this.result_display_mode=='box')?'_dark':'';
 44+ var list_dark = (this.result_display_mode=='list')?'_dark':'';
 45+ $j('#'+this.target_submit).after('<img id="msc_box_layout" ' +
 46+ 'src = "' + mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon' + box_dark + '.png" ' +
 47+ 'style="width:20px;height:20px;cursor:pointer;"> ' +
 48+ '<img id="msc_list_layout" '+
 49+ 'src = "' + mv_embed_path + 'skins/' + mv_skin_name + '/images/list_layout_icon' + list_dark + '.png" '+
 50+ 'style="width:20px;height:20px;cursor:pointer;">'
 51+ );
 52+ js_log('should have set: ' +this.target_submit);
 53+ $j('#msc_box_layout').hover(function(){
 54+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/box_layout_icon_dark.png');
 55+ }, function(){
 56+ var box_dark = (_this.result_display_mode=='box')?'_dark':'';
 57+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/box_layout_icon'+box_dark+'.png');
 58+ }).click(function(){
 59+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/box_layout_icon_dark.png');
 60+ _this.setDispMode('box');
 61+ });
 62+
 63+ $j('#msc_list_layout').hover(function(){
 64+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/list_layout_icon_dark.png');
 65+ }, function(){
 66+ var list_dark = (_this.result_display_mode=='list')?'_dark':'';
 67+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/list_layout_icon'+list_dark+'.png');
 68+ }).click(function(){
 69+ $j(this).attr("src", mv_embed_path+'skins/'+mv_skin_name+'/images/list_layout_icon_dark.png');
 70+ _this.setDispMode('list');
 71+ });
 72+
 73+ //or if we are in plain mediaWiki mode:
 74+ return this;
 75+ },
 76+ setDispMode:function(mode){
 77+ js_log('setDispMode:' + mode);
 78+ this.result_display_mode=mode;
 79+ //reformat the results:
 80+ this.formatOutputResults();
 81+ },
 82+ getSearchResults:function(){
 83+ js_log('f:getSearchResults for:' + $j('#'+this.target_input).val() );
 84+ //set results div to "loading"
 85+ $j('#'+this.target_results).html( getMsg('loading_txt') );
 86+
 87+ //do two queries against the Image / File namespace:
 88+ if( this.api_mode=='mediawiki' ){
 89+ //construct search request:
 90+ var req_url =this.p_seq.plObj.interface_url.replace(/index\.php/, 'api.php');
 91+ //build the image request object:
 92+ var rObj = {
 93+ 'action':'query',
 94+ 'generator':'search',
 95+ 'gsrsearch': encodeURIComponent( $j('#'+this.target_input).val() ),
 96+ 'gsrnamespace':6, //(only search images)
 97+ 'gsrwhat':'text',
 98+ 'prop':'imageinfo|revisions|categories',
 99+ 'iiprop':'url',
 100+ 'iiurlwidth':'80',
 101+ 'rvprop':'content'
 102+ };
 103+ var _this = this;
 104+ //set up the number of request:
 105+ this.completed_req=0;
 106+ this.num_req=2;
 107+ //setup the number of requests result flag:
 108+ do_api_req( rObj, req_url, function(data){
 109+ //parse the return data
 110+ _this.addMediaWikiAPIResults( data);
 111+ _this.checkRequestDone();
 112+ });
 113+ //also do a request for page titles (would be nice if api could query both at the same time)
 114+ rObj['gsrwhat']='title';
 115+ do_api_req( rObj, req_url, function(data){
 116+ //parse the return data
 117+ _this.addMediaWikiAPIResults( data);
 118+ _this.checkRequestDone();
 119+ });
 120+ }
 121+ },
 122+ //check request done used for when we have multiple requests to check before formating results.
 123+ checkRequestDone:function(){
 124+ //display output if done:
 125+ this.completed_req++;
 126+ if(this.completed_req == this.num_req){
 127+ this.formatOutputResults();
 128+ }
 129+ },
 130+ formatOutputResults:function(){
 131+ js_log('f:formatOutputResults');
 132+ //debugger;
 133+ var o='';
 134+ //output results based on display mode:
 135+ for( var i in this.resultsObj ){
 136+ var pageObj = this.resultsObj[i];
 137+ if( this.result_display_mode == 'box' ){
 138+ o+='<div class="mv_clip_box_result" style="width:' + this.thumb_width + 'px;">';
 139+ o+='<img style="width:' + this.thumb_width + 'px;" src="' + pageObj.imageinfo[0].thumburl + '">';
 140+ o+='</div>';
 141+ }else if(this.result_display_mode == 'list'){
 142+ o+='<div class="mv_clip_list_result" style="width:90%">';
 143+ o+='<img style="float:left;width:' + this.thumb_width + 'px;" src="' + pageObj.imageinfo[0].thumburl + '">';
 144+ o+= pageObj.revisions[0]['*'];
 145+ o+='</div>';
 146+ o+='<div style="clear:both" />';
 147+ }
 148+ }
 149+ js_log('set : ' +this.target_results + ' to ' + o);
 150+ //debugger;
 151+ $j('#'+this.target_results).html(o);
 152+ },
 153+ addMediaWikiAPIResults:function( data ){
 154+ //make sure we have pages to iderate:
 155+ if(data.query && data.query.pages){
 156+ for(var page_id in data.query.pages){
 157+ var page = data.query.pages[ page_id ];
 158+ this.resultsObj[page_id]=page;
 159+ }
 160+ }else{
 161+ js_log('no results:' + data);
 162+ }
 163+ }
 164+}
 165+/*
 166+
 167+
 168+*/
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_sequencer.js
@@ -89,9 +89,9 @@
9090 menu_items : {
9191 'welcome':1,
9292 'cliplib':0,
93 - 'transition':0,
94 - 'resource_overview':0,
 93+ 'transition':0,
9594 'options':0
 95+ //menu_resource_overview
9696 },
9797 init:function( initObj ){
9898 //set the default values:
@@ -187,7 +187,7 @@
188188 for(var i in this.menu_items){
189189 req_url+='|'+i;
190190 $j('#'+i+'_ic').html( getMsg('loading_txt') );//set targets to loading
191 - }
 191+ }
192192 var _this = this;
193193 do_request(req_url, function(data){
194194 if(typeof data=='string'){
@@ -200,23 +200,33 @@
201201 $j('#'+i+'_ic').html( data[i] );
202202 _this.doMenuItemDispJs(i)
203203 }
204 - });
205 -
206 - //load req content:
207 - //var _this = this;
208 - //$j('#'+target_id).load(req_url, function(responseText, textStatus, XMLHttpRequest){
209 - // _this.doMenuItemDispJs(item, target_id);
210 - //});
 204+ });
211205 },
212 - doMenuItemDispJs:function(item){
 206+ doMenuItemDispJs:function(item){
213207 var _this = this;
214208 var target_id = item + '_ic';
215209 //do any menu item post embed js hook processing:
216 - switch(item){
217 - case 'cliplib':
218 - $j('#mv_ams_submit').click(function(){
219 - _this.doClipSearch();
220 - })
 210+ switch(item){
 211+ case 'transition':
 212+ //render out the transitions library
 213+ this.renderTransitionsSet(target_id);
 214+ break;
 215+ case 'cliplib':
 216+ //load the search interface with sequence tool targets
 217+ //@@todo it maybe cleaner to just pass along msg text in JSON
 218+ //and have the search interface build the html
 219+ if( !this.plObj.interface_url )
 220+ return js_log( 'Error:missing interface_url, can not load search interface' );
 221+
 222+ mvJsLoader.doLoad({'mvRemoteSearch':'mv_remote_media_search.js'}, function(){
 223+ _this.mySearch = new mvRemoteSearch( {
 224+ 'p_seq':_this,
 225+ 'instance_name': _this.instance_name + '.mySearch',
 226+ 'target_input':'mv_ams_search',
 227+ 'target_submit':'mv_ams_submit',
 228+ 'target_results':'mv_ams_results'
 229+ });
 230+ });
221231 break;
222232 case 'options':
223233 $j('#'+target_id+" input[value='simple_editor']").attr({
@@ -231,7 +241,28 @@
232242 });
233243 break;
234244 }
235 - },
 245+ },
 246+ //renders out the transitions effects set
 247+ renderTransitionsSet:function(target_id){
 248+ js_log('f:renderTransitionsSet:' + target_id);
 249+ var o = '';
 250+ if(typeof mvTransLib == 'undefined')
 251+ return js_log('Error: missing mvTransLib');
 252+
 253+ for(var i in mvTransLib['type']){
 254+ js_log('on tran type: ' + i);
 255+ var base_trans_name = i;
 256+ var tLibSet = mvTransLib['type'][ i ];
 257+ for(var j in tLibSet){
 258+ trans_name=base_trans_name+'_'+j;
 259+ js_log('tname: ' + trans_name);
 260+ o+='<img style="float:left;padding:10px;" '+
 261+ 'src="'+mv_embed_path +'/skins/'+mv_skin_name+'/transition_images/'+ trans_name + '.png">';
 262+ }
 263+ }
 264+ js_log('should set: ' + target_id + ' to: ' + o);
 265+ $j('#'+target_id).append(o);
 266+ },
236267 renderTimeLine:function(){
237268 //empty out the top level html:
238269 $j('#'+this.timeline_id).html('');
@@ -373,7 +404,7 @@
374405 js_log('json output');
375406 },
376407 getSeqOutputHLRDXML:function(){
377 - var o='<sequence_hlrd>' +"\n"+
 408+ var o='<sequence_hlrd>' +"\n";
378409 o+="\t<head>";
379410 //get transitions
380411 for(var i in this.plObj.transitions){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_playlist.js
@@ -602,7 +602,7 @@
603603 if(this.cur_clip.embed.supports['playlist_swap_loader'] ){
604604 //navtive support:
605605 // * pre-loads clips
606 - // * mv_playlist smil extension, mannages transitions animations overlays etc.
 606+ // * mv_playlist smil extension, manages transitions animations overlays etc.
607607 js_log('clip obj supports playlist swap_loader (ie playlist controlled playback)');
608608 //update cur clip based if sequence playhead set:
609609 var d = new Date();
@@ -1523,7 +1523,7 @@
15241524 if(!tObj.fadeColor)
15251525 return js_log('missing fadeColor');
15261526 if($j('#'+tObj.overlay_selector_id).length==0){
1527 - js_log("ERROR cant find: "+ tObj.overlay_selector_id);
 1527+ js_log("ERROR can't find: "+ tObj.overlay_selector_id);
15281528 }
15291529 //set the initial state
15301530 $j('#'+tObj.overlay_selector_id).css({

Status & tagging log