r55121 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55120‎ | r55121 | r55122 >
Date:23:27, 15 August 2009
Author:dale
Status:deferred
Tags:
Comment:
* msg updates
* firefogg updates for add-media-wizard usage
* more support for simpleUploadFrom usage in add-media-wizard
* some header updates
Modified paths:
  • /trunk/phase3/js2/editPage.js (modified) (history)
  • /trunk/phase3/js2/mwApiProxy.html (added) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libClipEdit/colorpicker/js/colorpicker.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/mv_embed.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/mwHostProxy.html (added) (history)
  • /trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -25,7 +25,7 @@
2626
2727 var default_firefogg_options = {
2828 //what to do when finished uploading
29 - 'upload_done_action':'redirect',
 29+ 'done_upload_cb':false,
3030 //if firefoog is enabled
3131 'fogg_enabled':false,
3232 //the api url to upload to
@@ -476,7 +476,8 @@
477477 get_mw_token(
478478 'File:'+ _this.formData['wpDestFile'],
479479 _this.api_url,
480 - function( eToken ){
 480+ function( eToken ){
 481+ if(eToken==)
481482 _this.etoken = eToken;
482483 _this.doChunkWithFormData();
483484 }
@@ -631,9 +632,18 @@
632633 buttons[gM('go-to-resource')] = function(){
633634 window.location = _this.fogg.resultUrl;
634635 }
635 - var go_to_url_txt = gM('go-to-resource');
636 - //should have an json result:
637 - _this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', _this.fogg.resultUrl),buttons);
 636+ var go_to_url_txt = gM('go-to-resource');
 637+ if( typeof _this.done_upload_cb == 'function' ){
 638+ //if done action return 'true'
 639+ if( _this.done_upload_cb() ){
 640+ //update status
 641+ _this.updateProgressWin( gM('successfulupload'), gM( 'mv_upload_done', _this.fogg.resultUrl),buttons);
 642+ }else{
 643+ //if done action returns 'false' //close progress window
 644+ this.action_done = true;
 645+ $j('#upProgressDialog').dialog('close');
 646+ }
 647+ }
638648 }else{
639649 //done state with error? ..not really possible given how firefogg works
640650 js_log(" upload done, in chunks mode, but no resultUrl!");
@@ -682,14 +692,14 @@
683693 _this.updateProgressWin( gM('mv_upload_completed'), result_txt );
684694
685695 if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){
686 - js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.upload_done_action );
687 - if( _this.upload_done_action == 'redirect' ){
 696+ js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.done_upload_cb );
 697+ if( _this.done_upload_cb == 'redirect' ){
688698 $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + result_txt + '<br>' + form_txt);
689699 window.location = wgArticlePath.replace( /\$1/, 'File:' + _this.formData['wpDestFile'] );
690700 }else{
691701 //check if the add_done_action is a callback:
692 - if( typeof _this.upload_done_action == 'function' )
693 - _this.upload_done_action();
 702+ if( typeof _this.done_upload_cb == 'function' )
 703+ _this.done_upload_cb();
694704 }
695705 }else{
696706 //js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page );
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -577,18 +577,25 @@
578578 $j('#tab-upload').html( gM('rsd_config_error', 'bad_api_url') );
579579 return false;
580580 }
581 - //output the form
582 - mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
583 - //set the form action based on domain:
584 - if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
 581+ //output the form
 582+ //set the form action based on domain:
 583+ if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
 584+ mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
585585 //deal with the api form upload form directly:
586586 $j('#tab-upload').simpleUploadForm({
587 - "api_target" : _this.upload_api_target
 587+ "api_target" : _this.upload_api_target ,
 588+ "ondone_cb" : function( resultData ){
 589+ var cat = resultData;
 590+ debugger;
 591+ return false;
 592+ }
588593 })
589 - }else{
590 - //setup the proxy
591 - }
592 - });
 594+ });
 595+ }else{
 596+ //setup the proxy
 597+ js_log('do proxy:: ' + parseUri( _this.upload_api_target ).host);
 598+ $j('#tab-upload').html('proxy upload not yet ready');
 599+ }
