uploader 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +55 -57
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/helpers/uploader_helper.rb +3 -3
- data/app/views/uploads/_swf_javascript.html.erb +9 -6
- data/app/views/uploads/_swf_upload.html.erb +2 -2
- data/app/views/uploads/_uploadify.html.erb +3 -3
- data/{locales → config/locales}/ar.yml +0 -0
- data/{locales → config/locales}/bg.yml +0 -0
- data/{locales → config/locales}/ca.yml +0 -0
- data/{locales → config/locales}/cs.yml +0 -0
- data/{locales → config/locales}/da.yml +0 -0
- data/{locales → config/locales}/de.yml +0 -0
- data/{locales → config/locales}/el.yml +0 -0
- data/{locales → config/locales}/en.yml +0 -0
- data/{locales → config/locales}/es.yml +0 -0
- data/{locales → config/locales}/et.yml +0 -0
- data/{locales → config/locales}/fa.yml +2 -2
- data/{locales → config/locales}/fi.yml +0 -0
- data/{locales → config/locales}/fr.yml +0 -0
- data/{locales → config/locales}/gl.yml +0 -0
- data/{locales → config/locales}/hi.yml +1 -1
- data/{locales → config/locales}/hr.yml +0 -0
- data/{locales → config/locales}/hu.yml +0 -0
- data/{locales → config/locales}/id.yml +1 -1
- data/{locales → config/locales}/it.yml +0 -0
- data/{locales → config/locales}/iw.yml +0 -0
- data/{locales → config/locales}/ja.yml +0 -0
- data/{locales → config/locales}/ko.yml +2 -2
- data/{locales → config/locales}/lt.yml +0 -0
- data/{locales → config/locales}/lv.yml +0 -0
- data/{locales → config/locales}/mt.yml +0 -0
- data/{locales → config/locales}/nl.yml +0 -0
- data/{locales → config/locales}/no.yml +0 -0
- data/{locales → config/locales}/pl.yml +0 -0
- data/{locales → config/locales}/pt-PT.yml +0 -0
- data/{locales → config/locales}/ro.yml +0 -0
- data/{locales → config/locales}/ru.yml +0 -0
- data/{locales → config/locales}/sk.yml +0 -0
- data/{locales → config/locales}/sl.yml +0 -0
- data/{locales → config/locales}/sq.yml +0 -0
- data/{locales → config/locales}/sr.yml +0 -0
- data/{locales → config/locales}/sv.yml +0 -0
- data/{locales → config/locales}/th.yml +1 -1
- data/{locales → config/locales}/tl.yml +0 -0
- data/{locales → config/locales}/tr.yml +0 -0
- data/{locales → config/locales}/uk.yml +0 -0
- data/{locales → config/locales}/vi.yml +2 -2
- data/{locales → config/locales}/zh-CN.yml +0 -0
- data/{locales → config/locales}/zh-TW.yml +0 -0
- data/{locales → config/locales}/zh.yml +0 -0
- data/config/routes.rb +8 -0
- data/lib/tasks/uploader.rake +22 -0
- data/lib/uploader/config.rb +65 -0
- data/lib/uploader/engine.rb +19 -0
- data/lib/uploader/models/upload.rb +229 -0
- data/lib/uploader.rb +4 -2
- data/test/{rails_root → rails_test}/.gitignore +0 -0
- data/test/{rails_root → rails_test}/.rake_tasks +0 -0
- data/test/rails_test/Gemfile +21 -0
- data/{Gemfile.lock → test/rails_test/Gemfile.lock} +21 -1
- data/test/rails_test/README +256 -0
- data/test/{rails_root → rails_test}/Rakefile +2 -7
- data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +0 -0
- data/test/rails_test/app/controllers/default_controller.rb +18 -0
- data/test/{rails_root → rails_test}/app/controllers/uploads_controller.rb +5 -2
- data/test/{rails_root → rails_test}/app/models/.keep +0 -0
- data/test/rails_test/app/models/upload.rb +38 -0
- data/test/{rails_root → rails_test}/app/models/user.rb +0 -0
- data/test/{rails_root → rails_test}/app/views/default/index.html.erb +11 -1
- data/test/rails_test/app/views/default/uploadify.html.erb +27 -0
- data/test/{rails_root → rails_test}/app/views/layouts/application.html.erb +2 -2
- data/test/{rails_root → rails_test}/config/amazon_s3.yml +0 -0
- data/test/{rails_root → rails_test}/config/application.rb +6 -12
- data/test/rails_test/config/boot.rb +13 -0
- data/test/{rails_root → rails_test}/config/database.yml +3 -11
- data/test/rails_test/config/environment.rb +5 -0
- data/test/rails_test/config/environments/development.rb +26 -0
- data/test/rails_test/config/environments/production.rb +49 -0
- data/test/rails_test/config/environments/test.rb +35 -0
- data/test/{rails_root → rails_test}/config/global_config.yml +0 -0
- data/test/{rails_root → rails_test}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
- data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
- data/test/{rails_root → rails_test}/config/initializers/s3_credentials.rb +1 -1
- data/test/{rails_root → rails_test}/config/initializers/secret_token.rb +1 -1
- data/test/rails_test/config/initializers/session_store.rb +8 -0
- data/test/rails_test/config/locales/en.yml +5 -0
- data/test/rails_test/config/routes.rb +13 -0
- data/test/rails_test/config.ru +4 -0
- data/test/{rails_root → rails_test}/db/.keep +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090517040220_create_uploads.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
- data/test/rails_test/db/seeds.rb +7 -0
- data/test/rails_test/doc/README_FOR_APP +2 -0
- data/test/{rails_root → rails_test}/features/step_definitions/webrat_steps.rb +0 -0
- data/test/{rails_root → rails_test}/features/support/env.rb +0 -0
- data/test/{rails_root → rails_test}/lib/daemons/amazonaws.rb +0 -0
- data/test/{rails_root/public/favicon.ico → rails_test/lib/tasks/.gitkeep} +0 -0
- data/test/rails_test/public/404.html +26 -0
- data/test/rails_test/public/422.html +26 -0
- data/test/rails_test/public/500.html +26 -0
- data/test/{rails_root/public/stylesheets/.keep → rails_test/public/favicon.ico} +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/excel.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_aac.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ai.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_avi.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_bin.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_bmp.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_cue.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_divx.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_doc.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_eps.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_flac.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_flv.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_gif.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_html.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ical.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_indd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_inx.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_iso.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_jpg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mov.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mp3.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mpg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_pdf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_php.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_png.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_pps.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ppt.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_psd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_qxd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_qxp.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_raw.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_rtf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_svg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_tif.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_txt.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_vcf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_wav.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_wma.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_xls.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_xml.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/mp3.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/pdf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/pdf.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/text.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/text.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/word.gif +0 -0
- data/test/rails_test/public/images/rails.png +0 -0
- data/test/{rails_root/public/images → rails_test/public/images/swfupload}/SWFUploadButton.png +0 -0
- data/test/{rails_root/public/images → rails_test/public/images/swfupload}/cancelbutton.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/uploadify/cancel.png +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/application.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/controls.js +75 -73
- data/test/{rails_root → rails_test}/public/javascripts/dragdrop.js +171 -169
- data/test/{rails_root → rails_test}/public/javascripts/effects.js +180 -177
- data/test/{rails_root/public/javascripts/jquery/jquery.js → rails_test/public/javascripts/jquery/jquery-1.4.2.min.js} +0 -0
- data/test/{rails_root/public/javascripts/jquery/jquery-ui.js → rails_test/public/javascripts/jquery/jquery-ui-1.8.4.custom.min.js} +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/jquery/jquery.uploadify.min.js +0 -0
- data/test/rails_test/public/javascripts/prototype.js +6001 -0
- data/test/rails_test/public/javascripts/rails.js +175 -0
- data/test/{rails_root → rails_test}/public/javascripts/swf/swfobject.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/fileprogress.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/handlers.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.cookies.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.proxy.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.queue.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.speed.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.swfobject.js +0 -0
- data/test/rails_test/public/robots.txt +5 -0
- data/test/{rails_root/test/functional/.keep → rails_test/public/stylesheets/.gitkeep} +0 -0
- data/test/{rails_root → rails_test}/public/stylesheets/swfupload.css +0 -0
- data/test/{rails_root → rails_test}/public/stylesheets/uploadify.css +0 -0
- data/test/{rails_root → rails_test}/public/swf/expressInstall.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/swfupload.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/swfupload_fp9.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/uploadify.swf +0 -0
- data/test/rails_test/script/rails +6 -0
- data/test/{rails_root → rails_test}/test/factories.rb +1 -1
- data/test/{rails_root → rails_test}/test/fixtures/files/5k.png +0 -0
- data/test/{rails_root → rails_test}/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG +0 -0
- data/test/rails_test/test/fixtures/rails.png +0 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.doc +0 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.pdf +0 -0
- data/test/rails_test/test/fixtures/test.txt +1 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.xls +0 -0
- data/test/{rails_root/test/integration → rails_test/test/functional}/.keep +0 -0
- data/test/{rails_root → rails_test}/test/functional/default_controller_test.rb +0 -0
- data/test/{rails_root → rails_test}/test/functional/uploads_controller_test.rb +0 -0
- data/test/{rails_root/test/mocks/development → rails_test/test/integration}/.keep +0 -0
- data/test/rails_test/test/performance/browsing_test.rb +9 -0
- data/test/{rails_root → rails_test}/test/shoulda_macros/paperclip.rb +0 -0
- data/test/rails_test/test/test_helper.rb +25 -0
- data/test/{rails_root/test/mocks/test → rails_test/test/unit}/.keep +0 -0
- data/test/{rails_root → rails_test}/test/unit/upload_test.rb +9 -18
- data/test/{rails_root/test/unit/.keep → rails_test/vendor/plugins/.gitkeep} +0 -0
- data/uploader.gemspec +225 -255
- metadata +228 -258
- data/Gemfile +0 -13
- data/config/uploader_routes.rb +0 -3
- data/lib/active_record/acts/uploader_upload.rb +0 -279
- data/lib/uploader/initialize_routes.rb +0 -8
- data/lib/uploader/tasks.rb +0 -42
- data/rails/init.rb +0 -38
- data/tasks/rails.rake +0 -2
- data/test/rails_root/Capfile +0 -3
- data/test/rails_root/app/controllers/default_controller.rb +0 -12
- data/test/rails_root/app/models/upload.rb +0 -55
- data/test/rails_root/app/views/default/uploadify.html.erb +0 -17
- data/test/rails_root/config/boot.rb +0 -109
- data/test/rails_root/config/environment.rb +0 -29
- data/test/rails_root/config/environments/development.rb +0 -19
- data/test/rails_root/config/environments/production.rb +0 -1
- data/test/rails_root/config/environments/test.rb +0 -27
- data/test/rails_root/config/initializers/requires.rb +0 -13
- data/test/rails_root/config/initializers/session_store.rb +0 -8
- data/test/rails_root/config/initializers/uploader.rb +0 -11
- data/test/rails_root/config/routes.rb +0 -13
- data/test/rails_root/db/development.sqlite3 +0 -0
- data/test/rails_root/db/schema.rb +0 -47
- data/test/rails_root/db/test.sqlite3 +0 -0
- data/test/rails_root/public/.htaccess +0 -40
- data/test/rails_root/public/404.html +0 -30
- data/test/rails_root/public/422.html +0 -30
- data/test/rails_root/public/500.html +0 -30
- data/test/rails_root/public/dispatch.rb +0 -10
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/images/swfupload/SWFUploadButton.png +0 -0
- data/test/rails_root/public/images/swfupload/cancelbutton.gif +0 -0
- data/test/rails_root/public/javascripts/builder.js +0 -136
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +0 -1
- data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +0 -9
- data/test/rails_root/public/javascripts/jquery/jquery.form.js +0 -637
- data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +0 -2
- data/test/rails_root/public/javascripts/jquery/jquery.tips.js +0 -69
- data/test/rails_root/public/javascripts/jquery/jrails.js +0 -1
- data/test/rails_root/public/javascripts/prototype.js +0 -4225
- data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
- data/test/rails_root/public/javascripts/slider.js +0 -277
- data/test/rails_root/public/javascripts/sound.js +0 -60
- data/test/rails_root/public/robots.txt +0 -1
- data/test/rails_root/script/about +0 -3
- data/test/rails_root/script/breakpointer +0 -3
- data/test/rails_root/script/console +0 -3
- data/test/rails_root/script/create_project.rb +0 -52
- data/test/rails_root/script/cucumber +0 -7
- data/test/rails_root/script/dbconsole +0 -3
- data/test/rails_root/script/destroy +0 -3
- data/test/rails_root/script/generate +0 -3
- data/test/rails_root/script/performance/benchmarker +0 -3
- data/test/rails_root/script/performance/profiler +0 -3
- data/test/rails_root/script/performance/request +0 -3
- data/test/rails_root/script/plugin +0 -3
- data/test/rails_root/script/process/inspector +0 -3
- data/test/rails_root/script/process/reaper +0 -3
- data/test/rails_root/script/process/spawner +0 -3
- data/test/rails_root/script/runner +0 -3
- data/test/rails_root/script/server +0 -3
- data/test/rails_root/test/test_helper.rb +0 -26
@@ -0,0 +1,175 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
})();
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -10,5 +10,5 @@ Factory.define :upload do |f|
|
|
10
10
|
f.creator {|a| a.association(:user)}
|
11
11
|
f.uploadable {|a| a.association(:user)}
|
12
12
|
f.caption { Factory.next(:name) }
|
13
|
-
f.local
|
13
|
+
f.local fixture_file_upload('rails.png', 'image/png')
|
14
14
|
end
|
File without changes
|
File without changes
|
Binary file
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
This is just a text file.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.reject! { |e| e.include? 'TextMate' }
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
require File.expand_path('../../config/environment', __FILE__)
|
4
|
+
|
5
|
+
require 'rails/test_help'
|
6
|
+
include ActionDispatch::TestProcess
|
7
|
+
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/factories')
|
9
|
+
require File.join(File.dirname(__FILE__), 'shoulda_macros', 'paperclip')
|
10
|
+
|
11
|
+
class ActiveSupport::TestCase
|
12
|
+
|
13
|
+
VALID_FILE = fixture_file_upload('rails.png', 'image/png')
|
14
|
+
VALID_TEXT_FILE = fixture_file_upload('test.txt', 'text/plain')
|
15
|
+
VALID_PDF_FILE = fixture_file_upload('test.pdf', 'application/pdf')
|
16
|
+
VALID_WORD_FILE = fixture_file_upload('test.doc', 'application/word')
|
17
|
+
VALID_EXCEL_FILE = fixture_file_upload('test.xls', 'application/excel')
|
18
|
+
|
19
|
+
self.use_transactional_fixtures = true
|
20
|
+
self.use_instantiated_fixtures = false
|
21
|
+
|
22
|
+
def ensure_flash(val)
|
23
|
+
assert_contains flash.values, val, ", Flash: #{flash.inspect}"
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
@@ -3,16 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class UploadTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
context "upload" do
|
6
|
-
|
7
|
-
context 'options' do
|
8
|
-
should 'not enable immediate transfers to S3 by default' do
|
9
|
-
assert false == Upload.s3_no_wait?
|
10
|
-
end
|
11
|
-
should 'keep a local copy of each upload by default' do
|
12
|
-
assert true == Upload.keep_local_file?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
6
|
+
|
16
7
|
context 'upload instance' do
|
17
8
|
|
18
9
|
should belong_to :uploadable
|
@@ -29,7 +20,7 @@ class UploadTest < ActiveSupport::TestCase
|
|
29
20
|
upload = Upload.new
|
30
21
|
upload.stubs(:id).returns(12345)
|
31
22
|
upload.local = VALID_FILE
|
32
|
-
assert_equal "#{
|
23
|
+
assert_equal "#{::Rails.root.to_s}/public/system/locals/000/012/345/original/rails.png", upload.local.path
|
33
24
|
assert_equal '/system/locals/000/012/345/original/rails.png', upload.local.url(:original, false)
|
34
25
|
end
|
35
26
|
|
@@ -79,15 +70,15 @@ class UploadTest < ActiveSupport::TestCase
|
|
79
70
|
assert_equal @second, Upload.by_filename[1]
|
80
71
|
end
|
81
72
|
end
|
82
|
-
context "'
|
73
|
+
context "'is_public' named scope" do
|
83
74
|
setup do
|
84
75
|
Upload.delete_all
|
85
76
|
@first = Factory(:upload, :is_public => true)
|
86
77
|
@second = Factory(:upload, :is_public => false)
|
87
78
|
end
|
88
79
|
should "find public files" do
|
89
|
-
assert Upload.
|
90
|
-
assert !Upload.
|
80
|
+
assert Upload.is_public.include?(@first)
|
81
|
+
assert !Upload.is_public.include?(@second)
|
91
82
|
end
|
92
83
|
end
|
93
84
|
context "'pending_s3_migrations' named scope" do
|
@@ -105,7 +96,7 @@ class UploadTest < ActiveSupport::TestCase
|
|
105
96
|
setup do
|
106
97
|
Upload.delete_all
|
107
98
|
@first = Factory(:upload) # default is png
|
108
|
-
@second = Factory(:upload, :local =>
|
99
|
+
@second = Factory(:upload, :local => fixture_file_upload('test.doc', 'application/msword'))
|
109
100
|
end
|
110
101
|
should "find images" do
|
111
102
|
assert Upload.images.include?(@first)
|
@@ -115,7 +106,7 @@ class UploadTest < ActiveSupport::TestCase
|
|
115
106
|
context "'documents' named scope" do
|
116
107
|
setup do
|
117
108
|
Upload.delete_all
|
118
|
-
@first = Factory(:upload, :local =>
|
109
|
+
@first = Factory(:upload, :local => fixture_file_upload('test.doc', 'application/msword'))
|
119
110
|
@second = Factory(:upload)
|
120
111
|
end
|
121
112
|
should "find documents" do
|
@@ -126,7 +117,7 @@ class UploadTest < ActiveSupport::TestCase
|
|
126
117
|
context "'files' named scope" do
|
127
118
|
setup do
|
128
119
|
Upload.delete_all
|
129
|
-
@first = Factory(:upload, :local =>
|
120
|
+
@first = Factory(:upload, :local => fixture_file_upload('test.pdf', 'application/pdf'))
|
130
121
|
@second = Factory(:upload)
|
131
122
|
end
|
132
123
|
should "find files (not images)" do
|
@@ -152,6 +143,6 @@ class UploadTest < ActiveSupport::TestCase
|
|
152
143
|
|
153
144
|
private
|
154
145
|
def fixture_file(name)
|
155
|
-
File.new(File.join(
|
146
|
+
File.new(File.join(::Rails.root.to_s, 'test', 'fixtures', 'files', name), 'rb')
|
156
147
|
end
|
157
148
|
end
|
File without changes
|