r48458 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48457‎ | r48458 | r48459 >
Date:21:13, 16 March 2009
Author:dale
Status:deferred
Tags:
Comment:
firefogg integration cleanups.
improved license handling for add_media_wizard
general add_media_wizard fixes / improvements
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/i18n/README (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/solrArchiveSearch.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -319,7 +319,7 @@
320320 );
321321 }
322322 # Define a setup function
323 -# Add a hook to initialise the magic word
 323+# Add a hook to initialize the magic word
324324 $wgHooks['LanguageGetMagic'][] = 'mvMagicParserFunction_Magic';
325325
326326 function mvMagicParserFunction_Magic( &$magicWords, $langCode ) {
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -71,7 +71,7 @@
7272
7373 # remoteSearchDriver.js
7474 #set to ignored for now. Messages does not appear to be final
75 - 'mv_media_search' => 'Media search why test test', # do not translate or duplicate this message to other languages
 75+ 'mv_media_search' => 'Media search', # do not translate or duplicate this message to other languages
7676 'rsd_box_layout' => 'Box layout',
7777 'rsd_list_layout' => 'List layout',
7878 #set to ignored for now. Messages does not appear to be final
@@ -81,6 +81,15 @@
8282 'upload' => 'Upload',
8383 'rsd_layout' => 'Layout:',
8484 'rsd_resource_edit' => 'Edit resource:',
 85+ 'resource_description_page'=> "Resource Description Page",
 86+
 87+ 'cc_title' => 'Creative Commons',
 88+ 'cc_by_title' => 'Attribution',
 89+ 'cc_nc_title' => 'Noncommercial',
 90+ 'cc_nd_title' => 'No Derivative Works',
 91+ 'cc_sa_title' => 'Share Alike',
 92+ 'cc_pd_title' => 'Public Domain',
 93+
8594
8695 # mvClipEdit.js
8796 'mv_crop' => 'Crop image',
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css
@@ -559,6 +559,15 @@
560560 #rsd_resource_edit{
561561 z-index:2;
562562 }
 563+.rsd_license{
 564+ position:absolute;
 565+ bottom:0px;
 566+ left:0px;
 567+ width:100%;
 568+}
 569+.rsd_license img{
 570+ float:left;
 571+}