593600 },
594601 runSearch: function(){
595602 js_log("f:runSearch::" + this.disp_item);
@@ -1352,8 +1359,7 @@
13531360 mvJsLoader.doLoad([
13541361 'mvBaseUploadInterface',
13551362 '$j.ui.progressbar'
1356 - ],function(){
1357 -
 1363+ ],function(){
13581364 //initicate a download similar to url copy:
13591365 myUp = new mvBaseUploadInterface({
13601366 'api_url' : _this.local_wiki_api_url,
@@ -1363,7 +1369,9 @@
13641370 //close up the rsd_resource_import
13651371 $j('#rsd_resource_import').remove();
13661372 //run the parent callback:
1367 - cir_callback();
 1373+ cir_callback();
 1374+ //return false to avoid BaseUploadInterface done actions
 1375+ return false;
13681376 }
13691377 });
13701378 //set the edit token if we have it handy
Index: trunk/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js
@@ -11,13 +11,15 @@
1212 "licence_cc-by-sa" : "Creative Commons Share Alike (3.0)",
1313 "upload" : "Upload File",
1414 "destfilename" : "Destination filename:",
15 - "summary" : "Summary"
 15+ "summary" : "Summary",
 16+ "error_not_loggedin" : "You don't appear to be logged in or don't have upload privlages."
1617 });
1718
1819 var default_form_options = {
1920 'enable_fogg' : true,
2021 'licence_options':['cc-by-sa'],
21 - 'api_target' : false
 22+ 'api_target' : false,
 23+ 'ondone_cb' : null
2224 };
2325
2426 (function($) {
@@ -32,55 +34,66 @@
3335 if(!opt.api_target){
3436 $(this.selector).html('Error: Missing api target');
3537 return false;
36 - }
37 -
 38+ }
3839
3940 //@@todo this is just a proof of concept
4041 //much todo to improved this web form
41 - var o = '<div style="margin: 0 auto;">'+
42 - '<form id="suf-upload" enctype="multipart/form-data" action="" method="post">' +
43 - '<label for="wpUploadFile">' + gM('select_file') + '</label><br>'+
44 - '<input type="file" style="display: inline;" name="wpUploadFile" id="wpUploadFile" size="10"/><br>' +
45 - '<label for="wpDestFile">' +gM('destfilename') + '</label><br>'+
46 - '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
47 - '<label for="wpUploadDescription">' + gM('summary') + ':</label><br>' +
48 - '<textarea cols="30" rows="3" id="wpUploadDescription" name="wpUploadDescription" tabindex="3"/><br>'+
49 - gM('select_ownwork') + '<br>' +
50 - '<input type="checkbox" id="wpLicence" name="wpLicence" value="cc-by-sa">' + gM('licence_cc-by-sa') + '<br>' +
51 -
52 - '<input type="submit" accesskey="s" value="' + gM('upload') + '" name="wpUploadBtn" id="wpUploadBtn" tabindex="9"/>' +
53 - //close the form and div
54 - '</form></div>';
 42+ get_mw_token('File:MyRandomFileTokenCheck', opt.api_target, function(eToken){
 43+ debugger;
 44+ if( !eToken || eToken == '+\\' ){
 45+ $(this.selector).html( gM('error_not_loggedin') );
 46+ return false;
 47+ }
5548
56 - //set the target with the form output:
57 - $(this.selector).html( o );
58 - //by default dissable:
59 - $j('#wpUploadBtn').attr('disabled', 'disabled');
60 -
61 - //set up basic binding:
62 - $j('#wpLicence').click(function(){
63 - if( $j(this).is(':checked') ){
64 - $j('#wpUploadBtn').removeAttr('disabled');
65 - }else{
66 - $j('#wpUploadBtn').attr('disabled', 'disabled');
67 - }
68 - });
 49+ var o = '<div style="margin: 0 auto;width:450px;">'+
 50+ '<form id="suf-upload" enctype="multipart/form-data" action="" method="post">' +
 51+ '<label for="wpUploadFile">' + gM('select_file') + '</label><br>'+
 52+ '<input type="file" style="display: inline;" name="wpUploadFile" id="wpUploadFile" size="10"/><br>' +
 53+ '<label for="wpDestFile">' +gM('destfilename') + '</label><br>'+
 54+ '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
 55+ '<label for="wpUploadDescription">' + gM('summary') + ':</label><br>' +
 56+ '<textarea cols="30" rows="3" id="wpUploadDescription" name="wpUploadDescription" tabindex="3"/><br>'+
 57+ gM('select_ownwork') + '<br>' +
 58+ '<input type="checkbox" id="wpLicence" name="wpLicence" value="cc-by-sa">' + gM('licence_cc-by-sa') + '<br>' +
 59+
 60+ '<input type="submit" accesskey="s" value="' + gM('upload') + '" name="wpUploadBtn" id="wpUploadBtn" tabindex="9"/>' +
 61+ //close the form and div
 62+ '</form></div>';
 63+
 64+ //set the target with the form output:
 65+ $( this.selector ).html( o );
 66+ //by default dissable:
 67+ $j('#wpUploadBtn').attr('disabled', 'disabled');
6968
70 - //set up the binding per the config
71 - if( opt.enable_fogg ){
72 - $j('#wpUploadFile').firefogg({
73 - //an api url (we won't submit directly to action of the form)
74 - 'api_url' : opt.api_target,
75 - 'form_rewrite': true,
76 - 'target_edit_from' : '#suf-upload',
77 - 'new_source_cb' : function( orgFilename, oggName ){
78 - $j('#wpDestFile').val( oggName );
79 - //@@TODO:
80 - //mwUploadHelper.doDestCheck();
81 - }
82 - });
83 - }else{
84 - //simple web form rewrite
85 - }
 69+ //set up basic binding:
 70+ $j('#wpLicence').click(function(){
 71+ if( $j(this).is(':checked') ){
 72+ $j('#wpUploadBtn').removeAttr('disabled');
 73+ }else{
 74+ $j('#wpUploadBtn').attr('disabled', 'disabled');
 75+ }
 76+ });
 77+
 78+ if(typeof opt.ondone_cb == 'undefined')
 79+ opt.ondone_cb = false;
 80+
 81+ //set up the binding per the config
 82+ if( opt.enable_fogg ){
 83+ $j('#wpUploadFile').firefogg({
 84+ //an api url (we won't submit directly to action of the form)
 85+ 'api_url' : opt.api_target,
 86+ 'form_rewrite': true,
 87+ 'target_edit_from' : '#suf-upload',
 88+ 'new_source_cb' : function( orgFilename, oggName ){
 89+ $j('#wpDestFile').val( oggName );
 90+ //@@TODO:
 91+ //mwUploadHelper.doDestCheck();
 92+ },
 93+ 'done_upload_cb' : opt.ondone_cb
 94+ });
 95+ }else{
 96+ //simple web form rewrite
 97+ }
 98+ });
8699 }
87100 })(jQuery);
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -31,6 +31,7 @@
3232 "ignorewarning" : "Ignore warning and save file anyway",
3333 "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>",
3434 "go-to-resource" : "Go to Resource Page",
 35+ "upload-misc-error" : "Unknown upload error",
