Index: trunk/extensions/MetavidWiki/skins/add_media_wizard.js |
— | — | @@ -9,7 +9,29 @@ |
10 | 10 | //if mv_embed is hosted somewhere other than near by the add_media_wizard you can define it here: |
11 | 11 | var mv_add_media_wizard_path = 'http://mvbox2.cse.ucsc.edu/w/extensions/MetavidWiki/skins/'; |
12 | 12 | |
| 13 | +var MV_EMBED_VIDEO_HANDLER = true; // if we should use mv_embed for all ogg_hanlder video embeds. |
13 | 14 | |
| 15 | + |
| 16 | +if( MV_EMBED_VIDEO_HANDLER ){ |
| 17 | + var vidIdList = new Array(); |
| 18 | + addOnloadHook( function(){ |
| 19 | + var divs = document.getElementsByTagName('div'); |
| 20 | + for(var i = 0; i < divs.length; i++){ |
| 21 | + if( divs[i].id.substring(0,11) == 'ogg_player_'){ |
| 22 | + vidIdList.push( divs[i].id ); |
| 23 | + } |
| 24 | + } |
| 25 | + if( vidIdList.length > 0){ |
| 26 | + load_mv_embed( function(){ |
| 27 | + mvJsLoader.loadBaseLibs(function(){ |
| 28 | + //do utilty rewrite of oggHanlder content: |
| 29 | + rewrite_for_oggHanlder( vidIdList ); |
| 30 | + }); |
| 31 | + }); |
| 32 | + } |
| 33 | + }); |
| 34 | +} |
| 35 | + |
14 | 36 | //*code should not have to modify anything below*/ |
15 | 37 | //check if we are on a edit page: |
16 | 38 | if( wgAction == 'edit' || wgAction == 'submit' ){ |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js |
— | — | @@ -55,12 +55,16 @@ |
56 | 56 | |
57 | 57 | //transform the title into a wiki_safe title: |
58 | 58 | //rObj['titleKey'] = proe.queryKey['stream_name'] + '_' + rObj['start_time'].replace(/:/g,'.') + '_' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; |
59 | | - rObj['titleKey'] = proe.queryKey['stream_name'] + '/' + rObj['start_time'] + '/' + rObj['end_time'] + '__.ogg'; |
| 59 | + rObj['titleKey'] = proe.queryKey['stream_name'] + '_start-' + rObj['start_time'].replace(/:/g,'.') + '_end-' + rObj['end_time'].replace(/:/g,'.') + '.ogg'; |
60 | 60 | } |
61 | 61 | //done loading: |
62 | 62 | _this.loading=0; |
63 | 63 | }); |
64 | 64 | }, |
| 65 | + //metavid descption tied to public domain license key (government produced content) |
| 66 | + getPermissionWikiTag:function( rObj ){ |
| 67 | + return '{{PD-USGov}}'; |
| 68 | + }, |
65 | 69 | getEmbedWikiText:function(rObj, options){ |
66 | 70 | //if we are using a local copy do the standard embed: |
67 | 71 | if( this.cp.local_copy == true) |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | 'maxSize': 400, |
21 | 21 | 'videoBitrate': 400 |
22 | 22 | }, |
23 | | - formData:{}, //the form to be submited |
| 23 | + formData:{}, //the form to be submitted |
24 | 24 | |
25 | 25 | init : function( iObj ){ |
26 | 26 | if(!iObj) |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | var error_txt = 'Your upload <i>should be</i> accessible <a href="' + |
355 | 355 | wgArticlePath.replace(/\$1/, 'File:' + this.formData['wpDestFile'] ) + '">'+ |
356 | 356 | 'here</a> \n'; |
357 | | - //set the error text in case we dont' get far along in proccessing the response |
| 357 | + //set the error text in case we dont' get far along in processing the response |
358 | 358 | $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt ); |
359 | 359 | |
360 | 360 | if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){ |
— | — | @@ -372,32 +372,14 @@ |
373 | 373 | if( !result_page ){ |
374 | 374 | //@@todo fix this: |
375 | 375 | //the mediaWiki upload system does not have an API so we can\'t read errors |
376 | | - }else{ |
377 | | - sp = result_page.indexOf('<span class="error">'); |
378 | | - if(sp!=-1){ |
379 | | - se = result_page.indexOf('</span>', sp); |
380 | | - error_txt = result_page.substr(sp, (sp-se)) + '</span>'; |
381 | | - }else{ |
382 | | - //look for warning: |
383 | | - sp = result_page.indexOf('<ul class="warning">') |
384 | | - if(sp!=-1){ |
385 | | - se = result_page.indexOf('</ul>', sp); |
386 | | - error_txt = result_page.substr(sp, (se-sp)) + '</ul>'; |
387 | | - //try and add the ignore form item: |
388 | | - sfp = result_page.indexOf('<form method="post"'); |
389 | | - if(sfp!=-1){ |
390 | | - sfe = result_page.indexOf('</form>', sfp); |
391 | | - form_txt = result_page.substr(sfp, ( sfe - sfp )) + '</form>'; |
392 | | - } |
393 | | - }else{ |
394 | | - //one more error type check: |
395 | | - sp = result_page.indexOf('class="mw-warning-with-logexcerpt">') |
396 | | - if(sp!=-1){ |
397 | | - se = result_page.indexOf('</div>', sp); |
398 | | - error_txt = result_page.substr(sp, ( se - sp )) + '</div>'; |
399 | | - } |
400 | | - } |
401 | | - } |
| 376 | + }else{ |
| 377 | + var res = mvUploader.grabWikiFormError( result_page ); |
| 378 | + |
| 379 | + if(res.error_txt) |
| 380 | + error_txt = opt.error_txt; |
| 381 | + |
| 382 | + if(res.form_txt) |
| 383 | + form_txt = res.form_txt; |
402 | 384 | } |
403 | 385 | js_log( 'error text is: ' + error_txt ); |
404 | 386 | $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt + '<br>' + form_txt); |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | 'default_query':null, //default search query |
47 | 47 | //specific to sequence profile |
48 | 48 | 'p_seq':null, |
49 | | - 'cFileNS':'Image', //what is the cannonical namespace for images |
| 49 | + 'cFileNS':'File', //what is the cannonical namespace for images |
50 | 50 | //@@todo (should get that from the api or inpage vars) |
51 | 51 | |
52 | 52 | 'enable_uploads':false // if we want to enable an uploads tab: |
— | — | @@ -247,9 +247,10 @@ |
248 | 248 | } |
249 | 249 | var url = (force_url) ? force_url : cl.base_license_url + cl.licenses[ license_key ]; |
250 | 250 | return { |
251 | | - 'title': title, |
252 | | - 'img_html':imgs, |
253 | | - 'lurl' : url |
| 251 | + 'title' : title, |
| 252 | + 'img_html' : imgs, |
| 253 | + 'key' : license_key, |
| 254 | + 'lurl' : url |
254 | 255 | }; |
255 | 256 | }, |
256 | 257 | /* |
— | — | @@ -268,7 +269,7 @@ |
269 | 270 | //could not find it return unknown_license |
270 | 271 | return { |
271 | 272 | 'title' : gM('unknown_license'), |
272 | | - 'img_html' : '<span>' + gM('unknown_license') + '</span>', |
| 273 | + 'img_html' : '<span>' + gM('unknown_license') + '</span>', |
273 | 274 | 'lurl' : license_url |
274 | 275 | }; |
275 | 276 | }, |
— | — | @@ -940,7 +941,7 @@ |
941 | 942 | |
942 | 943 | }, |
943 | 944 | checkImportResource:function( rObj, cir_callback){ |
944 | | - //@@todo get the localized File/Image namespace name or do a general {NS}:Title aproch |
| 945 | + //@@todo get the localized File/Image namespace name or do a general {NS}:Title |
945 | 946 | var cp = rObj.pSobj.cp; |
946 | 947 | var _this = this; |
947 | 948 | rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,''); |
— | — | @@ -989,20 +990,16 @@ |
990 | 991 | |
991 | 992 | if( rObj.date ) |
992 | 993 | base_resource_desc+='|Date=' + rObj.date +"\n"; |
993 | | - |
994 | | - if( rObj.permission ) |
995 | | - base_resource_desc+='|Permission='+ rObj.permission +"\n"; |
| 994 | + |
| 995 | + //add the Permision info: |
| 996 | + base_resource_desc+='|Permission=' + rObj.pSobj.getPermissionWikiTag( rObj ) +"\n"; |
996 | 997 | |
997 | 998 | if( rObj.other_versions ) |
998 | | - base_resource_desc+='|Other_versions=' + rObj.other_versions + "\n"; |
| 999 | + base_resource_desc+='|other_versions=' + rObj.other_versions + "\n"; |
999 | 1000 | |
1000 | 1001 | base_resource_desc+='}}'; |
1001 | 1002 | |
1002 | | - //add in license template tag: |
1003 | | - if( rObj.license_template_tag ) |
1004 | | - base_resource_desc += "\n" + |
1005 | | - '== [[Commons:Copyright tags|Licensing]]: ==' +"\n"+ |
1006 | | - '{{' + rObj.license_template_tag + '}}'; |
| 1003 | + |
1007 | 1004 | |
1008 | 1005 | $j('#rsd_resource_import').remove();//remove any old resource imports |
1009 | 1006 | //@@ show user dialog to import the resource |
— | — | @@ -1039,21 +1036,17 @@ |
1040 | 1037 | }); |
1041 | 1038 | //add bidings: |
1042 | 1039 | $j('#rsd_import_apreview').click(function(){ |
1043 | | - $j('#rsd_import_desc').show().html( |
| 1040 | + /*$j('#rsd_import_desc').show().html( |
1044 | 1041 | mv_get_loading_img() |
1045 | | - ); |
| 1042 | + );*/ |
1046 | 1043 | //load the preview text: |
1047 | 1044 | _this.getParsedWikiText( $j('#rsd_import_ta').val(), _this.cFileNS +':'+ rObj.target_resource_title, function( o ){ |
1048 | 1045 | js_log('got updated preivew: '+ o); |
1049 | 1046 | $j('#rsd_import_desc').html(o); |
1050 | 1047 | }); |
1051 | 1048 | }); |
1052 | | - $j('#rsd_import_doimport').click(function(){ |
1053 | | - //replace the parent with progress bar: |
1054 | | - $j('#rsd_resource_import').html( |
1055 | | - '<h3>Importing asset</h3>'+ |
1056 | | - mv_get_loading_img() |
1057 | | - ); |
| 1049 | + $j('#rsd_import_doimport').click(function(){ |
| 1050 | + |
1058 | 1051 | //get an edittoken: |
1059 | 1052 | do_api_req( { |
1060 | 1053 | 'data': { 'action':'query', |
— | — | @@ -1076,16 +1069,16 @@ |
1077 | 1070 | }); |
1078 | 1071 | }else{ |
1079 | 1072 | //not sure if we can do remote url uploads (so just do a local post) |
1080 | | - js_log('got token for new page:' +editToken); |
| 1073 | + js_log('got token for new page:' +editToken); |
1081 | 1074 | var postVars = { |
1082 | 1075 | 'wpSourceType' :'web', |
1083 | | - 'wpUploadFileURL' : rObj.url, |
| 1076 | + 'wpUploadFileURL' : rObj.src, |
1084 | 1077 | 'wpDestFile' : rObj.target_resource_title, |
1085 | | - 'wpUploadDescription':$j('#rsd_import_ta').val(), |
1086 | | - 'wpWatchthis' : $j('#wpWatchthis').val(), |
| 1078 | + 'wpUploadDescription': $j('#rsd_import_ta').val(), |
| 1079 | + 'wpWatchthis' : $j('#wpWatchthis').val(), |
1087 | 1080 | 'wpUpload' : 'Upload file' |
1088 | 1081 | } |
1089 | | - //set to uploading: |
| 1082 | + //set to uploading: |
1090 | 1083 | $j('#rsd_resource_import').append('<div id="rsd_import_progress"'+ |
1091 | 1084 | 'style="position:absolute;top:0px;'+ |
1092 | 1085 | 'left:0px;width:100%;height:100%;'+ |
— | — | @@ -1275,9 +1268,9 @@ |
1276 | 1269 | var out = gM('rsd_results_desc') + ' ' + (cp.offset+1) + ' to ' + to_num; |
1277 | 1270 | //check if we have more results (next prev link) |
1278 | 1271 | if( cp.offset >= cp.limit ) |
1279 | | - out+=' <a href="#" id="rsd_pprev">' + gM('rsd_results_prev') + cp.limit + '</a>'; |
| 1272 | + out+=' <a href="#" id="rsd_pprev">' + gM('rsd_results_prev') + ' ' + cp.limit + '</a>'; |
1280 | 1273 | if( cp.sObj.more_results ) |
1281 | | - out+=' <a href="#" id="rsd_pnext">' + gM('rsd_results_next') + cp.limit + '</a>'; |
| 1274 | + out+=' <a href="#" id="rsd_pnext">' + gM('rsd_results_next') + ' ' + cp.limit + '</a>'; |
1282 | 1275 | $j(target).html(out); |
1283 | 1276 | //set bindings |
1284 | 1277 | $j('#rsd_pnext').click(function(){ |
— | — | @@ -1427,7 +1420,7 @@ |
1428 | 1421 | _this.resultsObj[inx] = rObj; |
1429 | 1422 | _this.num_results++; |
1430 | 1423 | }); |
1431 | | - }, |
| 1424 | + }, |
1432 | 1425 | //by default just return the existing image with callback |
1433 | 1426 | getImageObj:function( rObj, size, callback){ |
1434 | 1427 | callback( {'url':rObj.poster} ); |
— | — | @@ -1440,6 +1433,15 @@ |
1441 | 1434 | //no desc avaliable: |
1442 | 1435 | return ''; |
1443 | 1436 | }, |
| 1437 | + //default licence permision wiki text is cc based template mapping (does not confirm the templates actually exist) |
| 1438 | + getPermissionWikiTag: function( rObj ){ |
| 1439 | + //check that its a defined creative commons licnese key: |
| 1440 | + if( typeof this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ){ |
| 1441 | + return '{{Cc-' + rObj.license.key + '}}'; |
| 1442 | + }else if( rObj.license.lurl ) { |
| 1443 | + return '{{Template:External_License|' + rObj.license.lurl + '}}'; |
| 1444 | + } |
| 1445 | + }, |
1444 | 1446 | //by default just return the poster (clients can overide) |
1445 | 1447 | getImageTransform:function(rObj, opt){ |
1446 | 1448 | return rObj.poster; |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvUploader.js |
— | — | @@ -98,6 +98,35 @@ |
99 | 99 | _this.fogg = new mvFirefogg( intFirefoggObj ); |
100 | 100 | |
101 | 101 | }, |
| 102 | + grabWikiFormError:function( result_page ){ |
| 103 | + var res = {}; |
| 104 | + sp = result_page.indexOf('<span class="error">'); |
| 105 | + if(sp!=-1){ |
| 106 | + se = result_page.indexOf('</span>', sp); |
| 107 | + res.error_txt = result_page.substr(sp, (sp-se)) + '</span>'; |
| 108 | + }else{ |
| 109 | + //look for warning: |
| 110 | + sp = result_page.indexOf('<ul class="warning">') |
| 111 | + if(sp!=-1){ |
| 112 | + se = result_page.indexOf('</ul>', sp); |
| 113 | + error_txt = result_page.substr(sp, (se-sp)) + '</ul>'; |
| 114 | + //try and add the ignore form item: |
| 115 | + sfp = result_page.indexOf('<form method="post"'); |
| 116 | + if(sfp!=-1){ |
| 117 | + sfe = result_page.indexOf('</form>', sfp); |
| 118 | + res.form_txt = result_page.substr(sfp, ( sfe - sfp )) + '</form>'; |
| 119 | + } |
| 120 | + }else{ |
| 121 | + //one more error type check: |
| 122 | + sp = result_page.indexOf('class="mw-warning-with-logexcerpt">') |
| 123 | + if(sp!=-1){ |
| 124 | + se = result_page.indexOf('</div>', sp); |
| 125 | + res.error_txt = result_page.substr(sp, ( se - sp )) + '</div>'; |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + return res; |
| 130 | + }, |
102 | 131 | //same add code as specialUpload if($wgEnableFirefogg){ |
103 | 132 | addFirefoggHtml:function(){ |
104 | 133 | var itd_html = $j('#mw-upload-table .mw-input:first').html(); |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js |
— | — | @@ -776,6 +776,28 @@ |
777 | 777 | mv_embed(ready_callback, vid_id ); |
778 | 778 | }); |
779 | 779 | } |
| 780 | +function rewrite_for_oggHanlder( vidIdList ){ |
| 781 | + for(var i = 0; i < vidIdList.length ; i++){ |
| 782 | + var vidId = vidIdList[i]; |
| 783 | + js_log('looking at vid: ' + i +' ' + vidId); |
| 784 | + //grab the thumbnail and src video |
| 785 | + var pimg = $j('#'+vidId + ' img'); |
| 786 | + var poster = pimg.attr('src'); |
| 787 | + var pwidth = pimg.attr('width'); |
| 788 | + var pheight = pimg.attr('height'); |
| 789 | + //reg videoUrl\":\s*"([^"]*) |
| 790 | + |
| 791 | + var re = new RegExp( /videoUrl(":?\s*)*([^&]*)/ ); |
| 792 | + var src = re.exec( $j('#'+vidId).html() )[2]; |
| 793 | + //replace the top div with mv_embed based player: |
| 794 | + if( src && poster) |
| 795 | + $j('#'+vidId).replaceWidth( '<video id="vid_' + i +'" '+ |
| 796 | + 'src="' + src + ' poster="' + poster + '" style="width:' + pwidth + |
| 797 | + 'px;height:' + pheight + 'px;"></video>'; |
| 798 | + //rewrite that video id: |
| 799 | + rewrite_by_id('vid_' + i); |
| 800 | + } |
| 801 | +} |
780 | 802 | |
781 | 803 | |
782 | 804 | /*********** INITIALIZATION CODE ************* |
— | — | @@ -1072,7 +1094,7 @@ |
1073 | 1095 | |
1074 | 1096 | //does a remote or local api request based on request url |
1075 | 1097 | //@param options: url, data, cbParam, callback |
1076 | | -function do_api_req( options, callback ){ |
| 1098 | +function do_api_req( options, callback ){ |
1077 | 1099 | if(typeof options.data != 'object'){ |
1078 | 1100 | js_log('Error: request paramaters must be an object'); |
1079 | 1101 | return false; |
— | — | @@ -1092,12 +1114,13 @@ |
1093 | 1115 | |
1094 | 1116 | //force format to json (if not already set) |
1095 | 1117 | options.data['format'] = 'json'; |
1096 | | - |
| 1118 | + |
| 1119 | + js_log('do api req: ' + options.url + options.data); |
1097 | 1120 | //build request string: |
1098 | 1121 | if( parseUri( document.URL ).host == parseUri( options.url ).host ){ |
1099 | 1122 | //local request do api request directly |
1100 | 1123 | $j.ajax({ |
1101 | | - type: "GET", |
| 1124 | + type: "POST", |
1102 | 1125 | url: options.url, |
1103 | 1126 | data: options.data, |
1104 | 1127 | dataType:'json', //api requests _should_ always return JSON data: |
— | — | @@ -1105,8 +1128,8 @@ |
1106 | 1129 | success:function(data){ |
1107 | 1130 | callback( data ); |
1108 | 1131 | }, |
1109 | | - error:function(){ |
1110 | | - js_error( ' error in getting: ' + options.url); |
| 1132 | + error:function(e){ |
| 1133 | + js_error( ' error' + e +' in getting: ' + options.url); |
1111 | 1134 | } |
1112 | 1135 | }); |
1113 | 1136 | }else{ |
— | — | @@ -1150,6 +1173,7 @@ |
1151 | 1174 | loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1)); |
1152 | 1175 | } |
1153 | 1176 | } |
| 1177 | + |
1154 | 1178 | function mv_jsdata_cb(response){ |
1155 | 1179 | js_log('f:mv_jsdata_cb:'+ response['cb_inx']); |
1156 | 1180 | //run the callback from the global req cb object: |