r74331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74330‎ | r74331 | r74332 >
Date:23:13, 5 October 2010
Author:dale
Status:deferred
Tags:
Comment:
* sync extension with mwEmbedStandAlone addMedia updates
Modified paths:
  • /trunk/extensions/AddMediaWizard/AddMedia/AddMedia.i18n.php (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/jquery.dragDropFile.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/loader.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.Firefogg.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.FirefoggGUI.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.UploadForm.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/mw.UploadHandler.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/searchLibs/flickrSearch.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /trunk/extensions/AddMediaWizard/ClipEdit/mw.ClipEdit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AddMediaWizard/AddMedia/mw.UploadHandler.js
@@ -85,12 +85,12 @@
8686 // Update the selecto to include pointer to upload handler
8787 var selectorElement = $j( this.selector ).get( 0 );
8888 selectorElement[ 'uploadHandler' ] = myUpload;
89 - }
 89+ };
9090 } )( jQuery );
9191
9292 mw.UploadHandler = function( options ) {
9393 return this.init( options );
94 -}
 94+};
9595
9696 mw.UploadHandler.prototype = {
9797
@@ -232,7 +232,7 @@
233233 'name': 'comment',
234234 'type' : 'hidden'
235235 })
236 - )
 236+ );
237237 }
238238
239239 var uploadDesc = _this.getUploadDescription();
@@ -305,7 +305,7 @@
306306 } else if ( _this.upload_mode == 'autodetect' ) {
307307 mw.log( 'detectUploadMode::' + _this.upload_mode + ' api:' + _this.apiUrl );
308308 if( !_this.apiUrl ) {
309 - mw.log( 'Error: can\'t autodetect mode without api url' );
 309+ mw.log( 'Error: cant autodetect mode without api url' );
310310 return;
311311 }
312312
@@ -320,7 +320,7 @@
321321 return mw.log( 'Error: bad api results' );
322322 }
323323 if ( typeof data.paraminfo.modules[0].classname == 'undefined' ) {
324 - mw.log( 'Autodetect Upload Mode: \'post\' ' );
 324+ mw.log( 'Autodetect Upload Mode: post ' );
325325 _this.upload_mode = 'post';
326326 callback( 'post' );
327327 } else {
@@ -398,7 +398,7 @@
399399 'name' : "action",
400400 'value' : "upload"
401401 })
402 - )
 402+ );
403403 }
404404
405405 // Add JSON response format (jsonfm so that IE does not prompt save dialog box on iframe result )
@@ -410,7 +410,7 @@
411411 'name' : "format",
412412 'value' : "jsonfm"
413413 })
414 - )
 414+ );
415415 }
416416
417417 // Map a new hidden form
@@ -504,7 +504,7 @@
505505 'comment' : this.getUploadDescription(),
506506 'watch' : ( $j( '#wpWatchthis' ).is( ':checked' ) ) ? 'true' : 'false',
507507 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false'
508 - }
 508+ };
509509 this.doHttpUpload( httpUpConf );
510510 },
511511
@@ -535,7 +535,7 @@
536536
537537 // Run the JS equivalent of SpecialUpload.php getInitialPageText
538538 comment_value = this.getCommentText( comment_value, license, copyStatus, source );
539 - this.rewriteDescriptionText = false;
 539+ //this.rewriteDescriptionText = false;
540540 }
541541 mw.log( 'getUploadDescription:: new val:' + comment_value );
542542 return comment_value;
@@ -552,15 +552,15 @@
553553 * @param {String} source The source filed
554554 */
555555 getCommentText: function( comment, license, copyStatus, source ) {
556 - var pageText = '== ' + gM( 'filedesc' ) + " ==\n" + comment + "\n";
 556+ var pageText = '== ' + gM( 'mwe-filedesc' ) + " ==\n" + comment + "\n";
557557 if( copyStatus ){
558 - pageText += '== ' + gM( 'filestatus' ) + " ==\n" + copyStatus + "\n";
 558+ pageText += '== ' + gM( 'mwe-filestatus' ) + " ==\n" + copyStatus + "\n";
559559 }
560560 if( source ){
561 - pageText += '== ' + gM( 'filesource' ) + " ==\n" + source + "\n";
 561+ pageText += '== ' + gM( 'mwe-filesource' ) + " ==\n" + source + "\n";
562562 }
563563 if ( license ) {
564 - pageText += '== ' + gM( 'license-header' ) + " ==\n" + '{{' + license + '}}' + "\n";
 564+ pageText += '== ' + gM( 'mwe-license-header' ) + " ==\n" + '{{' + license + '}}' + "\n";
565565 }
566566 return pageText;
567567 },
@@ -771,7 +771,7 @@
772772 if ( apiRes.upload && apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ) {
773773 // Call the completion callback if available.
774774 if ( typeof _this.doneUploadCb == 'function' ) {
775 - _this.doneUploadCb( apiRes )
 775+ _this.doneUploadCb( apiRes );
776776 // Close the ui
777777 _this.ui.close();
778778 return true;
@@ -833,7 +833,7 @@
834834 _this.processApiResult( data );
835835 } );
836836 } else {
837 - mw.log( 'No session key re-sending upload' )
 837+ mw.log( 'No session key re-sending upload' );
838838 //Do a stashed upload
839839 $j( '#wpIgnoreWarning' ).attr( 'checked', true );
840840 $j( _this.form ).submit();
@@ -876,7 +876,7 @@
877877 this.editToken = $j("form[name='token']").val();
878878 }
879879 if( !this.editToken ){
880 - mw.log("Error: can not find edit token ")
 880+ mw.log("Error: can not find edit token ");
881881 return false;
882882 }
883883 return this.editToken;
@@ -948,14 +948,14 @@
949949
950950 if ( !data || !data.query || !data.query.pages ) {
951951 // Ignore a null result
952 - mw.log(" No data in DestCheck result")
 952+ mw.log(" No data in DestCheck result");
953953 return;
954954 }
955955
956956 if ( data.query.pages[-1] ) {
957957 // No conflict found
958 - mw.log(" No pages in DestCheck result")
959 - return;
 958+ mw.log(" No pages in DestCheck result");
 959+ return false;
960960 }
961961 for ( var page_id in data.query.pages ) {
962962 if ( !data.query.pages[ page_id ].imageinfo ) {
@@ -966,7 +966,7 @@
967967 if ( data.query.normalized ) {
968968 var ntitle = data.query.normalized[0].to;
969969 } else {
970 - var ntitle = data.query.pages[ page_id ].title
 970+ var ntitle = data.query.pages[ page_id ].title;
971971 }
972972 var img = data.query.pages[ page_id ].imageinfo[0];
973973
@@ -983,7 +983,7 @@
984984 .attr( linkAttr )
985985 .text( ntitle )
986986 )
987 - )
 987+ );