3536
3637 "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension (<a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">more information</a>).",
3738
@@ -696,7 +697,7 @@
697698 };
698699 return cancelBtn;
699700 },
700 - cancel_action:function(dlElm){
 701+ cancel_action : function( dlElm ){
701702 //confirm:
702703 if( confirm( gM('mv-cancel-confim') )){
703704 //@@todo (cancel the encode / upload)
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -2,10 +2,13 @@
33 * the mvPlayList object code
44 * only included if playlist object found
55 *
6 - * part of mv_embed:
7 - * http://metavid.org/wiki/index.php/Mv_embed
 6+ * part of mwEmbed media projects see:
 7+ * http://www.mediawiki.org/wiki/Media_Projects_Overview
 8+ *
 9+ * @author: Michael Dale mdale@wikimedia.org
 10+ * @license GPL2
811 */
9 -var mv_default_playlist_attributes = {
 12+var mv_default_playlist_attributes = {
1013 //playlist attributes :
1114 "id":null,
1215 "title":null,
@@ -27,6 +30,7 @@
2831 //globals:
2932 //10 possible colors for clips: (can be in hexadecimal)
3033 var mv_clip_colors = new Array('aqua', 'blue', 'fuchsia', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red');
 34+
3135 //the base url for requesting stream metadata
3236 if(typeof wgServer=='undefined'){
3337 var defaultMetaDataProvider = 'http://metavid.org/overlay/archive_browser/export_cmml?stream_name=';
@@ -1980,8 +1984,9 @@
19811985 'fill',
19821986 'dur',
19831987 'title',
1984 -
 1988+ //some custom attributes:
19851989 'uri',
 1990+ 'durationHint',
19861991 'poster'
19871992 );
19881993 /* extension to mvClip to support smil properties */
@@ -2039,7 +2044,10 @@
20402045 }
20412046 //parse duration / begin times:
20422047 if( this.dur )
2043 - this.dur = smilParseTime( this.dur );
 2048+ this.dur = smilParseTime( this.dur );
 2049+ //parse the media duration hint ( the source media length)
 2050+ if( this.durationHint )
 2051+ this.durationHint = smilParseTime( this.durationHint );
20442052
20452053 //conform type to vido/ogg:
20462054 if( this.type == 'application/ogg' )
@@ -2077,7 +2085,7 @@
20782086 if( this.dur )
20792087 return this.dur;
20802088 return this.embed.getDuration();
2081 - },
 2089+ },
20822090 //gets the duration of the clip subracting transitions
20832091 getSoloDuration:function(){
20842092 var fulldur = this.getDuration();
@@ -2087,6 +2095,13 @@
20882096
20892097 //js_log("getSoloDuration:: td: " + this.getDuration() + ' sd:' + fulldur);
20902098 return fulldur;
 2099+ },
 2100+ //gets the duration of the original media asset (usefull for bounding setting of in-out-points)
 2101+ getSourceDuration:function(){
 2102+ if( this.durationHint )
 2103+ return this.durationHint;
 2104+ //if we have no source duration just return the media dur:
 2105+ return this.getDuration();
20912106 }
20922107 }
20932108 /*
Index: trunk/phase3/js2/mwEmbed/libClipEdit/colorpicker/js/colorpicker.js
@@ -6,7 +6,6 @@
77 * Dual licensed under the MIT and GPL licenses
88 *
99 */
10 -
1110 (function ($) {
1211 var ColorPicker = function () {
1312 var
Index: trunk/phase3/js2/mwEmbed/mwHostProxy.html
@@ -0,0 +1,43 @@
 2+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3+"http://www.w3.org/TR/html4/loose.dtd">
 4+<html>
 5+<head>
 6+ <title></title>
 7+ <script type="text/javascript">
 8+ /*
 9+ XDCommsChild - Cross Domain Communication, Child Object.
 10+
 11+ Create this in the child window with the address of the xdomaincomms.html file on the same domain as the parent window
 12+ */
 13+ var XDCommsChild = function(xdomaincommsAddress) {
 14+ this.xdomaincommsAddress = xdomaincommsAddress;
 15+
 16+ this.isIe = isInternetExplorer();
 17+
 18+ if (isIe) {
 19+ // need hidden frame for communication. IE8 is supposed to support postMessage, but I can't get it to work properly
 20+ document.writeln("")
 21+ }
 22+
 23+ this.postBack = function(data) {
 24+ if (isIe) {
 25+ // this method tested against IE6,7 & 8
 26+ window.open(this.xdomaincommsAddress + '#data=' + data, 'xdcomms'); // MUST use window.open. frame.src or frame.location both fail
 27+ } else {
 28+ // for everything else - tested against Firefox 3, Chrome, Safari
 29+ window.opener.postMessage(data, '*'); // should really restrict the domain data can come from here
 30+ }
 31+ }
 32+
 33+ this.postBackAndCloseWindow = function(data){
 34+ this.postBack(data);
 35+ setTimeout("window.close()", 200); // need to use a timeout to make sure the javascript in the frame has executed if we are using that communication model
 36+ }
 37+ }
 38+ </script>
 39+</head>
 40+<body>
 41+<h3> This file should be inclued by external sites that want to be proxied: </h3>
 42+</body>
 43+</html>
 44+
Index: trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php
@@ -41,6 +41,7 @@
4242 'ignorewarning' => 'Ignore warning and save file anyway',
4343 'file-thumbnail-no' => 'The filename begins with <b><tt>$1</tt></b>',
4444 'go-to-resource' => 'Go to Resource Page',
 45+ 'upload-misc-error' => 'Unknown upload error',
4546 'wgfogg_waring_bad_extension' => 'You have selected a file with an unsuported extension (<a href="http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types">more information</a>).',
4647 'cancel-button' => 'Cancel',
4748 'ok-button' => 'OK',
Index: trunk/phase3/js2/mwEmbed/mv_embed.js
@@ -232,8 +232,9 @@
233233
234234 //depencency mapping for css files for self contained included plugins:
235235 lcCssPath({
236 - '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
237 - '$j.fn.ColorPicker': 'libClipEdit/colorpicker/css/colorpicker.css'
 236+ '$j.ui' : 'jquery/' + jQueryUiVN + '.custom.css',
 237+ '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
 238+ '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css'
238239 })
239240
240241 /**
@@ -1191,7 +1192,7 @@
11921193 //prepend json_ to feed_format if not already requesting json format
11931194 if( req_url.indexOf("feed_format=")!=-1 && req_url.indexOf("feed_format=json")==-1)
11941195 req_url = req_url.replace(/feed_format=/, 'feed_format=json_');
1195 - loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1));
 1196+ loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + (global_req_cb.length-1));
11961197 }
11971198 }
11981199
@@ -1238,7 +1239,7 @@
12391240 global_req_cb[response['cb_inx']]( response['pay_load'] );
12401241 }
12411242 //load external js via dom injection
1242 -function loadExternalJs( url ){
 1243+function loadExternalJs( url, callback ){
12431244 js_log('load js: '+ url);
12441245 //if(window['$j']) //use jquery call:
12451246 /*$j.ajax({
@@ -1251,11 +1252,13 @@
12521253 var e = document.createElement("script");
12531254 e.setAttribute('src', url);
12541255 e.setAttribute('type',"text/javascript");
 1256+ /*if(callback)
 1257+ e.onload = callback;
 1258+ */
12551259 //e.setAttribute('defer', true);
1256 - document.getElementsByTagName("head")[0].appendChild(e);
 1260+ document.getElementsByTagName("head")[0].appendChild(e);
12571261 // }
12581262 }
1259 -
12601263 function styleSheetPresent(url){
12611264 style_elements = document.getElementsByTagName('link');
12621265 if( style_elements.length > 0) {
Index: trunk/phase3/js2/mwApiProxy.html
@@ -0,0 +1,31 @@
 2+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3+"http://www.w3.org/TR/html4/loose.dtd">
 4+<html>
 5+<head>
 6+ <title>Javascript Api Proxy</title>
 7+ <style type="text/css">
 8+ body{
 9+ font-size:80%;
 10+ }
 11+ img {
 12+ border:medium none;
 13+ }
 14+ </style>
 15+ <script type="text/javascript">
 16+ var domainList = [
 17+ '127.0.0.1'
 18+ ];
 19+ </script>
 20+</head>
 21+<body>
 22+<h3> This file proxies api and html output for source domains: </h3>
 23+<div id="domainList"></div>
 24+ <script type="text/javascript">
 25+ var o='';
 26+ for( var i in domainList){
 27+ o+='<br><i>'+ domainList[i] + '</i>';
 28+ }
 29+ </script>
 30+</body>
 31+</html>
 32+
Index: trunk/phase3/js2/editPage.js
@@ -32,8 +32,8 @@
3333 );
3434
3535 //add to new toolbar (need to use api)
36 - //$j('[rel=insert] .tool-file').addMediaWiz(
37 - // mwAddMediaConfig
38 - //);
 36+ /*$j('[rel=insert] tool-file').addMediaWiz(
 37+ mwAddMediaConfig
 38+ );*/
3939 }
4040 }

Status & tagging log