r55465 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55464‎ | r55465 | r55466 >
Date:05:57, 22 August 2009
Author:dale
Status:deferred
Tags:
Comment:
* Fixed some AMW regressions.
* Fixed upload destination check
* Localized more of AMW
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/mv_embed.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /trunk/phase3/js2/uploadPage.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -36,7 +36,17 @@
3737 "uploaded_itmes" : "Uploaded Items:",
3838
3939 "your_recent_uploads" : "Your Recent Uploads",
40 - "upload_a_file": "Upload a New File"
 40+ "upload_a_file": "Upload a New File",
 41+
 42+ "resource_page_desc":"Resource Page Description:",
 43+ "edit_resource_desc": "Edit WikiText Resource Description:",
 44+ "local_resource_title": "Local Resource Title:",
 45+ "watch_this_page": "Watch this page",
 46+ "do_import_resource": "Do Import Resource",
 47+ "update_preview": "Update Preview",
 48+ "cancel_import": "Cancel Import",
 49+ "importing_asset" : "Importing Asset",
 50+ "preview_insert_resource": "Preview Insert of Resource: $1"
4151 });
4252 var default_remote_search_options = {
4353 'profile':'mediawiki_edit',
@@ -96,11 +106,12 @@
97107 * sets the default display item:
98108 * can be any content_providers key or 'all'
99109 */
100 - disp_item : 'upload',
 110+ disp_item : 'wiki_commons',
101111 /** the default content providers list.
102112 *
103113 * (should be note that special tabs like "upload" and "combined" don't go into the content proviers list:
104 - *
 114+ * @note do not use double underscore in content providers names (used for id lookup)
 115+ *
105116 * @@todo we will want to load more per user-preference and per category lookup
106117 */
107118 content_providers:{
@@ -562,93 +573,95 @@
563574 var _this = this;
564575 //set it to loading:
565576 mv_set_loading('#tab-upload');
566 -
567 - //do config variable reality checks:
568 - if( _this.upload_api_target == 'local' ){
569 - if( ! _this.local_wiki_api_url ){
570 - $j('#tab-upload').html( gM( 'rsd_config_error', 'missing_local_api_url' ) );
 577+ //do things async to keep interface snapy
 578+ setTimeout(function(){
 579+ //do config variable reality checks:
 580+ if( _this.upload_api_target == 'local' ){
 581+ if( ! _this.local_wiki_api_url ){
 582+ $j('#tab-upload').html( gM( 'rsd_config_error', 'missing_local_api_url' ) );
 583+ return false;
 584+ }else{
 585+ _this.upload_api_target = _this.local_wiki_api_url;
 586+ }
 587+ }
 588+ //make sure we have a url for the upload target:
 589+ if( parseUri( _this.upload_api_target ).host == _this.upload_api_target ){
 590+ $j('#tab-upload').html( gM('rsd_config_error', 'bad_api_url') );
571591 return false;
572 - }else{
573 - _this.upload_api_target = _this.local_wiki_api_url;
574592 }
575 - }
576 - //make sure we have a url for the upload target:
577 - if( parseUri( _this.upload_api_target ).host == _this.upload_api_target ){
578 - $j('#tab-upload').html( gM('rsd_config_error', 'bad_api_url') );
579 - return false;
580 - }
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(){
 593+ //output the form
 594+ //set the form action based on domain:
 595+ if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
 596+ mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
 597+
 598+ //get extened info about the file
 599+ var cp = _this.content_providers['this_wiki'];
 600+ //check for "this_wiki" enabled
 601+ if(!cp.enabled){
 602+ $j('#tab-upload').html('error this_wiki not enabled (can\'t get uploaded file info)');
 603+ return false;
 604+ }
585605
586 - //get extened info about the file
587 - var cp = _this.content_providers['this_wiki'];
588 - //check for "this_wiki" enabled
589 - if(!cp.enabled){
590 - $j('#tab-upload').html('error this_wiki not enabled (can\'t get uploaded file info)');
591 - return false;
592 - }
593 -
594 - //load this_wiki search system to grab the rObj
595 - _this.loadSearchLib(cp, function(){
596 - //do basic layout form on left upload "bin" on right
597 - $j('#tab-upload').html('<table cellspacing="10">' +
598 - '<tr>' +
599 - '<td valign="top" style="width:350px;">' +
600 - '<h4>' + gM('upload_a_file') + '</h4>' +
601 - '<div id="upload_form">' +
602 - mv_get_loading_img() +
603 - '</div>' +
604 - '</td>' +
605 - '<td valign="top" id="upload_bin_cnt">' +
606 - '<h4>' + gM('your_recent_uploads') + '</h4>' +
607 - '<div id="upload_bin">' +
608 - mv_get_loading_img() +
609 - '</div>'+
610 - '</td>' +
611 - '</tr>' +
612 - '</table>');
613 -
614 -
615 - //fill in the user page:
616 - if(typeof wgUserName != 'undefined' && wgUserName){
617 - //load the upload bin with anything the current user has uploaded
618 - cp.sObj.getUserRecentUploads( wgUserName, function(){
619 - _this.drawOutputResults();
620 - });
621 - }else{
622 - $j('#upload_bin_cnt').empty();
623 - }
624 -
625 - //deal with the api form upload form directly:
626 - $j('#upload_form').simpleUploadForm({
627 - "api_target" : _this.upload_api_target ,
628 - "ondone_cb" : function( resultData ){
629 - var wTitle = resultData['wpDestFile'];
630 - //add a loading div
631 - $j( _this.target_container ).append('<div id="temp_edit_loader" '+
632 - 'style="position:absolute;top:0px;left:0px;bottom:5px;right:4px;background-color:#FFF;">' +
633 - mv_get_loading_img('position:absolute;top:30px;left:30px') +
634 - '</div>');
635 - cp.sObj.addByTitle( wTitle, function( rObj ){
636 - $j( _this.target_container ).find('#temp_edit_loader').remove();
637 - //redraw (with added result if new)
638 - _this.drawOutputResults();
639 - //pull up recource editor:
640 - _this.resourceEdit( rObj, $j('#res_upload_' + rObj.id).get(0) );
641 - });
642 - //return false to close progress window:
643 - return false;
644 - }
645 - })
 606+ //load this_wiki search system to grab the rObj
 607+ _this.loadSearchLib(cp, function(){
 608+ //do basic layout form on left upload "bin" on right
 609+ $j('#tab-upload').html('<table cellspacing="10">' +
 610+ '<tr>' +
 611+ '<td valign="top" style="width:350px;">' +
 612+ '<h4>' + gM('upload_a_file') + '</h4>' +
 613+ '<div id="upload_form">' +
 614+ mv_get_loading_img() +
 615+ '</div>' +
 616+ '</td>' +
 617+ '<td valign="top" id="upload_bin_cnt">' +
 618+ '<h4>' + gM('your_recent_uploads') + '</h4>' +
 619+ '<div id="upload_bin">' +
 620+ mv_get_loading_img() +
 621+ '</div>'+
 622+ '</td>' +
 623+ '</tr>' +
 624+ '</table>');
 625+
 626+
 627+ //fill in the user page:
 628+ if(typeof wgUserName != 'undefined' && wgUserName){
 629+ //load the upload bin with anything the current user has uploaded
 630+ cp.sObj.getUserRecentUploads( wgUserName, function(){
 631+ _this.drawOutputResults();
 632+ });
 633+ }else{
 634+ $j('#upload_bin_cnt').empty();
 635+ }
 636+
 637+ //deal with the api form upload form directly:
 638+ $j('#upload_form').simpleUploadForm({
 639+ "api_target" : _this.upload_api_target ,
 640+ "ondone_cb" : function( resultData ){
 641+ var wTitle = resultData['wpDestFile'];
 642+ //add a loading div
 643+ $j( _this.target_container ).append('<div id="temp_edit_loader" '+
 644+ 'style="position:absolute;top:0px;left:0px;bottom:5px;right:4px;background-color:#FFF;">' +
 645+ mv_get_loading_img('position:absolute;top:30px;left:30px') +
 646+ '</div>');
 647+ cp.sObj.addByTitle( wTitle, function( rObj ){
 648+ $j( _this.target_container ).find('#temp_edit_loader').remove();
 649+ //redraw (with added result if new)
 650+ _this.drawOutputResults();
 651+ //pull up recource editor:
 652+ _this.resourceEdit( rObj, $j('#res_upload_' + rObj.id).get(0) );
 653+ });
 654+ //return false to close progress window:
 655+ return false;
 656+ }
 657+ })
 658+ });
646659 });
647 - });
648 - }else{
649 - //setup the proxy
650 - js_log('do proxy:: ' + parseUri( _this.upload_api_target ).host);
651 - $j('#tab-upload').html('proxy upload not yet ready');
652 - }
 660+ }else{
 661+ //setup the proxy
 662+ js_log('do proxy:: ' + parseUri( _this.upload_api_target ).host);
 663+ $j('#tab-upload').html('proxy upload not yet ready');
 664+ }
 665+ },1);
