Index: branches/uploadwizard-firefogg/UploadWizard.config.php |
— | — | @@ -1,108 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Upload Wizard Configuration |
5 | | - * Do not modify this file, instead use localsettings.php and set: |
6 | | - * $wgUploadWizardConfig[ 'name'] = 'value'; |
7 | | - */ |
8 | | -global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules; |
9 | | -return array( |
10 | | - // Upload wizard has an internal debug flag |
11 | | - 'debug' => false, |
12 | | - |
13 | | - // If the uploaded file should be auto categorized |
14 | | - 'autoCategory' => true, |
15 | | - |
16 | | - // File extensions acceptable in this wiki |
17 | | - 'fileExtensions' => $wgFileExtensions, |
18 | | - |
19 | | - // Check if we want to enable firefogg ( for transcoding ) |
20 | | - 'enableFirefogg' => true, |
21 | | - |
22 | | - // Check if we have the firefogg upload api module enabled: |
23 | | - 'enableFirefoggChunkUpload' => isset( $wgAPIModules['firefoggupload'] )? true : false, |
24 | | - |
25 | | - // The default api url is for the current wiki ( can override at run time ) |
26 | | - 'apiUrl' => $wgServer . $wgScriptPath . '/api.php', |
27 | | - |
28 | | - // Default thumbnail width |
29 | | - 'thumbnailWidth' => 120, |
30 | | - |
31 | | - // Max thumbnail height: |
32 | | - 'thumbnailMaxHeight' => 200, |
33 | | - |
34 | | - // Min thumbnail width |
35 | | - 'smallThumbnailWidth' => 60, |
36 | | - |
37 | | - // Small thumbnail max height |
38 | | - 'smallThumbnailMaxHeight' => 100, |
39 | | - |
40 | | - // Icon thumbnail width: |
41 | | - 'iconThumbnailWidth' => 32, |
42 | | - |
43 | | - // Icon thumbnail height: |
44 | | - 'iconThumbnailMaxHeight' => 32, |
45 | | - |
46 | | - // Max author string length |
47 | | - 'maxAuthorLength' => 50, |
48 | | - |
49 | | - // Min author string length |
50 | | - 'minAuthorLength' => 2, |
51 | | - |
52 | | - // Max source string length |
53 | | - 'maxSourceLength' => 200, |
54 | | - |
55 | | - // Min source string length |
56 | | - 'minSourceLength' => 5, |
57 | | - |
58 | | - // Max file title string length |
59 | | - 'maxTitleLength' => 200, |
60 | | - |
61 | | - // Min file title string length |
62 | | - 'minTitleLength' => 5, |
63 | | - |
64 | | - // Max file description length |
65 | | - 'maxDescriptionLength' => 4096, |
66 | | - |
67 | | - // Min file description length |
68 | | - 'minDescriptionLength' => 5, |
69 | | - |
70 | | - // Max length for other file information: |
71 | | - 'maxOtherInformationLength' => 4096, |
72 | | - |
73 | | - // Max number of simultaneous upload requests |
74 | | - 'maxSimultaneousConnections' => 1, |
75 | | - |
76 | | - // Max number of uploads for a given form |
77 | | - 'maxUploads' => 10, |
78 | | - |
79 | | - // not for use with all wikis. |
80 | | - // The ISO 639 code for the language tagalog is "tl". |
81 | | - // Normally we name templates for languages by the ISO 639 code. |
82 | | - // Commons already had a template called 'tl: though. |
83 | | - // so, this workaround will cause tagalog descriptions to be saved with this template instead. |
84 | | - 'languageTemplateFixups' => array( 'tl' => 'tgl' ), |
85 | | - |
86 | | - // names of all license templates, in order. Case sensitive! |
87 | | - // n.b. in the future, the licenses for a wiki will probably be defined in PHP or even LocalSettings. |
88 | | - 'licenses' => array( |
89 | | - array( 'template' => 'Cc-by-sa-3.0','messageKey' => 'mwe-upwiz-license-cc-by-sa-3.0', 'default' => true ), |
90 | | - array( 'template' => 'Cc-by-3.0', 'messageKey' => 'mwe-upwiz-license-cc-by-3.0', 'default' => false ), |
91 | | - array( 'template' => 'Cc-zero', 'messageKey' => 'mwe-upwiz-license-cc-zero', 'default' => false ), |
92 | | - // n.b. the PD-US is only for testing purposes, obviously we need some geographical discrimination here... |
93 | | - array( 'template' => 'PD-US', 'messageKey' => 'mwe-upwiz-license-pd-us', 'default' => false ), |
94 | | - array( 'template' => 'GFDL', 'messageKey' => 'mwe-upwiz-license-gfdl', 'default' => false ) |
95 | | - ) |
96 | | - |
97 | | - // XXX this is horribly confusing -- some file restrictions are client side, others are server side |
98 | | - // the filename prefix blacklist is at least server side -- all this should be replaced with PHP regex config |
99 | | - // or actually, in an ideal world, we'd have some way to reliably detect gibberish, rather than trying to |
100 | | - // figure out what is bad via individual regexes, we'd detect badness. Might not be too hard. |
101 | | - // |
102 | | - // we can export these to JS if we so want. |
103 | | - // filenamePrefixBlacklist: wgFilenamePrefixBlacklist, |
104 | | - // |
105 | | - // filenameRegexBlacklist: [ |
106 | | - // /^(test|image|img|bild|example?[\s_-]*)$/, // test stuff |
107 | | - // /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/ // flickr |
108 | | - // ] |
109 | | -); |
Index: branches/uploadwizard-firefogg/resources/mw.UploadWizardUploadInterface.js |
— | — | @@ -1,344 +0,0 @@ |
2 | | -/** |
3 | | - * Create an interface fragment corresponding to a file input, suitable for Upload Wizard. |
4 | | - * @param upload |
5 | | - * @param div to insert file interface |
6 | | - * @param addInterface interface to add a new one (assumed that we start out there) |
7 | | - */ |
8 | | -mw.UploadWizardUploadInterface = function( upload, filesDiv ) { |
9 | | - var _this = this; |
10 | | - |
11 | | - _this.upload = upload; |
12 | | - |
13 | | - // may need to collaborate with the particular upload type sometimes |
14 | | - // for the interface, as well as the uploadwizard. OY. |
15 | | - _this.div = $j('<div class="mwe-upwiz-file"></div>').get(0); |
16 | | - _this.isFilled = false; |
17 | | - |
18 | | - _this.$fileInputCtrl = $j('<input size="1" class="mwe-upwiz-file-input" name="file" type="file"/>') |
19 | | - .change( function() { _this.fileChanged(); } ); |
20 | | - |
21 | | - _this.$indicator = $j( '<div class="mwe-upwiz-file-indicator"></div>' ); |
22 | | - |
23 | | - visibleFilenameDiv = $j('<div class="mwe-upwiz-visible-file"></div>') |
24 | | - .append( _this.$indicator ) |
25 | | - .append( '<div class="mwe-upwiz-visible-file-filename">' |
26 | | - + '<div class="mwe-upwiz-file-preview"/>' |
27 | | - + '<div class="mwe-upwiz-file-texts">' |
28 | | - + '<div class="mwe-upwiz-visible-file-filename-text"/>' |
29 | | - + '<div class="mwe-upwiz-file-status-line">' |
30 | | - + '<div class="mwe-upwiz-file-status mwe-upwiz-file-status-line-item"></div>' |
31 | | - + '</div>' |
32 | | - + '</div>' |
33 | | - + '</div>' |
34 | | - ); |
35 | | - |
36 | | - _this.$removeCtrl = $j.fn.removeCtrl( |
37 | | - 'mwe-upwiz-remove', |
38 | | - 'mwe-upwiz-remove-upload', |
39 | | - function() { _this.upload.remove(); } |
40 | | - ).addClass( "mwe-upwiz-file-status-line-item" ); |
41 | | - |
42 | | - visibleFilenameDiv.find( '.mwe-upwiz-file-status-line' ) |
43 | | - .append( _this.$removeCtrl ); |
44 | | - |
45 | | - //_this.errorDiv = $j('<div class="mwe-upwiz-upload-error mwe-upwiz-file-indicator" style="display: none;"></div>').get(0); |
46 | | - |
47 | | - _this.filenameCtrl = $j('<input type="hidden" name="filename" value=""/>').get(0); |
48 | | - |
49 | | - // this file Ctrl container is placed over other interface elements, intercepts clicks and gives them to the file input control. |
50 | | - // however, we want to pass hover events to interface elements that we are over, hence the bindings. |
51 | | - // n.b. not using toggleClass because it often gets this event wrong -- relies on previous state to know what to do |
52 | | - _this.fileCtrlContainer = $j('<div class="mwe-upwiz-file-ctrl-container">'); |
53 | | -/* |
54 | | - .bind( 'mouseenter', function(e) { _this.addFileCtrlHover(e); } ) |
55 | | - .bind( 'mouseleave', function(e) { _this.removeFileCtrlHover(e); } ); |
56 | | -*/ |
57 | | - |
58 | | - |
59 | | - // the css trickery (along with css) |
60 | | - // here creates a giant size file input control which is contained within a div and then |
61 | | - // clipped for overflow. The effect is that we have a div (ctrl-container) we can position anywhere |
62 | | - // which works as a file input. It will be set to opacity:0 and then we can do whatever we want with |
63 | | - // interface "below". |
64 | | - // XXX caution -- if the add file input changes size we won't match, unless we add some sort of event to catch this. |
65 | | - _this.form = $j( '<form method="POST" encType="multipart/form-data" class="mwe-upwiz-form"></form>' ) |
66 | | - .attr( { action: _this.upload.api.url } ) |
67 | | - .append( visibleFilenameDiv ) |
68 | | - .append( _this.fileCtrlContainer |
69 | | - .append( _this.$fileInputCtrl ) |
70 | | - ) |
71 | | - .append( _this.filenameCtrl ) |
72 | | - .append( _this.thumbnailParam ) |
73 | | - .get( 0 ); |
74 | | - |
75 | | - |
76 | | - $j( _this.div ).append( _this.form ); |
77 | | - |
78 | | - // XXX evil hardcoded |
79 | | - // we don't really need filesdiv if we do it this way? |
80 | | - $j( filesDiv ).append( _this.div ); |
81 | | - |
82 | | - // _this.progressBar = ( no progress bar for individual uploads yet ) |
83 | | - // we bind to the ui div since unbind doesn't work for non-DOM objects |
84 | | - $j( _this.div ).bind( 'transportProgressEvent', function(e) { _this.showTransportProgress(); } ); |
85 | | - // $j( _this.div ).bind( 'transportedEvent', function(e) { _this.showStashed(); } ); |
86 | | - |
87 | | -}; |
88 | | - |
89 | | - |
90 | | -mw.UploadWizardUploadInterface.prototype = { |
91 | | - /** |
92 | | - * Things to do to this interface once we start uploading |
93 | | - */ |
94 | | - start: function() { |
95 | | - var _this = this; |
96 | | - // remove hovering |
97 | | - $j( _this.div ) |
98 | | - .unbind( 'mouseenter mouseover mouseleave mouseout' ); |
99 | | - |
100 | | - // remove delete control |
101 | | - $j( _this.div ) |
102 | | - .find( '.mwe-upwiz-remove-ctrl' ) |
103 | | - .unbind( 'mouseenter mouseover mouseleave mouseout' ) |
104 | | - .remove(); |
105 | | - }, |
106 | | - |
107 | | - /** |
108 | | - * change the graphic indicator at the far end of the row for this file |
109 | | - * @param String statusClass: corresponds to a class mwe-upwiz-status which changes style of indicator. |
110 | | - */ |
111 | | - showIndicator: function( statusClass ) { |
112 | | - this.clearIndicator(); |
113 | | - // add the desired class and make it visible, if it wasn't already. |
114 | | - this.$indicator.addClass( 'mwe-upwiz-status-' + statusClass ) |
115 | | - .css( 'visibility', 'visible' ); |
116 | | - }, |
117 | | - |
118 | | - /** |
119 | | - * Reset the graphic indicator |
120 | | - */ |
121 | | - clearIndicator: function() { |
122 | | - var _this = this; |
123 | | - $j.each( _this.$indicator.attr( 'class' ).split( /\s+/ ), function( i, className ) { |
124 | | - if ( className.match( /^mwe-upwiz-status/ ) ) { |
125 | | - _this.$indicator.removeClass( className ); |
126 | | - } |
127 | | - } ); |
128 | | - }, |
129 | | - |
130 | | - /** |
131 | | - * Set the preview image on the file page for this upload. |
132 | | - * @param HTMLImageElement |
133 | | - */ |
134 | | - setPreview: function( image ) { |
135 | | - // encoding for url here? |
136 | | - $j( this.div ).find( '.mwe-upwiz-file-preview' ).css( 'background-image', 'url(' + image.src + ')' ); |
137 | | - }, |
138 | | - |
139 | | - /** |
140 | | - * Set the status line for this upload with an internationalized message string. |
141 | | - * @param String msgKey: key for the message |
142 | | - * @param Array args: array of values, in case any need to be fed to the image. |
143 | | - */ |
144 | | - setStatus: function( msgKey, args ) { |
145 | | - if ( !mw.isDefined( args ) ) { |
146 | | - args = []; |
147 | | - } |
148 | | - this.setStatusStr( gM( msgKey, args ) ); |
149 | | - }, |
150 | | - |
151 | | - /** |
152 | | - * Set the status line for this upload |
153 | | - * @param String str: the string to use |
154 | | - */ |
155 | | - setStatusStr: function( str ) { |
156 | | - $j( this.div ).find( '.mwe-upwiz-file-status' ).html( str ).show(); |
157 | | - }, |
158 | | - |
159 | | - /** |
160 | | - * Clear the status line for this upload (hide it, in case there are paddings and such which offset other things.) |
161 | | - */ |
162 | | - clearStatus: function() { |
163 | | - $j( this.div ).find( '.mwe-upwiz-file-status' ).hide(); |
164 | | - }, |
165 | | - |
166 | | - /** |
167 | | - * Put the visual state of an individual upload ito "progress" |
168 | | - * @param fraction The fraction of progress. Float between 0 and 1 |
169 | | - */ |
170 | | - showTransportProgress: function( fraction ) { |
171 | | - // if fraction available, update individual progress bar / estimates, etc. |
172 | | - this.showIndicator( 'progress' ); |
173 | | - this.setStatus( 'mwe-upwiz-uploading' ); |
174 | | - }, |
175 | | - |
176 | | - /** |
177 | | - * Show that upload is transported |
178 | | - */ |
179 | | - showStashed: function() { |
180 | | - this.$removeCtrl.detach(); |
181 | | - this.$fileInputCtrl.detach(); |
182 | | - this.showIndicator( 'stashed' ); |
183 | | - this.setStatus( 'mwe-upwiz-stashed-upload' ); // this is just "OK", say something more. |
184 | | - }, |
185 | | - |
186 | | - /** |
187 | | - * Show that transport has failed |
188 | | - * @param String code: error code from API |
189 | | - * @param {String|Object} info: extra info |
190 | | - */ |
191 | | - showError: function( code, info ) { |
192 | | - this.showIndicator( 'error' ); |
193 | | - // is this an error that we expect to have a message for? |
194 | | - var msgKey = 'mwe-upwiz-api-error-unknown-code'; |
195 | | - var args = [ code ]; |
196 | | - if ( $j.inArray( code, mw.Api.errors ) !== -1 ) { |
197 | | - msgKey = 'mwe-upwiz-api-error-' + code; |
198 | | - // args may change base on particular error messages. |
199 | | - // for instance, we are throwing away the extra info right now. Might be nice to surface that in a debug mode |
200 | | - args = []; |
201 | | - } |
202 | | - this.setStatus( msgKey, args ); |
203 | | - }, |
204 | | - |
205 | | - /** |
206 | | - * Run this when the value of the file input has changed. Check the file for various forms of goodness. |
207 | | - * If okay, then update the visible filename (due to CSS trickery the real file input is invisible) |
208 | | - */ |
209 | | - fileChanged: function() { |
210 | | - var _this = this; |
211 | | - _this.clearErrors(); |
212 | | - _this.upload.extractLocalFileInfo( _this.$fileInputCtrl.val() ); |
213 | | - if ( _this.isGoodExtension( _this.upload.title.getExtension() ) ) { |
214 | | - _this.updateFilename(); |
215 | | - } else { |
216 | | - //_this.error( 'bad-filename-extension', ext ); |
217 | | - alert("bad extension"); |
218 | | - } |
219 | | - this.clearStatus(); |
220 | | - }, |
221 | | - |
222 | | - /** |
223 | | - * Move the file input to cover a certain element on the page. |
224 | | - * We use invisible file inputs because this is the only way to style a file input |
225 | | - * or otherwise get it to do what you want. |
226 | | - * It is helpful to sometimes move them to cover certain elements on the page, and |
227 | | - * even to pass events like hover |
228 | | - * @param selector jquery-compatible selector, for a single element |
229 | | - */ |
230 | | - moveFileInputToCover: function( selector ) { |
231 | | - var $covered = $j( selector ); |
232 | | - |
233 | | - this.fileCtrlContainer |
234 | | - .css( $covered.position() ) |
235 | | - .css( 'marginTop', $covered.css( 'marginTop' ) ) |
236 | | - .css( 'marginRight', $covered.css( 'marginRight' ) ) |
237 | | - .css( 'marginBottom', $covered.css( 'marginBottom' ) ) |
238 | | - .css( 'marginLeft', $covered.css( 'marginLeft' ) ) |
239 | | - .width( $covered.outerWidth() ) |
240 | | - .height( $covered.outerHeight() ); |
241 | | - |
242 | | - this.fileCtrlContainer.css( { 'z-index': 1 } ); |
243 | | - |
244 | | - // shift the file input over with negative margins, |
245 | | - // internal to the overflow-containing div, so the div shows all button |
246 | | - // and none of the textfield-like input |
247 | | - this.$fileInputCtrl.css( { |
248 | | - 'margin-left': '-' + ~~( this.$fileInputCtrl.width() - $covered.outerWidth() - 10 ) + 'px', |
249 | | - 'margin-top' : '-' + ~~( this.$fileInputCtrl.height() - $covered.outerHeight() - 10 ) + 'px' |
250 | | - } ); |
251 | | - |
252 | | - |
253 | | - }, |
254 | | - |
255 | | - /** |
256 | | - * this does two things: |
257 | | - * 1 ) since the file input has been hidden with some clever CSS ( to avoid x-browser styling issues ), |
258 | | - * update the visible filename |
259 | | - * |
260 | | - * 2 ) update the underlying "title" which we are targeting to add to mediawiki. |
261 | | - * TODO silently fix to have unique filename? unnecessary at this point... |
262 | | - */ |
263 | | - updateFilename: function() { |
264 | | - var _this = this; |
265 | | - var path = _this.$fileInputCtrl.val(); |
266 | | - // get basename of file; some browsers do this C:\fakepath\something |
267 | | - path = path.replace(/\w:.*\\(.*)$/,'$1'); |
268 | | - |
269 | | - // visible filename |
270 | | - $j( _this.form ).find( '.mwe-upwiz-visible-file-filename-text' ).html( path ); |
271 | | - |
272 | | - _this.upload.title = new mw.Title( mw.UploadWizardUtil.getBasename( path ), 'file' ); |
273 | | - $j( _this.filenameCtrl ).val( _this.upload.title.getMain() ); |
274 | | - |
275 | | - if ( ! _this.isFilled ) { |
276 | | - var $div = $j( _this.div ); |
277 | | - _this.isFilled = true; |
278 | | - $div.addClass( 'filled' ); |
279 | | - |
280 | | - // cover the div with the file input. |
281 | | - // we use the visible-file div because it has the same offsetParent as the file input |
282 | | - // the second argument offsets the fileinput to the right so there's room for the close icon to get mouse events |
283 | | - _this.moveFileInputToCover( |
284 | | - $div.find( '.mwe-upwiz-visible-file-filename-text' ) |
285 | | - ); |
286 | | - |
287 | | - // Highlight the file on mouseover (and also show controls like the remove control). |
288 | | - // |
289 | | - // On Firefox there are bugs related to capturing mouse events on inputs, so we seem to miss the |
290 | | - // mouseenter or mouseleave events randomly. It's only really bad if we miss mouseleave, |
291 | | - // and have two highlights visible. so we add another call to REALLY make sure that other highlights |
292 | | - // are deactivated. |
293 | | - // http://code.google.com/p/fbug/issues/detail?id=2075 |
294 | | - // |
295 | | - // ALSO: When file inputs are adjacent, Firefox misses the "mouseenter" and "mouseleave" events. |
296 | | - // Consequently we have to bind to "mouseover" and "mouseout" as well even though that's not as efficient. |
297 | | - $div.bind( 'mouseenter mouseover', function() { |
298 | | - $div.addClass( 'hover' ); |
299 | | - $j( '#mwe-upwiz-filelist' ) |
300 | | - .children() |
301 | | - .filter( function() { return this !== _this.div; } ) |
302 | | - .removeClass('hover'); |
303 | | - }, false ); |
304 | | - $div.bind( 'mouseleave mouseout', function() { |
305 | | - $div.removeClass( 'hover' ); |
306 | | - }, false ); |
307 | | - $j( _this.div ).trigger( 'filled' ); |
308 | | - } else { |
309 | | - $j( _this.div ).trigger( 'filenameAccepted' ); |
310 | | - } |
311 | | - }, |
312 | | - |
313 | | - /** |
314 | | - * Remove any complaints we had about errors and such |
315 | | - * XXX this should be changed to something Theme compatible |
316 | | - */ |
317 | | - clearErrors: function() { |
318 | | - var _this = this; |
319 | | - $j( _this.div ).removeClass( 'mwe-upwiz-upload-error '); |
320 | | - $j( _this.errorDiv ).hide().empty(); |
321 | | - }, |
322 | | - |
323 | | - /** |
324 | | - * Show an error with the upload |
325 | | - */ |
326 | | - error: function() { |
327 | | - var _this = this; |
328 | | - var args = Array.prototype.slice.call( arguments ); // copies arguments into a real array |
329 | | - var msg = 'mwe-upwiz-upload-error-' + args[0]; |
330 | | - $j( _this.errorDiv ).append( $j( '<p class="mwe-upwiz-upload-error">' + gM( msg, args.slice( 1 ) ) + '</p>') ); |
331 | | - // apply a error style to entire did |
332 | | - $j( _this.div ).addClass( 'mwe-upwiz-upload-error' ); |
333 | | - $j( _this.errorDiv ).show(); |
334 | | - }, |
335 | | - |
336 | | - /** |
337 | | - * This is used when checking for "bad" extensions in a filename. |
338 | | - * @param ext |
339 | | - * @return boolean if extension was acceptable |
340 | | - */ |
341 | | - isGoodExtension: function( ext ) { |
342 | | - return $j.inArray( ext.toLowerCase(), mw.UploadWizard.config[ 'fileExtensions' ] ) !== -1; |
343 | | - } |
344 | | - |
345 | | -}; |
\ No newline at end of file |