988988
989989 var $imageLink = $j('<a />')
990990 .addClass( 'image' )
@@ -1039,5 +1039,6 @@
10401040 );
10411041 }
10421042 } );
1043 - }
 1043+ };
 1044+
10441045 })( jQuery );
Index: trunk/extensions/AddMediaWizard/AddMedia/searchLibs/mediaWikiSearch.js
@@ -28,33 +28,53 @@
2929 * @param {String} title Title of the resource to be added
3030 * @param {Function} callback Function called once title resource acquired
3131 */
32 - addByTitle:function( title , callback, redirect_count ) {
 32+ getByTitle:function( title , callback ) {
3333
34 - mw.log( "AddByTitle::" + title );
 34+ mw.log( "MediaWikiSearch:: getByTitle:" + title );
3535
36 - var _this = this;
37 - if ( !redirect_count )
38 - redirect_count = 0;
39 - if ( redirect_count > 5 ) {
40 - mw.log( 'Error: addByTitle too many redirects' );
41 - callback( false );
42 - return false;
43 - }
 36+ var _this = this;
 37+
4438 var request = {
45 - 'titles':'File:' + title,
46 - 'prop':'imageinfo|revisions|categories',
47 - 'iiprop':'url|mime|size',
48 - 'iiurlwidth': parseInt( this.rsd.thumb_width ),
49 - 'rvprop':'content',
 39+ 'titles' : 'File:' + title.replace(/File:|Image:/ig, ''),
 40+ 'prop' : 'imageinfo|revisions|categories',
 41+ 'iiprop' : 'url|mime|size|metadata',
 42+ 'iiurlwidth' : parseInt( this.rsd.thumb_width ),
 43+ 'rvprop' : 'content',
5044 'redirects' : true
5145 }
52 - mw.getJSON(this.provider.apiUrl, request, function( data ) {
 46+ mw.getJSON( this.provider.apiUrl, request, function( data ) {
5347 // call addSingleResult
5448 callback( _this.addSingleResult( data ) );
5549 });
5650 },
57 -
 51+
 52+ getResourceFromUrl: function( url, callback ){
 53+ var title = this.getTitleKeyFromMwUrl( url );
 54+ if( !title) {
 55+ callback( false );
 56+ return ;
 57+ }
 58+ this.getByTitle(title , callback );
 59+ },
5860 /**
 61+ * Does best effort to get the title key from a mediawiki url
 62+ */
 63+ getTitleKeyFromMwUrl: function( url ){
 64+ // try for title key param
 65+ var titleKey = mw.parseUri( url ).queryKey['title'];
 66+ if( titleKey ){
 67+ return titleKey;
 68+ }
 69+ // else try for title url map
 70+ titleKey = url.replace( this.provider.detailsUrl.replace( '$1', ''), '' );
 71+ if( titleKey != url ){
 72+ return titleKey;
 73+ }
 74+ mw.log("Error: mediaWikiSearch:: getResourceFromUrl could not get title form url: " + url );
 75+ return false;
 76+ },
 77+
 78+ /**
5979 * Get recent upload by user and add them as results
6080 *
6181 * @param {String} user Name of the user
@@ -88,7 +108,7 @@
89109 var resourceQuery = {
90110 'titles' : titleStr,
91111 'prop' : 'imageinfo|revisions|categories',
92 - 'iiprop' : 'url|mime|size',
 112+ 'iiprop' : 'url|mime|size|metadata',
93113 'iiurlwidth': parseInt( _this.rsd.thumb_width ),
94114 'rvprop':'content'
95115 };
@@ -122,7 +142,7 @@
123143 'gsrlimit': this.provider.limit,
124144 'gsroffset': this.provider.offset,
125145 'prop':'imageinfo|revisions|categories',
126 - 'iiprop':'url|mime|size',
 146+ 'iiprop':'url|mime|size|metadata',
127147 'iiurlwidth': parseInt( this.rsd.thumb_width ),
128148 'rvprop':'content'
129149 };
@@ -183,14 +203,18 @@
184204 }
185205
186206 // Get the url safe titleKey from the descriptionurl
187 - var titleKey = page.imageinfo[0].descriptionurl.split( '/' );
188 - titleKey = unescape( titleKey[ titleKey.length - 1 ] );
 207+ var titleKey = page.imageinfo[0].descriptionurl.split( '/' )
 208+ ;
 209+ titleKey = unescape(
 210+ titleKey[ titleKey.length - 1 ]
 211+ .replace( 'index.php?title=', '')
 212+ );
189213
190214 var resource = {
191215 'id' : page_id,
192216 'titleKey' : titleKey,
193217 'link' : page.imageinfo[0].descriptionurl,
194 - 'title' : page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''),
 218+ 'title' : page.title.replace(/Image:|File:|.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''),
195219 'poster' : page.imageinfo[0].thumburl,
196220 'thumbwidth' : page.imageinfo[0].thumbwidth,
197221 'thumbheight': page.imageinfo[0].thumbheight,
@@ -201,11 +225,18 @@
202226 'desc' : page.revisions[0]['*'],
203227 // add pointer to parent search obj:
204228 'pSobj' :_this,
 229+
205230 'meta': {
206231 'categories':page.categories
207232 }
208 - };
 233+ };
209234
 235+ for( var i in page.imageinfo[0].metadata ){
 236+ if( page.imageinfo[0].metadata[i].name == 'length' ){
 237+ resource.duration = page.imageinfo[0].metadata[i].value;
 238+ }
 239+ }
 240+
210241 /*
211242 //to use once we get the wiki-text parser in shape
212243 var pObj = mw.parser( resource.desc );
@@ -247,8 +278,10 @@
248279 this.resultsObj[page_id] = resource;
249280
250281 // If returnFirst flag:
251 - if ( returnFirst )
 282+ // xxx this is kind of hacky .. we should have abstract getter / adder to result list
 283+ if ( returnFirst ){
252284 return this.resultsObj[page_id];
 285+ }
253286
254287
255288 this.num_results++;
Index: trunk/extensions/AddMediaWizard/AddMedia/searchLibs/baseRemoteSearch.js
@@ -56,7 +56,7 @@
5757 num_results : 0,
5858
5959 /**
60 - * Initialise the baseRemoteSearch
 60+ * Initialize the baseRemoteSearch
6161 * @param {Object} options The set of options for the remote search class
6262 */
6363 init: function( options ) {
@@ -67,6 +67,10 @@
6868 return this;
6969 },
7070
 71+ getResourceFromUrl: function( url, callback ){
 72+ mw.log("Error getResourceFromUrl must be implemented by remoteSearch provider");
 73+ },
 74+
7175 /**
7276 * Base search results
7377 * Does some common initialisation for search results
Index: trunk/extensions/AddMediaWizard/AddMedia/searchLibs/flickrSearch.js
@@ -15,8 +15,7 @@
1616 var flickrSearch = function ( options ) {
1717 this.init( options );
1818 }
19 -flickrSearch.prototype = {
20 - dtUrl : 'http://www.flickr.com/photos/',
 19+flickrSearch.prototype = {
2120 // @@todo probably would be good to read the api-key from configuration
2221 apikey : '2867787a545cc66c0bce6f2e57aca1d1',
2322 // What license we are interested in
@@ -102,7 +101,7 @@
103102 var resource = {
104103 'titleKey' : flickrResource.title + '.jpg',
105104 'resourceKey': flickrResource.id,
106 - 'link' : _this.dtUrl + flickrResource.pathalias + '/' + flickrResource.id,
 105+ 'link' : _this.detailsUrl + flickrResource.pathalias + '/' + flickrResource.id,
107106 'title' : flickrResource.title,
108107 'thumbwidth' : flickrResource.width_t,
109108 'thumbheight': flickrResource.height_t,
Index: trunk/extensions/AddMediaWizard/AddMedia/loader.js
@@ -38,7 +38,9 @@
3939 mw.addModuleLoader( 'AddMedia.UploadForm', [
4040 [
4141 'mw.UploadForm',
42 - '$j.ui'
 42+ '$j.ui',
 43+ '$j.widget',
 44+ '$j.ui.mouse'
4345 ],
4446 [
4547 '$j.ui.datepicker'
@@ -57,7 +59,10 @@
5860 '$j.browserTest', // ( textSelection uses browserTest )
5961 '$j.ui'
6062 ], [
61 - '$j.ui.resizable',
 63+ '$j.widget',
 64+ '$j.ui.mouse',
 65+ '$j.ui.resizable',
 66+ '$j.ui.position',
6267 '$j.ui.draggable',
6368 '$j.ui.dialog',
6469 '$j.ui.tabs',
@@ -70,10 +75,13 @@
7176 [
7277 'mw.UploadHandler',
7378 'mw.UploadInterface',
74 - '$j.ui'
 79+ '$j.ui',
 80+ '$j.ui.mouse',
 81+ '$j.widget'
7582 ],
7683 [
7784 '$j.ui.progressbar',
 85+ '$j.ui.position',
7886 '$j.ui.dialog',
7987 '$j.ui.draggable'
8088 ]
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.Firefogg.js
@@ -25,7 +25,7 @@
2626 "fogg-preview" : "Preview video",
2727 "fogg-hidepreview" : "Hide preview",
2828 "fogg-warning-firebug" : "<b>Firebug</b> can cause conflicts with <i>Firefogg</i>. Please disable <b>Firebug</b> for this page.",
29 - "fogg-missing-webm-support" : "Please use a [$1 WebM compatible] browser to preview results of WebM videos"
 29+ "fogg-missing-webm-support" : "Please use a [$1 webm compatible] browsers to preview results of webm videos"
3030 });
3131
3232 var firefogg_install_links = {
@@ -344,9 +344,14 @@
345345 /**
346346 * Show the install firefogg msg
347347 */
348 - showInstallFirefog: function() {
 348+ showInstallFirefog: function( target ) {
349349 var _this = this;
350350
 351+ if( target ){
 352+ this.target_use_latest_firefox = target;
 353+ this.target_please_install = target;
 354+ }
 355+
351356 var upMsg = ( _this.form_type == 'upload' ) ?
352357 gM( 'fogg-for_improved_uploads' ) + ' ' : gM( 'fogg-not-installed') + ' ';
353358
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.UploadForm.js
@@ -401,7 +401,7 @@
402402 remoteSearchDriver.addResourceEditLoader();
403403
404404 //Add the uploaded result
405 - searchProvider.sObj.addByTitle( wTitle, function( resource ) {
 405+ searchProvider.sObj.getByTitle( wTitle, function( resource ) {
406406 // Update the recent uploads ( background task )
407407 remoteSearchDriver.showUserRecentUploads( uploadTargetId );
408408 // Pull up resource editor:
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.FirefoggGUI.js
@@ -96,7 +96,7 @@
9797
9898 mw.FirefoggGUI = function( iObj ) {
9999 return this.init( iObj );
100 -}
 100+};
101101 var default_mvAdvFirefogg_config = {
102102 // Config groups to include
103103 'config_groups': [ 'preset', 'range', 'quality', 'meta', 'advVideo', 'advAudio' ],
@@ -109,7 +109,7 @@
110110
111111 // The control container
112112 'target_control_container': false
113 -}
 113+};
114114
115115 mw.FirefoggGUI.prototype = {
116116 // The configuration group names
@@ -219,13 +219,13 @@
220220 'group' : "quality"
221221 },
222222 'width': {
223 - 'range' : { 'min': 0, 'max': 1080 },
 223+ 'range' : { 'min': 0, 'max': 4096 },
224224 'step' : 4,
225225 'type' : 'slider',
226226 'group' : "quality"
227227 },
228228 'height': {
229 - 'range' : { 'min': 0, 'max' : 1080 },
 229+ 'range' : { 'min': 0, 'max' : 3072 },
230230 'step' : 4,
231231 'type' : "slider",
232232 'group' : "quality"
@@ -413,7 +413,7 @@
414414 case 'target_btn_save_local_file':
415415 var icon;
416416 if ( target == 'target_btn_save_local_file' ) {
417 - icon = 'ui-icon-video'
 417+ icon = 'ui-icon-video';
418418 } else {
419419 icon = 'ui-icon-folder-open';
420420 }
@@ -545,32 +545,6 @@
546546 return out;
547547 },
548548
549 - /**
550 - * Show a dialog box asking the user to select a source URL.
551 - * FIXME: half-written, doesn't work at all.
552 - */
553 - /*
554 - selectSourceUrl: function() {
555 - // FIXME: i18n
556 - var url = prompt( "Please enter the source media url you would like " +
557 - "to transcode from.", "http://" );
558 - if ( !url ) {
559 - return;
560 - }
561 -
562 - // update the mode:
563 - this.sourceMode = 'url';
564 - this.sourceUrl = url;
565 - this.clearSourceInfoCache();
566 - this.updateSourceFileUI();
567 - // update the input target
568 - $j( this.target_input_file_name )
569 - .unbind()
570 - .val( url )
571 - .removeAttr( 'readonly' );
572 - },
573 - */
574 -
575549 bindControls: function() {
576550 var _this = this;
577551 _this.basefogg_bindControls();
@@ -633,7 +607,7 @@
634608 function() {
635609 var configKey = _this.getClassId( this, 'help_' );
636610 if( !helpState[configKey] )
637 - $j( _this.selector + ' .helpRow_' + configKey ).hide( 'slow' )
 611+ $j( _this.selector + ' .helpRow_' + configKey ).hide( 'slow' );
638612 }
639613 );
640614
@@ -672,7 +646,7 @@
673647 $j( this ).val() )
674648 );
675649 _this.updatePresetSelection( 'custom' );
676 - })
 650+ });
677651 break;
678652 case 'date':
679653 $j( this.selector + ' ._' + configKey ).datepicker({
Index: trunk/extensions/AddMediaWizard/AddMedia/mw.RemoteSearchDriver.js
@@ -74,7 +74,7 @@
7575 "rsd-wiki_commons-title": "Wikimedia Commons",
7676 "rsd-wiki_commons": "Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)",
7777
78 - "rsd-kaltura-title" : "All sources",
 78+ "rsd-kaltura-title" : "Kaltura search ( all sources )",
7979 "rsd-kaltura" : "Kaltura aggregated search for free-licensed media across multiple search providers",
8080
8181 "rsd-this_wiki-title" : "This wiki",
@@ -104,7 +104,17 @@
105105 // The target button or link that will invoke the search interface
106106 'target_invoke_button': null,
107107
 108+ // Default id for search target input
 109+ 'target_search_input' : '#rsd_q',
 110+
108111 /**
 112+ * Callback functions:
 113+ */
 114+ 'resourceSelectionCallback' : null,
 115+
 116+ 'displaySearchResultsCallback' : null,
 117+
 118+ /**
109119 * import_url_mode
110120 * Can be 'api', 'autodetect', 'remote_link'
111121 * api: uses the mediawiki api to insert the media asset
@@ -146,8 +156,11 @@
147157 // 'nc' ( non-commercial ), 'all' ( all found licenses are "ok")
148158 'enabled_licenses' : ['pd', 'by', 'sa' ],
149159
 160+ // If the input text should be displayed
 161+ 'displaySearchInput' : true,
 162+
150163 // If we should display resource icons
151 - 'displayResourceInfoIcons' : true,
 164+ 'displayResourceInfoIcons' : true,
152165
153166 // If we should display the result format button.
154167 'displayResultFormatButton': true,
@@ -166,7 +179,6 @@
167180
168181 $.fn.addMediaWizard = function( options, callback ) {
169182 options['target_invoke_button'] = this.selector;
170 - options['instance_name'] = 'rsdMVRS';
171183 window['rsdMVRS'] = new mw.RemoteSearchDriver( options );
172184 if( callback ) {
173185 callback( window['rsdMVRS'] );
@@ -266,7 +278,10 @@
267279 'this_wiki': {
268280 'enabled': 1,
269281 'apiUrl': ( wgServer && wgScriptPath ) ?
270 - wgServer + wgScriptPath + '/api.php' : null,
 282+ wgServer + wgScriptPath + '/api.php' : null,
 283+
 284+ 'detailsUrl' : ( wgServer && wgArticlePath )? wgServer + wgArticlePath : null,
 285+
271286 'lib': 'mediaWiki',
272287 'homepage' : ( wgServer && wgScript ) ?
273288 wgServer + wgScript : null,
@@ -281,6 +296,9 @@
282297 'enabled': 1,
283298 'homepage': 'http://kaltura.com',
284299 'apiUrl': 'http://kaldev.kaltura.com/michael/aggregator.php',
 300+
 301+ 'detailsUrl' : 'http://videos.kaltura.com/$1',
 302+
285303 'lib': 'kaltura',
286304 'resource_prefix' : '',
287305 'tab_image':false
@@ -293,6 +311,8 @@
294312 'enabled': 1,
295313 'homepage': 'http://commons.wikimedia.org/wiki/Main_Page',
296314 'apiUrl': 'http://commons.wikimedia.org/w/api.php',
 315+ 'detailsUrl' : 'http://commons.wikimedia.org/wiki/$1',
 316+
297317 'lib': 'mediaWiki',
298318 'tab_img': true,
299319
@@ -318,6 +338,8 @@
319339 'homepage': 'http://www.archive.org/about/about.php',
320340
321341 'apiUrl': 'http://www.archive.org/advancedsearch.php',
 342+ 'detailsUrl' : 'http://www.archive.org/details/$1',
 343+
322344 'lib': 'archiveOrg',
323345 'local': false,
324346 'resource_prefix': 'AO_',
@@ -329,9 +351,10 @@
330352 */
331353 'flickr': {
332354 'enabled': 1,
333 - 'homepage': 'http://www.flickr.com/about/',
334 -
 355+ 'homepage': 'http://www.flickr.com/about/',
335356 'apiUrl': 'http://www.flickr.com/services/rest/',
 357+ 'detailsUrl' : 'http://www.flickr.com/photos/',
 358+
336359 'lib': 'flickr',
337360 'local': false,
338361 // Just prefix with Flickr_ for now.
@@ -346,6 +369,8 @@
347370 'enabled': 1,
348371 'homepage': 'http://metavid.org/wiki/Metavid_Overview',
349372 'apiUrl': 'http://metavid.org/w/index.php?title=Special:MvExportSearch',
 373+ 'detailsUrl' : 'http://metavid.org/wiki/Stream:$1',
 374+
350375 'lib': 'metavid',
351376 'local': false,
352377
@@ -442,7 +467,7 @@
443468 */
444469 init: function( options ) {
445470 var _this = this;
446 - mw.log( 'remoteSearchDriver:init' );
 471+ mw.log( 'RemoteSearchDriver:init' );
447472
448473 // Add in a local "id" reference to each provider
449474 for ( var provider_id in this.content_providers ) {
@@ -524,6 +549,8 @@
525550 }
526551 return this;
527552 },
 553+
 554+
528555
529556 /**
530557 * Get license icon html
@@ -730,11 +757,11 @@
731758 var query = _this.getDefaultQuery();
732759
733760 // Refresh the container if "upload" or "changed query"
734 - if ( query != $j( '#rsd_q' ).val()
 761+ if ( query != $j( this.target_search_input ).val()
735762 ||
736763 this.current_provider == 'upload' )
737764 {
738 - $j( '#rsd_q' ).val( query );
 765+ $j( this.target_search_input ).val( query );
739766 _this.updateResults();
740767 }
741768 // $j(_this.target_container).dialog("open");
@@ -823,14 +850,8 @@
824851 .attr({
825852 'id' : 'rsd_modal_target',
826853 'title' : gM( 'mwe-add_media_wizard' )
827 - })
828 - .css( {
829 - 'position' : 'absolute',
830 - 'top' : '3em',
831 - 'left' : '0px',
832 - 'bottom' : '3em',
833 - 'right' : '0px'
834 - })
 854+ })
 855+ .css("position", 'relative')
835856 );
836857 // Get layout
837858 mw.log( 'width: ' + $j( window ).width() + ' height: ' + $j( window ).height() );
@@ -845,6 +866,9 @@
846867 bgiframe: true,
847868 autoOpen: true,
848869 modal: true,
 870+ width: $j(window).width()-50,
 871+ height: $j(window).height()-50,
 872+ position : 'center',
849873 draggable: false,
850874 resizable: false,
851875 buttons: cancelButton,
@@ -855,7 +879,7 @@
856880 $j( this ).parents( '.ui-dialog' ).fadeOut( 'slow' );
857881 }
858882 } );
859 - $j( _this.target_container ).dialogFitWindow();
 883+ //$j( _this.target_container ).dialogFitWindow();
860884
861885 // Add the window resize hook to keep dialog layout
862886 $j( window ).resize( function() {
@@ -872,12 +896,16 @@
873897
874898 var $mainContainer = $j( this.target_container );
875899
876 - var $controlContainer = this.createControlContainer();
 900+ // Add the provider seleciton
 901+ $mainContainer.append( this.createProviderSelection() );
877902
878 - $mainContainer.append( $controlContainer );
 903+ // Add the searchInput control if it should be displayed:
 904+ if( this.displaySearchInput ){
 905+ $mainContainer.append( this.createSearchInput() );
 906+ };
879907
880908 this.$resultsContainer = $j('<div />').attr({
881 - id: "rsd_results_container"
 909+ id : "rsd_results_container"
882910 });
883911
884912 $mainContainer.append( this.$filtersContainer );
@@ -885,7 +913,7 @@
886914
887915 // Run the default search:
888916 if ( this.getDefaultQuery() ){
889 - this.updateResults();
 917+ _this.updateResults();
890918 }
891919
892920 // Add bindings
@@ -920,12 +948,57 @@
921949 // Setup base cancel button binding
922950 this.onCancelResourceEdit();
923951 },
924 -
925952 /**
 953+ * public function to get enabled content providers
 954+ */
 955+ getEnabledProviders: function(){
 956+ var enabledProviders = {};
 957+ for ( var providerName in this.content_providers ) {
 958+ var content_providers = this.content_providers;
 959+ var provider = content_providers[ providerName ];
 960+ if ( provider.enabled && provider.apiUrl ) {
 961+ enabledProviders[providerName] = provider;
 962+ }
 963+ }
 964+ return enabledProviders;
 965+ },
 966+
 967+ createProviderSelection: function(){
 968+ var _this = this;
 969+ var $providerSelection = $j( '<ul />' )
 970+ .addClass( "ui-provider-selection" );
 971+ // Add enabled search providers.
 972+ $j.each( _this.getEnabledProviders(), function(providerName, provider){
 973+ var $anchor = $j( '<div />' )
 974+ .text( gM( 'rsd-' + providerName + '-title' ) )
 975+ .attr({
 976+ name: providerName
 977+ });
 978+ if ( _this.current_provider == providerName) {
 979+ $anchor.addClass( 'ui-selected' );
 980+ }
 981+
 982+ $anchor.click( function() {
 983+ $j( this ).parent().parent().find( '.ui-selected' )
 984+ .removeClass( 'ui-selected' );
 985+ $j( this ).addClass( 'ui-selected' );
 986+ _this.current_provider = $j( this ).attr( "name" );
 987+ // Update the search results on provider selection
 988+ _this.updateResults( _this.current_provider, true );
 989+ return false;
 990+ });
 991+
 992+ var $listItem = $j( '<li />' );
 993+ $listItem.append( $anchor );
 994+ $providerSelection.append( $listItem );
 995+ });
 996+ return $providerSelection;
 997+ },
 998+ /**
926999 * Creates the search control (i.e. Search textbox, search button, provider filter).
9271000 * @return A jQuery-generated HTML element ready to be injected in the main container.
9281001 */
929 - createControlContainer: function() {
 1002+ createSearchInput: function() {
9301003 var _this = this;
9311004 var $controlContainer = $j( '<div />' )
9321005 .addClass( "rsd_control_container" );
@@ -935,22 +1008,20 @@
9361009 action : "javascript:return false"
9371010 });
9381011
939 - var $providerSelection = $j( '<ul />' )
940 - .addClass( "ui-provider-selection" );
941 -
942 - var $searchButton = $j.button({
943 - icon_id: 'search',
944 - text: gM( 'mwe-media_search' ) })
945 - .addClass( 'rsd_search_button' )
946 - .buttonHover()
947 - .click(function () {
948 - if( _this.current_provider == 'upload' ){
949 - _this.current_provider = _this.previus_provider;
950 - }
951 - _this.updateResults( _this.current_provider, true );
952 - return false;
953 - });
9541012
 1013+ var $searchButton = $j.button({
 1014+ icon: 'search',
 1015+ text: gM( 'mwe-media_search' )
 1016+ })
 1017+ .addClass( 'rsd_search_button' )
 1018+ .click(function () {
 1019+ if( _this.current_provider == 'upload' ){
 1020+ _this.current_provider = _this.previus_provider;
 1021+ }
 1022+ _this.updateResults( _this.current_provider, true );
 1023+ return false;
 1024+ });
 1025+
9551026 var $searchBox = $j( '<input />' )
9561027 .addClass( 'ui-corner-all' )
9571028 .attr({
@@ -972,43 +1043,13 @@
9731044 $searchButton.removeClass("ui-button-disabled");
9741045 }
9751046 });
976 -
977 - // Add enabled search providers.
978 - for ( var providerName in this.content_providers ) {
979 - var content_providers = this.content_providers;
980 - var provider = content_providers[ providerName ];
981 - if ( provider.enabled && provider.apiUrl ) {
982 - var $anchor = $j( '<div />' )
983 - .text( gM( 'rsd-' + providerName + '-title' ) )
984 - .attr({
985 - name: providerName
986 - });
987 - if ( this.current_provider == providerName) {
988 - $anchor.addClass( 'ui-selected' );
989 - }
990 -
991 - $anchor.click( function() {
992 - $j( this ).parent().parent().find( '.ui-selected' )
993 - .removeClass( 'ui-selected' );
994 - $j( this ).addClass( 'ui-selected' );
995 - _this.current_provider = $j( this ).attr( "name" );
996 - // Update the search results on provider selection
997 - _this.updateResults( _this.current_provider, true );
998 - return false;
999 - });
1000 -
1001 - var $listItem = $j( '<li />' );
1002 - $listItem.append( $anchor );
1003 - $providerSelection.append( $listItem );
1004 - }
1005 - }
1006 -
1007 - $searchForm.append( $providerSelection );
 1047+
10081048 $searchForm.append( $searchBox );
10091049 $searchForm.append( $searchButton );
 1050+
10101051 // Add optional upload buttons.
10111052 if ( this.content_providers['upload'].enabled) {
1012 - $uploadButton = $j.button( { icon_id: 'disk', text: gM( 'mwe-upload_tab' ) })
 1053+ $uploadButton = $j.button( { icon: 'disk', text: gM( 'mwe-upload_tab' ) })
10131054 .addClass("rsd_upload_button")
10141055 .click(function() {
10151056 // Update the previus_provider to swap back
@@ -1022,7 +1063,7 @@
10231064 $searchForm.append( $uploadButton );
10241065 /*
10251066 // Import functionality not yet supported
1026 - $importButton = $j.button({icon_id: 'import', text: 'import'})
 1067+ $importButton = $j.button({icon: 'import', text: 'import'})
10271068 .addClass("rsd_import_button");
10281069 .append( $importButton );
10291070 */
@@ -1323,11 +1364,11 @@
13241365
13251366 // Check if we need to update:
13261367 if ( typeof provider.sObj != 'undefined' ) {
1327 - if ( provider.sObj.last_query == $j( '#rsd_q' ).val()
 1368+ if ( provider.sObj.last_query == $j( this.target_search_input ).val()
13281369 && provider.sObj.last_offset == provider.offset ) {
13291370
13301371 mw.log( 'last query is: ' + provider.sObj.last_query +
1331 - ' matches: ' + $j( '#rsd_q' ).val() + ' no search needed');
 1372+ ' matches: ' + $j( this.target_search_input ).val() + ' no search needed');
13321373
13331374 // Show search results directly
13341375 this.showResults( );
@@ -1344,7 +1385,7 @@
13451386 }
13461387 }
13471388
1348 - if ( $j ( '#rsd_q' ).val().length == 0 ) {
 1389+ if ( $j ( this.target_search_input ).val().length == 0 ) {
13491390 this.$resultsContainer.empty();
13501391 this.$resultsContainer.text( 'Please insert a search string above.' );
13511392 return;
@@ -1525,7 +1566,7 @@
15261567 var context = _this.storeContext( d.getTime() );
15271568 _this.currentRequest = context();
15281569 mw.log( "ProviderCallBack Generated " + context() )
1529 - provider.sObj.getSearchResults( $j( '#rsd_q' ).val() ,
 1570+ provider.sObj.getSearchResults( $j( _this.target_search_input ).val() ,
15301571 function( resultStatus ) {
15311572 mw.log( "ProviderCallBack Received " + context() );
15321573 if( _this.currentRequest != context() ) {
@@ -1597,6 +1638,33 @@
15981639 },
15991640
16001641 /**
 1642+ * Get a resource from a url loads the provider if not already initialized
 1643+ */
 1644+ getResourceFromUrl: function ( provider, url, callback){
 1645+ if (!provider.sObj) {
 1646+ this.loadSearchLib( provider, function( provider ){
 1647+ provider.sObj.getResourceFromUrl( url, callback);
 1648+ });
 1649+ }
 1650+ else {
 1651+ provider.sObj.getResourceFromUrl( url, callback);
 1652+ }
 1653+ },
 1654+
 1655+ /**
 1656+ * Get a resource from a titleKey loads the provider if not already initialized
 1657+ */
 1658+ getResourceFromTitleKey: function ( provider, title, callback){
 1659+ if (!provider.sObj) {
 1660+ this.loadSearchLib( provider, function( provider ){
 1661+ provider.sObj.getByTitle( title, callback);
 1662+ });
 1663+ }
 1664+ else {
 1665+ provider.sObj.getByTitle( title, callback);
 1666+ }
 1667+ },
 1668+ /**
16011669 * Get a resource object from a resource id
16021670 *
16031671 * NOTE: We could bind resource objects to html elements to avoid this lookup
@@ -1706,7 +1774,7 @@
17071775 $resultsContainer.append( _this.createResultsFooter() );
17081776 }
17091777
1710 - mw.log( 'did numResults :: ' + numResults + ' append: ' + $j( '#rsd_q' ).val() );
 1778+ mw.log( 'did numResults :: ' + numResults + ' append: ' + $j( this.target_search_input ).val() );
17111779
17121780 // Add "no search results" text
17131781 $j( '#rsd_no_search_res' ).remove();
@@ -1718,11 +1786,15 @@
17191787 );
17201788 } else {
17211789 $resultsContainer.append(
1722 - gM( 'rsd_no_results', $j( '#rsd_q' ).val() )
 1790+ gM( 'rsd_no_results', $j( this.target_search_input ).val() )
17231791 ) ;
17241792 }
17251793 }
17261794 this.addResultBindings();
 1795+
 1796+ if( typeof this.displaySearchResultsCallback == 'function'){
 1797+ this.displaySearchResultsCallback();
 1798+ }
17271799 },
17281800
17291801 /**
@@ -1890,7 +1962,15 @@
18911963 // Resource click action: (bring up the resource editor)
18921964 $j( '.rsd_res_item' ).unbind().click( function() {
18931965 var resource = _this.getResourceFromId( $j( this ).attr( "id" ) );
1894 - _this.showResourceEditor( resource );
 1966+
 1967+ // xxx These hooks should really be managed via bindings not options like this:
 1968+ var showResourceEditor = true;
 1969+ if( typeof _this.resourceSelectionCallback == 'function' ){
 1970+ showResourceEditor = _this.resourceSelectionCallback( resource );
 1971+ }
 1972+ if( showResourceEditor ){
 1973+ _this.showResourceEditor( resource );
 1974+ }
18951975 return false;
18961976 } )
18971977 // Add a "bind" class
@@ -1949,7 +2029,7 @@
19502030 'position' : 'absolute',
19512031 'top' : '0px',
19522032 'left' : '0px',
1953 - 'bottom' : '0px',
 2033+ 'bottom' : '30px',
19542034 'right' : '4px',
19552035 'background-color' : '#FFF'
19562036 } )
@@ -2646,7 +2726,7 @@
26472727 getTemplateDescription: function( resource ) {
26482728 // setup the resource description from resource description:
26492729 // FIXME: i18n, namespace
2650 - var description = '{{Information ' + "\n";
 2730+ var description ='{{Information ' + "\n";
26512731
26522732 if ( resource.desc ) {
26532733 description += '|Description= ' + resource.desc + "\n";
@@ -3198,7 +3278,7 @@
31993279 },
32003280
32013281 /*
3202 - * Sets the dispaly mode
 3282+ * Sets the display mode
32033283 * @param {String} mode Either "box" or "list"
32043284 */
32053285 setDisplayMode: function( mode ) {
Index: trunk/extensions/AddMediaWizard/AddMedia/jquery.dragDropFile.js
@@ -117,11 +117,6 @@
118118 )
119119 )
120120 )
121 - /*mw.addDialog( "upload this image", '<img width="300" src="' + files[i].getAsDataURL() + '">' +
122 - '<br>name: ' + files[i].name + '</br>' +
123 - '<br>size: ' + files[i].fileSize + '</br>' +
124 - '<br>mime: ' + files[i].mediaType + '</br>');
125 - */
126121 // do the add-media-wizard with the upload tab
127122 } else {
128123 alert( "file is too big, needs to be below 64mb" );
Index: trunk/extensions/AddMediaWizard/AddMedia/AddMedia.i18n.php
@@ -41,11 +41,11 @@
4242 'fogg-cg-advVideo' => 'Advanced video encoding controls',
4343 'fogg-cg-advAudio' => 'Advanced audio encoding controls',
4444 'fogg-preset-custom' => 'Custom settings',
45 - 'fogg-webvideo-desc' => 'Ogg web video Theora, Vorbis (600 kbit\/s and 400px maximum width)',
46 - 'fogg-savebandwidth-desc' => 'Ogg low bandwidth Theora, Vorbis (164 kbit\/s and 200px maximum width)',
47 - 'fogg-highquality-desc' => 'Ogg high quality Theora, Vorbis (1080px maximum width)',
48 - 'fogg-webvideo-webm-desc' => 'WebM web video VP8 (600 kbit\/s and 480px maximum width)',
49 - 'fogg-highquality-webm-desc' => 'WebM high quality VP8 (1080px maximum width)',
 45+ 'fogg-webvideo-desc' => 'Ogg Web video Theora, Vorbis (600 kbit\/s and 400px maximum width)',
 46+ 'fogg-savebandwidth-desc' => 'Ogg Low bandwidth Theora, Vorbis (164 kbit\/s and 200px maximum width)',
 47+ 'fogg-highquality-desc' => 'Ogg High quality Theora, Vorbis (1080px maximum width)',
 48+ 'fogg-webvideo-webm-desc' => 'Webm Web video VP8 (600 kbit\/s and 480px maximum width)',
 49+ 'fogg-highquality-webm-desc' => 'Webm High quality VP8 (1080px maximum width)',
5050 'fogg-videoQuality-title' => 'Video quality',
5151 'fogg-videoQuality-help' => 'Used to set the <i>visual quality</i> of the encoded video (not used if you set bitrate in advanced controls below).',
5252 'fogg-starttime-title' => 'Start second',
@@ -55,7 +55,7 @@
5656 'fogg-audioQuality-title' => 'Audio quality',
5757 'fogg-audioQuality-help' => 'Used to set the <i>acoustic quality</i> of the encoded audio (not used if you set bitrate in advanced controls below).',
5858 'fogg-videoCodec-title' => 'Video codec',
59 - 'fogg-videoCodec-help' => 'Select the clip video codec. More about the <a target=\"_new\" href=\"http:\/\/en.wikipedia.org\/wiki\/Theora\">Theora codec<\/a>. More about the <a target=\"_new\" href=\"http:\/\/en.wikipedia.org\/wiki\/WebM\">VP8 codec<\/a>',
 59+ 'fogg-videoCodec-help' => 'Select the clip video codec. More about the <a target=\"_new\" href=\"http:\/\/en.wikipedia.org\/wiki\/Theora\">Theora codec<\/a>. More about the <a target=\"_new\" href=\"http:\/\/en.wikipedia.org\/wiki\/Webm\">VP8 codec<\/a>',
6060 'fogg-audioCodec-title' => 'Audio codec',
6161 'fogg-audioCodec-help' => 'Used to set the clip audio codec. Presently only Vorbis is supported. More about the <a target="_new" href="http://en.wikipedia.org/wiki/Vorbis">Vorbis codec</a>',
6262 'fogg-width-title' => 'Video width',
@@ -97,7 +97,7 @@
9898 'fogg-license-help' => 'The license of the clip (preferably a Creative Commons URL).',
9999 'fogg-contact-title' => 'Contact',
100100 'fogg-contact-help' => 'Contact link',
101 - 'fogg-missing-webm-support' => 'Please use a [$1 WebM compatible] browser to preview results of WebM videos',
 101+ 'fogg-missing-webm-support' => 'Please use a [$1 webm compatible] browsers to preview results of webm videos',
102102 'fogg-gui-title' => 'Make web video',
103103 'mwe-imported_from' => '$1 imported from [$2 $3]. See the original [$4 resource page] for more information.',
104104 'mwe-import-description' => '$1, imported from $2',
@@ -182,7 +182,7 @@
183183 'mwe-ftype-unk' => 'Unknown file format',
184184 'rsd-wiki_commons-title' => 'Wikimedia Commons',
185185 'rsd-wiki_commons' => 'Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)',
186 - 'rsd-kaltura-title' => 'All sources',
 186+ 'rsd-kaltura-title' => 'Kaltura search( all sources )',
187187 'rsd-kaltura' => 'Kaltura aggregated search for free-licensed media across multiple search providers',
188188 'rsd-this_wiki-title' => 'This wiki',
189189 'rsd-this_wiki-desc' => 'The local wiki',
@@ -8252,4 +8252,3 @@
82538253 'fogg-savebandwidth-desc' => '低帶寬Theora或Vorbis編碼164 kbit/s,最寬200相素',
82548254 'fogg-highquality-desc' => '高質量Theora或Vorbis編輯,最寬1080相素',
82558255 );
8256 -
Index: trunk/extensions/AddMediaWizard/ClipEdit/mw.ClipEdit.js
@@ -171,10 +171,10 @@
172172 * Edit the "duration" of a given resource
173173 *
174174 * supports resource types:
175 - * ['image', 'template']
 175+ * ['image', 'mwtemplate']
176176 */
177177 'duration': {
178 - 'media' : ['image', 'template'],
 178+ 'media' : ['image', 'mwtemplate'],
179179 'doEdit':function( _this, target ) {
180180 function doUpdateDur( inputElm ) {
181181 mw.log( "update duration:" + $j( inputElm ).val() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r74350Follow-up r74331: Message tweaks for consistenxy.raymond11:14, 6 October 2010

Status & tagging log