653666 },
654667 runSearch: function(){
655668 js_log("f:runSearch::" + this.disp_item);
@@ -931,22 +944,21 @@
932945 },
933946 //@@todo we could load the id with the content provider id to find the object faster...
934947 getResourceFromId:function( rid ){
935 - //js_log('getResourceFromId:' + rid );
 948+ js_log('getResourceFromId:' + rid );
936949 //strip out /res/ if preset:
937950 rid = rid.replace(/res_/, '');
938951 //js_log("looking at: " + rid);
939 - p = rid.split('_');
 952+ p = rid.split('__');
940953 var cp_id = p[0];
941954 var rid = p[1];
 955+
942956 if(cp_id == 'upload')
943957 cp_id = 'this_wiki';
944958
945959 var cp = this.content_providers[cp_id];
946 -
947 - if(cp['sObj'] && cp.sObj.resultsObj[rid]){
 960+ if(cp && cp['sObj'] && cp.sObj.resultsObj[rid]){
948961 return cp.sObj.resultsObj[rid];
949962 }
950 -
951963 js_log("ERROR: could not find " + rid);
952964 return false;
953965 },
@@ -983,7 +995,7 @@
984996 rItem.poster = mv_skin_img_path + 'sound_music_icon-80.png';
985997 }
986998 //get a thumb with proper resolution transform if possible:
987 - o+='<img title="'+rItem.title+'" class="rsd_res_item" id="res_' + cp_id + '_' + rInx +
 999+ o+='<img title="'+rItem.title+'" class="rsd_res_item" id="res_' + cp_id + '__' + rInx +