563572 .mv_clip_box_result{
564573 padding:10px;
565574 float:left;
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -643,13 +643,26 @@
644644 // quicktime
645645 if ( this.testActiveX( 'QuickTimeCheckObject.QuickTimeCheck.1' ) )
646646 this.players.addPlayer(quicktimeActiveXPlayer);
647 - }
 647+ }
 648+ // <video> element
 649+ if ( typeof HTMLVideoElement == 'object' // Firefox, Safari
 650+ || typeof HTMLVideoElement == 'function' ) // Opera
 651+ {
 652+ //do another test for safari:
 653+ if( this.safari ){
 654+ var dummyvid = document.createElement("video");
 655+ if (dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably")
 656+ {
 657+ this.players.addPlayer( videoElementPlayer );
 658+ } else {
 659+ /* could add some user nagging to install the xiph qt */
 660+ }
 661+ }else{
 662+ this.players.addPlayer( videoElementPlayer );
 663+ }
 664+ }
 665+
648666
649 - // <video> element (should not need to be attached to the dom to test)(
650 - var v = document.createElement("video");
651 - if( v.play )
652 - this.players.addPlayer( videoElementPlayer );
653 -
654667 // Mozilla plugins
655668 if( navigator.mimeTypes && navigator.mimeTypes.length > 0) {
656669 for ( var i = 0; i < navigator.mimeTypes.length; i++ ) {
@@ -1011,19 +1024,22 @@
10121025 */
10131026 //simple url re-writer for standard temporal and size request urls:
10141027 function getURLParamReplace( url, opt ){
1015 - var pSrc = parseUri(url);
 1028+ var pSrc = parseUri( url );
10161029 if(pSrc.protocol != '' ){
10171030 var new_url = pSrc.protocol +'://'+ pSrc.authority + pSrc.path +'?';
10181031 }else{
10191032 var new_url = pSrc.path +'?';
10201033 }
10211034 var amp = '';
1022 - for(var i in pSrc.queryKey, function(key, val){
 1035+ for(var key in pSrc.queryKey){
 1036+ var val = pSrc.queryKey[ key ];
 1037+ //do override if requested
10231038 if( opt[ key ] )
10241039 val = opt[ key ];
10251040 new_url+= amp + key + '=' + val;
10261041 amp = '&';
1027 - });
 1042+ };
 1043+
10281044 return new_url;
10291045 }
10301046
Index: trunk/extensions/MetavidWiki/skins/mv_embed/i18n/README
@@ -1,51 +1,5 @@
22 This _short_ document outlines the plan for internationalization support for stand alone
33 javascript libraries being integrated into mediaWiki.
44
5 -A key piece is of this system is the script_loader.
6 -
7 -For static usage every script file should have an associative text js language file:
8 -mv_embed.en.js
9 -mv_embed.es.js
10 -mv_embed.fn.js
11 -
12 -libSequencer_mv_sequencer.en.js
13 -libSequencer_mv_sequencer.es.js
14 -
15 -These static files will be updated via mediaWikis translation system.
16 -
17 -
18 -These static files will be combined with the server side load script so that the language segment
19 -is requested at the same time the script is included. It won't result in a separate request because
20 -script_loader.php will combine the files.
21 -
22 -script_loader.php arguments:
23 -@uid _string the unique id to ensure fresh copy of the scripts
24 -@sl _string the list of scripts with relative paths
25 -@debug _boolean if debug is "ON" don't send out minimised code
26 -the javascript should read this param on Document.URL and not group requests for ease of debuging.
27 -
28 -
29 -script_loader.php will take a set of scripts as arguments ie:
30 -http://server.com/script_loader.php?uid=SVN_Version_Number&sl=/mv_embed/mv_embed.js,mv_embed.en.js,/jQuery/jquery.js
31 -
32 -It will minimise the scripts (strip comments and a custom stip of debug statements ie js_log('msg')
33 -can use: http://code.google.com/p/jsmin-php/ for minimisation.
34 -
35 -Features:
36 -script_loader will concatenate all the minimised code from the requested set of scripts.
37 -
38 -script_loader will send appropriate http cache headers.
39 - Can expire _never_ since we send unique SVN version id to force updates.
40 - This will integrate with the squid proxy setup so the minimisation just
41 - happens on fresh requests
42 -
43 -script_loader will read the client accept header and send out gziped or not.
44 -
45 -MediaWiki specific Features:
46 -
47 -We will want pass the il8n off to mediaWikis existing internationalization infastructure.
48 -MediaWiki should parse the il8n js file and check mediaWikis message space for any language variables.
49 -Yes this does result in all js_variables being stored twice.
50 -
51 -But will have the advantage of being a stand alone solution for media remixing and should enable
52 -wider participation in development.
 5+A key piece is of this system is the script_loader. mvwScriptLoader.php
 6+for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader
\ No newline at end of file
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js
@@ -7,7 +7,7 @@
88 metavid
99 and archive.org
1010 */
11 -loadGM( { "mv_media_search" : "Media Search why test test",
 11+loadGM( { "mv_media_search" : "Media Search",
1212 "rsd_box_layout" : "Box layout",
1313 "rsd_list_layout" : "List Layout",
1414 "rsd_results_desc" : "Results ",
@@ -15,7 +15,15 @@
1616 "rsd_results_prev" : "previous ",
1717 "upload" : "Upload",
1818 "rsd_layout" : "Layout:",
19 - "rsd_resource_edit" : "Edit Resource:"
 19+ "rsd_resource_edit" : "Edit Resource:",
 20+ "resource_description_page": "Resource Description Page",
 21+
 22+ "cc_title": "Creative Commons",
 23+ "cc_by_title": "Attribution",
 24+ "cc_nc_title": "Noncommercial",
 25+ "cc_nd_title": "No Derivative Works",
 26+ "cc_sa_title": "Share Alike",
 27+ "cc_pd_title": "Public Domain"
2028 });
2129
2230 var default_remote_search_options = {
@@ -65,7 +73,7 @@
6674 'advanced_search':{
6775 'title': 'Advanced Options'
6876 }
69 - },
 77+ },
7078 content_providers:{
7179 /*content_providers documentation:
7280 @enabled: whether the search provider can be selected
@@ -157,6 +165,71 @@
158166 'tab_img':true
159167 }
160168 },
 169+ //define the licenses
 170+ // ... this will get complicated quick...
 171+ // (just look at complexity for creative commons without exessive "duplicate data")
 172+ // ie cc_by could be "by/3.0/us/" or "by/2.1/jp/" to infinitum...
 173+ // some complexity should be negated by license equivalances.
 174+
 175+ // but we will have to abstract into another class let content providers provide license urls
 176+ // and we have to clone the license object and allow local overrides
 177+
 178+ licenses:{
 179+ //for now only support creative commons type licenses
 180+ //used page: http://creativecommons.org/licenses/
 181+ 'cc':{
 182+ 'base_img_url':'http://upload.wikimedia.org/wikipedia/commons/thumb/',
 183+ 'base_license_url': 'http://creativecommons.org/licenses/',
 184+ 'licenses':{
 185+ 'by':'by/3.0/',
 186+ 'by-sa':'by-sa/3.0/',
 187+ 'by-nc-nd':'by-nc-nd/3.0/',
 188+ 'by-nc':'by-nc/3.0/',
 189+ 'by-nc-sa':'by-nc-sa/3.0/',
 190+ 'by-sa':'by-nc/3.0',
 191+ 'pd':'publicdomain/'
 192+ },
 193+ 'license_img':{
 194+ 'by':{
 195+ 'im':'1/11/Cc-by_new_white.svg/20px-Cc-by_new_white.svg.png',
 196+ },
 197+ 'nc':{
 198+ 'im':'2/2f/Cc-nc_white.svg/20px-Cc-nc_white.svg.png',
 199+ },
 200+ 'nd':{
 201+ 'im':'b/b3/Cc-nd_white.svg/20px-Cc-nd_white.svg.png',
 202+ },
 203+ 'sa':{
 204+ 'im':'d/df/Cc-sa_white.svg/20px-Cc-sa_white.svg.png',
 205+ },
 206+ 'pd':{
 207+ 'im':'5/51/Cc-pd-new_white.svg/20px-Cc-pd-new_white.svg.png',
 208+ }
 209+ }
 210+ }
 211+ },
 212+ getlicenseImgSet:function( license_key ){
 213+ if( typeof( this.licenses.cc.licenses[ license_key ]) == 'undefined')
 214+ return js_error('only cc licencs presently supported, could not find:' + license_key);
 215+ //set the current license pointer:
 216+ var cl = this.licenses.cc;
 217+ var title = gM('cc_title');
 218+ var imgs = '';
 219+ var license_set = license_key.split('-');
 220+ for(var i=0;i < license_set.length; i++){
 221+ lkey = license_set[i];
 222+ title += gM( lkey + '_desc');
 223+ imgs +='<img width="20" src="' + cl.base_img_url +
 224+ cl.license_img[ lkey ].im + '">';
 225+ }
 226+ js_log('output images: '+ imgs);
 227+ return '<div class="rsd_license" title="'+ title + '" >' +
 228+ '<a target="_new" href="'+ cl.base_license_url + cl.licenses[ lkey ] +
 229+ '" title="' + title + '">'+
 230+ imgs +
 231+ '</a>'+
 232+ '</div>';
 233+ },
161234 //some default layout values:
162235 thumb_width : 80,
163236 image_edit_width : 600,
@@ -469,14 +542,21 @@
470543 rItem.poster = mv_embed_path + 'skins/' + mv_skin_name +
471544 '/images/sound_music_icon-80.png';
472545 }
 546+ //get a thumb with proper resolution transform if possible:
473547 o+='<img title="'+rItem.title+'" class="rsd_res_item" id="res_' + rInx +
474 - '" style="width:' + _this.thumb_width + 'px;" src="' + rItem.poster + '">';
 548+ '" style="width:' + _this.thumb_width + 'px;" src="' +
 549+ cp.sObj.getImageTransform( rItem, {'width':_this.thumb_width } )
 550+ + '">';
475551 //add a linkback to resource page in upper right:
476552 if( rItem.link )
477553 o+='<a target="_new" style="position:absolute;top:0px;right:0px" title="' +
478 - gM('Resource Description Page') +
 554+ gM('resource_description_page') +
479555 '" href="' + rItem.link + '"><img src="' + stylepath +
480556 '/common/images/magnify-clip.png"></a>';
 557+ //add license icons if present
 558+ if( rItem.license ){
 559+ o+= _this.getlicenseImgSet( rItem.license );
 560+ }
481561 o+='</div>';
482562 }else if(_this.result_display_mode == 'list'){
483563 o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result" style="' + disp + 'width:90%">';
@@ -737,11 +817,11 @@
738818
739819 base_resource_desc+='}}';
740820
741 - //add in licence template tag:
742 - if( rObj.licence_template_tag )
 821+ //add in license template tag:
 822+ if( rObj.license_template_tag )
743823 base_resource_desc += "\n" +
744824 '== [[Commons:Copyright tags|Licensing]]: ==' +"\n"+
745 - '{{' + rObj.licence_template_tag + '}}';
 825+ '{{' + rObj.license_template_tag + '}}';
746826
747827 $j('#rsd_resource_import').remove();//remove any old resource imports
748828 //@@ show user dialog to import the resource
@@ -1158,10 +1238,14 @@
11591239 _this.num_results++;
11601240 });
11611241 },
1162 - //by default just return the existing image:
 1242+ //by default just return the existing image with callback
11631243 getImageObj:function( rObj, size, callback){
11641244 callback( {'url':rObj.poster} );
11651245 },
 1246+ //by default just return the poster (clients can overide)
 1247+ getImageTransform:function(rObj, opt){
 1248+ return rObj.poster;
 1249+ },
11661250 getEmbedObjParsedInfo:function(rObj, eb_id){
11671251 return rObj;
11681252 },
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/solrArchiveSearch.js
@@ -1,7 +1,6 @@
22 //archive.org uses solr engine:
33 //more about solr here:
44 //http://lucene.apache.org/solr/
5 -
65 //if we ever have another remote repository using solr we could abstract thouse pieces into a seperate lib
76
87 var solrArchiveSearch = function ( initObj){
@@ -26,7 +25,8 @@
2726 js_log('f:getSearchResults for:' + $j('#rsd_q').val() );
2827 //build the query var
2928 var q = $j('#rsd_q').val();
30 - //@@todo check advanced options:
 29+ //@@todo check advanced options: include audio and images media types
 30+ //for now force (Ogg video) & a creativecommons license
3131 q+=' format:(Ogg video)';
3232 q+=' licenseurl:(http\\:\\/\\/creativecommons\\.org*)';
3333 var reqObj = {
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js
@@ -49,6 +49,10 @@
5050 rObj['start_time'] = proe.queryKey['t'].split('/')[0];
5151 rObj['end_time'] = proe.queryKey['t'].split('/')[1];
5252 rObj['stream_name'] = proe.queryKey['stream_name'];
 53+
 54+ //all metavid content is public domain:
 55+ rObj['license'] = 'pd';
 56+
5357 //transform the title into a wiki_safe title:
5458 //rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg';
5559 rObj['titleKey'] = proe.queryKey['stream_name'] + '/' + rObj['start_time'] + '/' + rObj['end_time'] + '__.ogg';
@@ -73,23 +77,18 @@
7478 return '<video ' + id_attr + ' roe="' + rObj['roe_url'] + '"></video>';
7579 }
7680 },
77 - getImageObj:function( rObj, size, callback ){
78 - var pUrl = parseURI( rObj.poster );
79 - //per Mv_StreamImage.php page
80 - var imgurl = '';
81 -
82 - if( size.width <= 80 ){
83 - imgurl = getURLParamReplace( rObj.poster, { 't' : "icon" } )
84 - }else if( size.width <= 160 ){
85 - imgurl = getURLParamReplace( rObj.poster, { 't' : "small" } )
86 - }else if( size.width <= 320 ){
87 - imgurl = getURLParamReplace( rObj.poster, { 't' : 'medium' } )
88 - }else if( size.width <= 512 ){
89 - imgurl = getURLParamReplace( rObj.poster, { 't' : 'large' } )
 81+ getImageTransform:function( rObj, opt ){
 82+ if( opt.width <= 80 ){
 83+ return getURLParamReplace( rObj.poster, { 'size' : "icon" } )
 84+ }else if( opt.width <= 160 ){
 85+ return getURLParamReplace( rObj.poster, { 'size' : "small" } )
 86+ }else if( opt.width <= 320 ){
 87+ return getURLParamReplace( rObj.poster, { 'size' : 'medium' } )
 88+ }else if( opt.width <= 512 ){
 89+ return getURLParamReplace( rObj.poster, { 'size' : 'large' } )
9090 }else{
91 - imgurl = getURLParamReplace( rObj.poster, { 't' : 'full' } )
92 - }
93 - callback( imgurl );
 91+ return getURLParamReplace( rObj.poster, { 'size' : 'full' } )
 92+ }
9493 },
9594 getEmbedObjParsedInfo:function(rObj, eb_id){
9695 var sources = $j('#'+eb_id).get(0).media_element.getSources();
@@ -113,7 +112,7 @@
114113 var year_full = (dParts[3].length==2)?'20'+dParts[3].toString():dParts[3];
115114 d.setFullYear(year_full, dParts[1]-1, dParts[2]);
116115 rObj['date'] = d.toDateString();
117 - rObj['licence_template_tag']='PD-USGov';
 116+ rObj['license_template_tag']='PD-USGov';
118117 //update based on new start time:
119118 js_log('url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time);
120119
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js
@@ -77,7 +77,8 @@
7878 this.enabled=true;
7979
8080 //make sure file is "checked"
81 - $j( '#wpSourceTypeFile' ).get(0).checked = true;
 81+ if($j( '#wpSourceTypeFile' ).length != 0)
 82+ $j( '#wpSourceTypeFile' ).get(0).checked = true;
8283
8384 //hide normal file upload stuff
8485 $j( '#wg-base-upload' ).hide();
@@ -284,10 +285,10 @@
285286 _this.formData[ 'action' ] = 'submit';
286287
287288 //send to the post url:
288 - js_log('sending form data to : ' + _this.editForm.action);
289 - for(var fk in _this.formData){
290 - js_log(fk + ' : ' + _this.formData[fk]);
291 - }
 289+ //js_log('sending form data to : ' + _this.editForm.action);
 290+ //for(var fk in _this.formData){
 291+ // js_log(fk + ' : ' + _this.formData[fk]);
 292+ //}
292293 _this.fogg.post( _this.editForm.action, 'wpUploadFile', JSON.stringify( _this.formData ) );
293294
294295 //update upload status:
@@ -305,7 +306,7 @@
306307 //setup a local function for timed callback:
307308 var uploadStatus = function(){
308309 var status = _this.fogg.status();
309 - js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + _this.fogg.responseText);
 310+ //js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + _this.fogg.responseText);
310311
311312 //update progress bar
312313 _this.fogg_update_progress( _this.fogg.progress() );
@@ -319,13 +320,15 @@
320321 js_log( 'firefogg:upload done: ');
321322 //if in "post" upload mode read the html response (should be depricated):
322323 if( _this.upload_mode == 'post' ) {
 324+ var pstatus = JSON.parse( _this.fogg.uploadstatus() );
323325 //js_log( 'done upload response is: ' + cat["responseText"] );
324 - _this.procPageResponse( JSON.parse( _this.fogg.uploadstatus() )["responseText"] );
 326+ _this.procPageResponse( pstatus["responseText"] );
325327 }else if( _this.upload_mode == 'chunks'){
326328 //should have an json result:
327 - var foo = _this;
328 - var cat = _JSON.parse( _this.fogg.uploadstatus() );
329 - debugger;
 329+ js_error('chunks upload not yet supported');
 330+ //var foo = _this;
 331+ //var cat = _JSON.parse( _this.fogg.uploadstatus() );
 332+ //debugger;
330333
331334 }
332335 }else{
@@ -350,7 +353,7 @@
351354 _this.upload_done_action();
352355 }
353356 }else{
354 - js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page );
 357+ //js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page );
355358 var error_txt = 'Unkown error';
356359 var form_txt = '';
357360 if( !result_page ){

Status & tagging log