9881000 '" style="width:' + _this.thumb_width + 'px;" src="' +
9891001 cp.sObj.getImageTransform( rItem, {'width':_this.thumb_width } )
9901002 + '">';
@@ -1110,8 +1122,8 @@
11111123 });
11121124
11131125
1114 - //assume we keep aspect ratio for the thumbnail that we clicked:
1115 - var tRatio = $j(rsdElement).height() / $j(rsdElement).width();
 1126+ //try and keep aspect ratio for the thumbnail that we clicked:
 1127+ var tRatio = $j('#rsd_edit_img').height() / $j('#rsd_edit_img').width();
11161128 if( ! tRatio )
11171129 var tRatio = 1; //set ratio to 1 if the width of the thumbnail can't be found for some reason
11181130
@@ -1123,8 +1135,8 @@
11241136 'left':'5px',
11251137 'width': maxWidth + 'px',
11261138 'height': parseInt( tRatio * maxWidth) + 'px'
1127 - }, "slow"); // do it slow to give it a chance to finish loading the HQ version
1128 -
 1139+ }, "slow"); // do it slow to give it a chance to finish loading the HQ version
 1140+
11291141 if( mediaType == 'image' ){
11301142 _this.loadHQImg(rObj, {'width':maxWidth}, 'rsd_edit_img', function(){
11311143 $j('.mv_loading_img').remove();
@@ -1341,7 +1353,7 @@
13421354 wt += '|Description= ' + gM('missing_desc_see_soruce', rObj.link ) + "\n";
13431355 }
13441356
1345 - //output person and bill info if
 1357+ //output search specific info
13461358 wt+='|Source=' + rObj.pSobj.getImportResourceDescWiki( rObj ) + "\n";
13471359
13481360 if( rObj.author )
@@ -1357,11 +1369,13 @@
13581370 wt+='|other_versions=' + rObj.other_versions + "\n";
13591371
13601372 wt+='}}';
 1373+
13611374 //get any extra categories or helpful links
13621375 wt+= rObj.pSobj.getExtraResourceDescWiki( rObj );
13631376
13641377
13651378 $j('#rsd_resource_import').remove();//remove any old resource imports
 1379+
13661380 //@@ show user dialog to import the resource
13671381 $j( _this.target_container ).append('<div id="rsd_resource_import" '+
13681382 'class="ui-state-highlight ui-widget-content ui-state-error" ' +
@@ -1370,27 +1384,27 @@
13711385 '<div id="rsd_preview_import_container" style="position:absolute;width:50%;bottom:0px;left:0px;overflow:auto;top:30px;">' +
13721386 rObj.pSobj.getEmbedHTML( rObj, {'id': _this.target_container + '_rsd_pv_vid', 'max_height':'200','only_poster':true} )+ //get embedHTML with small thumb:
13731387 '<br style="clear both">'+
1374 - '<strong>Resource Page Description:</strong>'+
 1388+ '<strong>'+gM('resource_page_desc') +'</strong>'+
13751389 '<div id="rsd_import_desc" syle="display:inline;">'+
13761390 mv_get_loading_img('position:absolute;top:5px;left:5px') +
13771391 '</div>'+
13781392 '</div>'+
13791393 '<div id="rds_edit_import_container" style="position:absolute;left:50%;' +
13801394 'bottom:0px;top:30px;right:0px;overflow:auto;">'+
1381 - '<strong>Local Resource Title:</strong><br>'+
 1395+ '<strong>' + gM('local_resource_title') + '</strong><br>'+
13821396 '<input type="text" size="30" value="' + rObj.target_resource_title + '" readonly="true"><br>'+
1383 - '<strong>Edit WikiText Resource Description:</strong>(will be replaced by forms soon)' +
 1397+ '<strong>' + gM('edit_resource_desc') + '</strong>' +
13841398 '<textarea id="rsd_import_ta" id="mv_img_desc" style="width:90%;" rows="8" cols="50">' +
13851399 wt +
13861400 '</textarea><br>' +
13871401 '<input type="checkbox" value="true" id="wpWatchthis" name="wpWatchthis" tabindex="7"/>' +
1388 - '<label for="wpWatchthis">Watch this page</label><br><br><br>' +
 1402+ '<label for="wpWatchthis">'+gM('watch_this_page')+'</label><br><br><br>' +
13891403
1390 - $j.btnHtml('Do Import Resource', 'rsd_import_doimport', 'check' ) + ' ' +
 1404+ $j.btnHtml(gM('do_import_resource'), 'rsd_import_doimport', 'check' ) + ' ' +
13911405
1392 - $j.btnHtml('Update Preview', 'rsd_import_apreview', 'refresh' ) + '<div style="clear:both;height:20px;"/>' +
 1406+ $j.btnHtml(gM('update_preview'), 'rsd_import_apreview', 'refresh' ) + '<div style="clear:both;height:20px;"/>' +
13931407
1394 - $j.btnHtml('Cancel Import', 'rsd_import_acancel', 'close' ) + ' ' +
 1408+ $j.btnHtml(gM('cancel_import'), 'rsd_import_acancel', 'close' ) + ' ' +
13951409
13961410 '</div>'+
13971411 //output the rendered and non-renderd version of description for easy swiching:
@@ -1526,7 +1540,7 @@
15271541 'style="position:absolute;top:0px;'+
15281542 'left:0px;width:100%;height:100%;'+
15291543 'z-index:5;background:#FFF;overflow:auto;">'+
1530 - '<div style="position:absolute;left:30%;right:30%"><h3>Importing Asset</h3><br>' +
 1544+ '<div style="position:absolute;left:30%;right:30%"><h3>'+gM('importing_asset')+'</h3><br>' +
15311545 mv_get_loading_img('','mv_loading_bar_img') +
15321546 '</div>'+
15331547 '</div>'
@@ -1558,7 +1572,7 @@
15591573 js_log( 'error text is: ' + error_txt );
15601574 $j( '#rsd_resource_import' ).html( '<h3>Error</h3>' + error_txt + '<br>' + form_txt +
15611575 '<br>'+
1562 - '<a href="#" id="rsd_import_error" >Cancel import</a>'
 1576+ '<a href="#" id="rsd_import_error" >' + gM('cancel_import') + '</a>'
15631577 );
15641578 //set up cancel action:
15651579 $j('#rsd_import_error').click(function(){
@@ -1581,12 +1595,12 @@
15821596 'style="position:absolute;overflow:hidden;z-index:4;top:0px;bottom:75px;right:0px;left:0px;background-color:#FFF;">' +
15831597 mv_get_loading_img('top:30px;left:30px') +
15841598 '</div>');
1585 -
 1599+
15861600 var bPlaneTarget = _this.target_container +'~ .ui-dialog-buttonpane';
15871601 var pTitle = $j( _this.target_container ).dialog('option', 'title');
15881602
15891603 //update title:
1590 - $j( _this.target_container ).dialog('option', 'title', 'Preview Insert of Resource: ' + rObj.title );
 1604+ $j( _this.target_container ).dialog('option', 'title', gM('preview_insert_resource', rObj.title) );
15911605
15921606 //update buttons preview:
15931607 $j(bPlaneTarget).html( $j.btnHtml( gM('rsd_do_insert'), 'preview_do_insert', 'check') + ' ' )
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -667,12 +667,13 @@
668668 '</div>'+
669669 '</div>'
670670 )
 671+ //just display an empty progress window
 672+ $j('#upProgressDialog').dialog('open');
 673+
671674 //setup progress bar:
672 - $j('#up-progressbar').progressbar({
673 - value:0
674 - });
675 - //just display an empty progress window
676 - $j('#upProgressDialog').dialog('open');
 675+ $j('#up-progressbar').progressbar({
 676+ value:0
 677+ });
677678
678679 },
679680 cancel_button:function(){
@@ -695,7 +696,7 @@
696697 }
697698 };
698699
699 -//add some jquery bindings:
 700+//add some jquery binding helpers
700701 (function($) {
701702 /**
702703 * doDestCheck checks the destination
Index: trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js
@@ -78,7 +78,7 @@
7979 function(){
8080 if($j('#gnp_' + embedObj.id).length==0){
8181 $j(this).append('<div id="gnp_' + embedObj.id + '" class="ui-state-highlight ui-corner-all" ' +
82 - 'style="position:absolute;display:none;background:#FFF;top:10px;left:10px;right:10px;height:60px;">' +
 82+ 'style="position:absolute;display:none;background:#FFF;top:10px;left:10px;right:10px;">' +
8383 gM('mv_for_best_experience') +
8484 '<br><input id="ffwarn_'+embedObj.id+'" type=\"checkbox\">' +
8585 gM('mv_do_not_warn_again') +
Index: trunk/phase3/js2/mwEmbed/mv_embed.js
@@ -610,7 +610,7 @@
611611 ];
612612 if(e[0].length!=0 || e[1].length!=0 || e[2].length!=0){
613613 js_log('we have items to rewrite');
614 -
 614+ setSwapableToLoading(e);
615615 //load libs and proccess:
616616 mvJsLoader.embedVideoCheck(function(){
617617 //run any queded global events:
@@ -624,6 +624,14 @@
625625 mvJsLoader.runQuededFunctions();
626626 }
627627 }
 628+//a quick function that sets the intial text of swapable elements to "loading"
 629+// (jquery might not be ready)
 630+//(does not destroy inner elements)
 631+function setSwapableToLoading(e){
 632+ //for(var i =0)
 633+ //for(var j = 0; i < j.length; j++){
 634+ //}
 635+}
628636 //js2AddOnloadHook: ensure jQuery and the DOM are ready:
629637 function js2AddOnloadHook( func ) {
630638 //make sure the skin/style sheets are avaliable always:
Index: trunk/phase3/js2/uploadPage.js
@@ -138,7 +138,9 @@
139139 $j('#wpDestFile').val( fname );
140140
141141 //do a destination check
142 - this.doDestCheck();
 142+ $j('#wpDestFile').doDestCheck({
 143+ 'warn_target':'#wpDestFile-warning'
 144+ });
143145 }
144146 }
145147

Status & tagging log