uploader 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. data/README.rdoc +55 -57
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/app/helpers/uploader_helper.rb +3 -3
  5. data/app/views/uploads/_swf_javascript.html.erb +9 -6
  6. data/app/views/uploads/_swf_upload.html.erb +2 -2
  7. data/app/views/uploads/_uploadify.html.erb +3 -3
  8. data/{locales → config/locales}/ar.yml +0 -0
  9. data/{locales → config/locales}/bg.yml +0 -0
  10. data/{locales → config/locales}/ca.yml +0 -0
  11. data/{locales → config/locales}/cs.yml +0 -0
  12. data/{locales → config/locales}/da.yml +0 -0
  13. data/{locales → config/locales}/de.yml +0 -0
  14. data/{locales → config/locales}/el.yml +0 -0
  15. data/{locales → config/locales}/en.yml +0 -0
  16. data/{locales → config/locales}/es.yml +0 -0
  17. data/{locales → config/locales}/et.yml +0 -0
  18. data/{locales → config/locales}/fa.yml +2 -2
  19. data/{locales → config/locales}/fi.yml +0 -0
  20. data/{locales → config/locales}/fr.yml +0 -0
  21. data/{locales → config/locales}/gl.yml +0 -0
  22. data/{locales → config/locales}/hi.yml +1 -1
  23. data/{locales → config/locales}/hr.yml +0 -0
  24. data/{locales → config/locales}/hu.yml +0 -0
  25. data/{locales → config/locales}/id.yml +1 -1
  26. data/{locales → config/locales}/it.yml +0 -0
  27. data/{locales → config/locales}/iw.yml +0 -0
  28. data/{locales → config/locales}/ja.yml +0 -0
  29. data/{locales → config/locales}/ko.yml +2 -2
  30. data/{locales → config/locales}/lt.yml +0 -0
  31. data/{locales → config/locales}/lv.yml +0 -0
  32. data/{locales → config/locales}/mt.yml +0 -0
  33. data/{locales → config/locales}/nl.yml +0 -0
  34. data/{locales → config/locales}/no.yml +0 -0
  35. data/{locales → config/locales}/pl.yml +0 -0
  36. data/{locales → config/locales}/pt-PT.yml +0 -0
  37. data/{locales → config/locales}/ro.yml +0 -0
  38. data/{locales → config/locales}/ru.yml +0 -0
  39. data/{locales → config/locales}/sk.yml +0 -0
  40. data/{locales → config/locales}/sl.yml +0 -0
  41. data/{locales → config/locales}/sq.yml +0 -0
  42. data/{locales → config/locales}/sr.yml +0 -0
  43. data/{locales → config/locales}/sv.yml +0 -0
  44. data/{locales → config/locales}/th.yml +1 -1
  45. data/{locales → config/locales}/tl.yml +0 -0
  46. data/{locales → config/locales}/tr.yml +0 -0
  47. data/{locales → config/locales}/uk.yml +0 -0
  48. data/{locales → config/locales}/vi.yml +2 -2
  49. data/{locales → config/locales}/zh-CN.yml +0 -0
  50. data/{locales → config/locales}/zh-TW.yml +0 -0
  51. data/{locales → config/locales}/zh.yml +0 -0
  52. data/config/routes.rb +8 -0
  53. data/lib/tasks/uploader.rake +22 -0
  54. data/lib/uploader/config.rb +65 -0
  55. data/lib/uploader/engine.rb +19 -0
  56. data/lib/uploader/models/upload.rb +229 -0
  57. data/lib/uploader.rb +4 -2
  58. data/test/{rails_root → rails_test}/.gitignore +0 -0
  59. data/test/{rails_root → rails_test}/.rake_tasks +0 -0
  60. data/test/rails_test/Gemfile +21 -0
  61. data/{Gemfile.lock → test/rails_test/Gemfile.lock} +21 -1
  62. data/test/rails_test/README +256 -0
  63. data/test/{rails_root → rails_test}/Rakefile +2 -7
  64. data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +0 -0
  65. data/test/rails_test/app/controllers/default_controller.rb +18 -0
  66. data/test/{rails_root → rails_test}/app/controllers/uploads_controller.rb +5 -2
  67. data/test/{rails_root → rails_test}/app/models/.keep +0 -0
  68. data/test/rails_test/app/models/upload.rb +38 -0
  69. data/test/{rails_root → rails_test}/app/models/user.rb +0 -0
  70. data/test/{rails_root → rails_test}/app/views/default/index.html.erb +11 -1
  71. data/test/rails_test/app/views/default/uploadify.html.erb +27 -0
  72. data/test/{rails_root → rails_test}/app/views/layouts/application.html.erb +2 -2
  73. data/test/{rails_root → rails_test}/config/amazon_s3.yml +0 -0
  74. data/test/{rails_root → rails_test}/config/application.rb +6 -12
  75. data/test/rails_test/config/boot.rb +13 -0
  76. data/test/{rails_root → rails_test}/config/database.yml +3 -11
  77. data/test/rails_test/config/environment.rb +5 -0
  78. data/test/rails_test/config/environments/development.rb +26 -0
  79. data/test/rails_test/config/environments/production.rb +49 -0
  80. data/test/rails_test/config/environments/test.rb +35 -0
  81. data/test/{rails_root → rails_test}/config/global_config.yml +0 -0
  82. data/test/{rails_root → rails_test}/config/initializers/backtrace_silencers.rb +0 -0
  83. data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
  84. data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
  85. data/test/{rails_root → rails_test}/config/initializers/s3_credentials.rb +1 -1
  86. data/test/{rails_root → rails_test}/config/initializers/secret_token.rb +1 -1
  87. data/test/rails_test/config/initializers/session_store.rb +8 -0
  88. data/test/rails_test/config/locales/en.yml +5 -0
  89. data/test/rails_test/config/routes.rb +13 -0
  90. data/test/rails_test/config.ru +4 -0
  91. data/test/{rails_root → rails_test}/db/.keep +0 -0
  92. data/test/{rails_root → rails_test}/db/migrate/20090517040220_create_uploads.rb +0 -0
  93. data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
  94. data/test/rails_test/db/seeds.rb +7 -0
  95. data/test/rails_test/doc/README_FOR_APP +2 -0
  96. data/test/{rails_root → rails_test}/features/step_definitions/webrat_steps.rb +0 -0
  97. data/test/{rails_root → rails_test}/features/support/env.rb +0 -0
  98. data/test/{rails_root → rails_test}/lib/daemons/amazonaws.rb +0 -0
  99. data/test/{rails_root/public/favicon.ico → rails_test/lib/tasks/.gitkeep} +0 -0
  100. data/test/rails_test/public/404.html +26 -0
  101. data/test/rails_test/public/422.html +26 -0
  102. data/test/rails_test/public/500.html +26 -0
  103. data/test/{rails_root/public/stylesheets/.keep → rails_test/public/favicon.ico} +0 -0
  104. data/test/{rails_root → rails_test}/public/images/file_icons/excel.gif +0 -0
  105. data/test/{rails_root → rails_test}/public/images/file_icons/file.gif +0 -0
  106. data/test/{rails_root → rails_test}/public/images/file_icons/file.png +0 -0
  107. data/test/{rails_root → rails_test}/public/images/file_icons/file_aac.gif +0 -0
  108. data/test/{rails_root → rails_test}/public/images/file_icons/file_ai.gif +0 -0
  109. data/test/{rails_root → rails_test}/public/images/file_icons/file_avi.gif +0 -0
  110. data/test/{rails_root → rails_test}/public/images/file_icons/file_bin.gif +0 -0
  111. data/test/{rails_root → rails_test}/public/images/file_icons/file_bmp.gif +0 -0
  112. data/test/{rails_root → rails_test}/public/images/file_icons/file_cue.gif +0 -0
  113. data/test/{rails_root → rails_test}/public/images/file_icons/file_divx.gif +0 -0
  114. data/test/{rails_root → rails_test}/public/images/file_icons/file_doc.gif +0 -0
  115. data/test/{rails_root → rails_test}/public/images/file_icons/file_eps.gif +0 -0
  116. data/test/{rails_root → rails_test}/public/images/file_icons/file_flac.gif +0 -0
  117. data/test/{rails_root → rails_test}/public/images/file_icons/file_flv.gif +0 -0
  118. data/test/{rails_root → rails_test}/public/images/file_icons/file_gif.gif +0 -0
  119. data/test/{rails_root → rails_test}/public/images/file_icons/file_html.gif +0 -0
  120. data/test/{rails_root → rails_test}/public/images/file_icons/file_ical.gif +0 -0
  121. data/test/{rails_root → rails_test}/public/images/file_icons/file_indd.gif +0 -0
  122. data/test/{rails_root → rails_test}/public/images/file_icons/file_inx.gif +0 -0
  123. data/test/{rails_root → rails_test}/public/images/file_icons/file_iso.gif +0 -0
  124. data/test/{rails_root → rails_test}/public/images/file_icons/file_jpg.gif +0 -0
  125. data/test/{rails_root → rails_test}/public/images/file_icons/file_mov.gif +0 -0
  126. data/test/{rails_root → rails_test}/public/images/file_icons/file_mp3.gif +0 -0
  127. data/test/{rails_root → rails_test}/public/images/file_icons/file_mpg.gif +0 -0
  128. data/test/{rails_root → rails_test}/public/images/file_icons/file_pdf.gif +0 -0
  129. data/test/{rails_root → rails_test}/public/images/file_icons/file_php.gif +0 -0
  130. data/test/{rails_root → rails_test}/public/images/file_icons/file_png.gif +0 -0
  131. data/test/{rails_root → rails_test}/public/images/file_icons/file_pps.gif +0 -0
  132. data/test/{rails_root → rails_test}/public/images/file_icons/file_ppt.gif +0 -0
  133. data/test/{rails_root → rails_test}/public/images/file_icons/file_psd.gif +0 -0
  134. data/test/{rails_root → rails_test}/public/images/file_icons/file_qxd.gif +0 -0
  135. data/test/{rails_root → rails_test}/public/images/file_icons/file_qxp.gif +0 -0
  136. data/test/{rails_root → rails_test}/public/images/file_icons/file_raw.gif +0 -0
  137. data/test/{rails_root → rails_test}/public/images/file_icons/file_rtf.gif +0 -0
  138. data/test/{rails_root → rails_test}/public/images/file_icons/file_svg.gif +0 -0
  139. data/test/{rails_root → rails_test}/public/images/file_icons/file_tif.gif +0 -0
  140. data/test/{rails_root → rails_test}/public/images/file_icons/file_txt.gif +0 -0
  141. data/test/{rails_root → rails_test}/public/images/file_icons/file_vcf.gif +0 -0
  142. data/test/{rails_root → rails_test}/public/images/file_icons/file_wav.gif +0 -0
  143. data/test/{rails_root → rails_test}/public/images/file_icons/file_wma.gif +0 -0
  144. data/test/{rails_root → rails_test}/public/images/file_icons/file_xls.gif +0 -0
  145. data/test/{rails_root → rails_test}/public/images/file_icons/file_xml.gif +0 -0
  146. data/test/{rails_root → rails_test}/public/images/file_icons/mp3.gif +0 -0
  147. data/test/{rails_root → rails_test}/public/images/file_icons/pdf.gif +0 -0
  148. data/test/{rails_root → rails_test}/public/images/file_icons/pdf.png +0 -0
  149. data/test/{rails_root → rails_test}/public/images/file_icons/text.gif +0 -0
  150. data/test/{rails_root → rails_test}/public/images/file_icons/text.png +0 -0
  151. data/test/{rails_root → rails_test}/public/images/file_icons/word.gif +0 -0
  152. data/test/rails_test/public/images/rails.png +0 -0
  153. data/test/{rails_root/public/images → rails_test/public/images/swfupload}/SWFUploadButton.png +0 -0
  154. data/test/{rails_root/public/images → rails_test/public/images/swfupload}/cancelbutton.gif +0 -0
  155. data/test/{rails_root → rails_test}/public/images/uploadify/cancel.png +0 -0
  156. data/test/{rails_root → rails_test}/public/javascripts/application.js +0 -0
  157. data/test/{rails_root → rails_test}/public/javascripts/controls.js +75 -73
  158. data/test/{rails_root → rails_test}/public/javascripts/dragdrop.js +171 -169
  159. data/test/{rails_root → rails_test}/public/javascripts/effects.js +180 -177
  160. data/test/{rails_root/public/javascripts/jquery/jquery.js → rails_test/public/javascripts/jquery/jquery-1.4.2.min.js} +0 -0
  161. 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
  162. data/test/{rails_root → rails_test}/public/javascripts/jquery/jquery.uploadify.min.js +0 -0
  163. data/test/rails_test/public/javascripts/prototype.js +6001 -0
  164. data/test/rails_test/public/javascripts/rails.js +175 -0
  165. data/test/{rails_root → rails_test}/public/javascripts/swf/swfobject.js +0 -0
  166. data/test/{rails_root → rails_test}/public/javascripts/swfupload/fileprogress.js +0 -0
  167. data/test/{rails_root → rails_test}/public/javascripts/swfupload/handlers.js +0 -0
  168. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.cookies.js +0 -0
  169. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.js +0 -0
  170. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.proxy.js +0 -0
  171. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.queue.js +0 -0
  172. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.speed.js +0 -0
  173. data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.swfobject.js +0 -0
  174. data/test/rails_test/public/robots.txt +5 -0
  175. data/test/{rails_root/test/functional/.keep → rails_test/public/stylesheets/.gitkeep} +0 -0
  176. data/test/{rails_root → rails_test}/public/stylesheets/swfupload.css +0 -0
  177. data/test/{rails_root → rails_test}/public/stylesheets/uploadify.css +0 -0
  178. data/test/{rails_root → rails_test}/public/swf/expressInstall.swf +0 -0
  179. data/test/{rails_root → rails_test}/public/swf/swfupload.swf +0 -0
  180. data/test/{rails_root → rails_test}/public/swf/swfupload_fp9.swf +0 -0
  181. data/test/{rails_root → rails_test}/public/swf/uploadify.swf +0 -0
  182. data/test/rails_test/script/rails +6 -0
  183. data/test/{rails_root → rails_test}/test/factories.rb +1 -1
  184. data/test/{rails_root → rails_test}/test/fixtures/files/5k.png +0 -0
  185. data/test/{rails_root → rails_test}/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG +0 -0
  186. data/test/rails_test/test/fixtures/rails.png +0 -0
  187. data/test/{rails_root/test → rails_test/test/fixtures}/test.doc +0 -0
  188. data/test/{rails_root/test → rails_test/test/fixtures}/test.pdf +0 -0
  189. data/test/rails_test/test/fixtures/test.txt +1 -0
  190. data/test/{rails_root/test → rails_test/test/fixtures}/test.xls +0 -0
  191. data/test/{rails_root/test/integration → rails_test/test/functional}/.keep +0 -0
  192. data/test/{rails_root → rails_test}/test/functional/default_controller_test.rb +0 -0
  193. data/test/{rails_root → rails_test}/test/functional/uploads_controller_test.rb +0 -0
  194. data/test/{rails_root/test/mocks/development → rails_test/test/integration}/.keep +0 -0
  195. data/test/rails_test/test/performance/browsing_test.rb +9 -0
  196. data/test/{rails_root → rails_test}/test/shoulda_macros/paperclip.rb +0 -0
  197. data/test/rails_test/test/test_helper.rb +25 -0
  198. data/test/{rails_root/test/mocks/test → rails_test/test/unit}/.keep +0 -0
  199. data/test/{rails_root → rails_test}/test/unit/upload_test.rb +9 -18
  200. data/test/{rails_root/test/unit/.keep → rails_test/vendor/plugins/.gitkeep} +0 -0
  201. data/uploader.gemspec +225 -255
  202. metadata +228 -258
  203. data/Gemfile +0 -13
  204. data/config/uploader_routes.rb +0 -3
  205. data/lib/active_record/acts/uploader_upload.rb +0 -279
  206. data/lib/uploader/initialize_routes.rb +0 -8
  207. data/lib/uploader/tasks.rb +0 -42
  208. data/rails/init.rb +0 -38
  209. data/tasks/rails.rake +0 -2
  210. data/test/rails_root/Capfile +0 -3
  211. data/test/rails_root/app/controllers/default_controller.rb +0 -12
  212. data/test/rails_root/app/models/upload.rb +0 -55
  213. data/test/rails_root/app/views/default/uploadify.html.erb +0 -17
  214. data/test/rails_root/config/boot.rb +0 -109
  215. data/test/rails_root/config/environment.rb +0 -29
  216. data/test/rails_root/config/environments/development.rb +0 -19
  217. data/test/rails_root/config/environments/production.rb +0 -1
  218. data/test/rails_root/config/environments/test.rb +0 -27
  219. data/test/rails_root/config/initializers/requires.rb +0 -13
  220. data/test/rails_root/config/initializers/session_store.rb +0 -8
  221. data/test/rails_root/config/initializers/uploader.rb +0 -11
  222. data/test/rails_root/config/routes.rb +0 -13
  223. data/test/rails_root/db/development.sqlite3 +0 -0
  224. data/test/rails_root/db/schema.rb +0 -47
  225. data/test/rails_root/db/test.sqlite3 +0 -0
  226. data/test/rails_root/public/.htaccess +0 -40
  227. data/test/rails_root/public/404.html +0 -30
  228. data/test/rails_root/public/422.html +0 -30
  229. data/test/rails_root/public/500.html +0 -30
  230. data/test/rails_root/public/dispatch.rb +0 -10
  231. data/test/rails_root/public/images/rails.png +0 -0
  232. data/test/rails_root/public/images/swfupload/SWFUploadButton.png +0 -0
  233. data/test/rails_root/public/images/swfupload/cancelbutton.gif +0 -0
  234. data/test/rails_root/public/javascripts/builder.js +0 -136
  235. data/test/rails_root/public/javascripts/jquery/jquery.easing.js +0 -1
  236. data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +0 -9
  237. data/test/rails_root/public/javascripts/jquery/jquery.form.js +0 -637
  238. data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +0 -2
  239. data/test/rails_root/public/javascripts/jquery/jquery.tips.js +0 -69
  240. data/test/rails_root/public/javascripts/jquery/jrails.js +0 -1
  241. data/test/rails_root/public/javascripts/prototype.js +0 -4225
  242. data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
  243. data/test/rails_root/public/javascripts/slider.js +0 -277
  244. data/test/rails_root/public/javascripts/sound.js +0 -60
  245. data/test/rails_root/public/robots.txt +0 -1
  246. data/test/rails_root/script/about +0 -3
  247. data/test/rails_root/script/breakpointer +0 -3
  248. data/test/rails_root/script/console +0 -3
  249. data/test/rails_root/script/create_project.rb +0 -52
  250. data/test/rails_root/script/cucumber +0 -7
  251. data/test/rails_root/script/dbconsole +0 -3
  252. data/test/rails_root/script/destroy +0 -3
  253. data/test/rails_root/script/generate +0 -3
  254. data/test/rails_root/script/performance/benchmarker +0 -3
  255. data/test/rails_root/script/performance/profiler +0 -3
  256. data/test/rails_root/script/performance/request +0 -3
  257. data/test/rails_root/script/plugin +0 -3
  258. data/test/rails_root/script/process/inspector +0 -3
  259. data/test/rails_root/script/process/reaper +0 -3
  260. data/test/rails_root/script/process/spawner +0 -3
  261. data/test/rails_root/script/runner +0 -3
  262. data/test/rails_root/script/server +0 -3
  263. data/test/rails_root/test/test_helper.rb +0 -26
data/README.rdoc CHANGED
@@ -5,9 +5,6 @@ Uploader makes it easy to integrate multiple file uploads into your application
5
5
  == ----NOTES----
6
6
  SWFUpload hasn't been updated in a while and tends to be buggy. We have added uploadify. We recommend using that instead.
7
7
 
8
- This branch has been setup to maintain compatibility with Rails2. Future versions of uploader will focus on Rails 3.
9
- Note that all 2.x.x versions of uploader will work with Rails 2 while 3.x.x versions are slated for Rails 3.
10
-
11
8
  == Installation
12
9
 
13
10
  === Install the gem:
@@ -17,10 +14,8 @@ Installing uploader should also install mime-types and rack. If for some reason
17
14
  sudo gem install mime-types
18
15
  sudo gem install rack
19
16
 
20
-
21
- === Add the gem to environment.rb
22
- config.gem 'uploader'
23
-
17
+ === Add the gem to Gemfile
18
+ gem 'uploader'
24
19
 
25
20
  === Install jQuery
26
21
  uploader uses jQuery. You'll need to include it in your application. Download it here:
@@ -29,38 +24,49 @@ http://jquery.com/
29
24
  Then include it in your layout:
30
25
  <%= javascript_include_tag 'jquery/jquery.js' %>
31
26
 
27
+ === Create an initializer to configure uploader
28
+ The default settings are fine for most uses, but if you want to use Amazon S3 or configure the size of the resulting
29
+ images you can configure uploader by creating an initializer:
30
+
31
+ Uploader.configure do |config|
32
+ config.enable_s3 = true # Turns S3 on/off
33
+ config.s3_no_wait = true # Send the file to S3 immediately. If this is false you will need to setup a daemon process to upload to S3. See below.
34
+ config.keep_local_file = true # Even when uploading to S3 keep the local file.
35
+ config.disable_halt_nonimage_processing = false # Paperclip will try to generate thumbnails for pdfs unless this is set to true
36
+ # These are the settings that will be passed to Paperclip:
37
+ config.has_attached_file_options = {
38
+ :url => "/system/:attachment/:id_partition/:style/:basename.:extension",
39
+ :path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
40
+ :styles => { :icon => "30x30!",
41
+ :thumb => "100>",
42
+ :small => "150>",
43
+ :medium => "300>",
44
+ :large => "660>" },
45
+ :default_url => "/images/default.jpg",
46
+ :storage => :s3,
47
+ :s3_credentials => AMAZON_S3_CREDENTIALS,
48
+ :bucket => "assets.example.com",
49
+ :s3_host_alias => "assets.example.com",
50
+ :convert_options => {
51
+ :all => '-quality 80'
52
+ }
53
+ }
54
+ end
55
+
32
56
  === Create a model for uploads.
33
- Create an 'Upload' model in upload.rb. acts_as_uploader accepts all valid options for paperclip via :has_attached_file => {}
57
+ Create an 'Upload' model in upload.rb.
34
58
 
35
59
  class Upload < ActiveRecord::Base
36
60
 
37
- acts_as_uploader :enable_s3 => false,
38
- :has_attached_file => {
39
- :url => "/system/:attachment/:id_partition/:style/:basename.:extension",
40
- :path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
41
- :styles => { :icon => "30x30!",
42
- :thumb => "100>",
43
- :small => "150>",
44
- :medium => "300>",
45
- :large => "660>" },
46
- :default_url => "/images/profile_default.jpg",
47
- :storage => :s3,
48
- :s3_credentials => AMAZON_S3_CREDENTIALS,
49
- :bucket => "assets.example.com",
50
- :s3_host_alias => "assets.example.com",
51
- :convert_options => {
52
- :all => '-quality 80'
53
- }
54
- },
55
- :s3_path => ':id_partition/:style/:basename.:extension'
56
-
61
+ include Uploader::Models::Upload
62
+
57
63
  # only allow images:
58
64
  # validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg']
59
65
 
60
66
  # limit uploads to 10 MB
61
67
  # validates_attachment_size :local, :less_than => 10.megabytes
62
68
 
63
- # The following method is implemented in 'acts_as_uploader'. This is the method destroy will check to see if
69
+ # The following method is implemented in the upload model mixin. This is the method destroy will check to see if
64
70
  # the user has permission to delete the object. Add additional logic as needed or if the existing logic
65
71
  # looks fine then feel free to delete this comment and the can_edit? method.
66
72
  def can_edit?(check_user)
@@ -110,9 +116,16 @@ default functionality that you may consider overriding.
110
116
  Be sure to modify your routes file. Add the following line to ensure that your application uses the new uploads
111
117
  controller instead of directly using the one inside the gem:
112
118
 
113
- map.resources :uploads, :collection => { :multiupload => :post }
119
+ ==== routes.rb
114
120
 
115
-
121
+ # Add the following to routes.rb and modify it as needed:
122
+ resources :uploads do
123
+ collection do
124
+ post :multiupload
125
+ end
126
+ end
127
+
128
+ ===== controller class
116
129
  class UploadsController < Uploader::UploadsController
117
130
 
118
131
  prepend_before_filter :login_required
@@ -169,46 +182,36 @@ You'll need something like this in your layout so that uploader can add in the r
169
182
 
170
183
  Then to add an upload form:
171
184
 
185
+ Uploadify version (recommended):
186
+ <%= uploadify_form(parent_object) %>
187
+
188
+ OR
189
+
172
190
  SWFUpload version:
173
- <%= upload_form(parent_object) %>
191
+ <%= upload_form(parent_object) %>
174
192
 
175
- Uploadify version (recommended):
176
- <%= uploadify_form(parent_object) %>
177
193
 
178
194
  See the uploader_helper.rb file for options. parent_object should be the object which owns the uploads. ie a user, photo_album, etc.
179
195
 
180
196
  === Rake Tasks
181
197
 
182
- Add the rake tasks for uploader to your project. You will need to add the following to your applications's Rakefile
183
-
184
- require 'uploader'
185
- require 'uploader/tasks'
186
-
187
- Then run:
188
- rake uploader:sync
198
+ rake uploader:sync # will copy all required assets (css, javascript, images, migrations, etc) from uploadify into your project
199
+ rake db:migrate #This will create an uploads table for you. If you selected a different name for your model you will need to modify the migration accordingly.
189
200
 
190
- Last run:
191
- rake db:migrate
192
- This will create an uploads table for you. If you selected a different name for your model you will need to modify the migration accordingly.
193
201
  == WARNING
194
202
  The migration will drop any existing 'uploads' table you have in place
195
203
 
196
-
197
- That will copy all the required javascript and asset files into your project
198
-
199
-
200
204
  == Amazon s3
201
205
 
202
-
203
206
  If you'd like to store your uploads on Amazon's S3 service there are a few extra steps involved. See the example file above
204
207
  to view the options in context.
205
208
 
206
209
  === Turn on s3
207
210
  Set the enable_s3 option to true in acts_as_uploader
208
- :enable_s3 => true
211
+ config.enable_s3 = true
209
212
 
210
- Pass your s3 credentials into acts_as_uploader
211
- :has_attached_file => { :s3_credentials => File.join(RAILS_ROOT, 'config', 's3.yml') }
213
+ Pass in your s3 credentials
214
+ config.has_attached_file_options = { :s3_credentials => File.join(::Rails.root.to_s, 'config', 's3.yml') }
212
215
 
213
216
  === Setup your credentials
214
217
  Create a file named s3.yml in your configuration directory and add the following lines:
@@ -336,11 +339,6 @@ The following jQuery code will do an ajax delete for you
336
339
  }
337
340
 
338
341
 
339
- === Testing
340
- If you intend to develop code and wish to run the tests you may do so using rake test. However, note that you will need to install the gem first using
341
- rake install since the embedded test application will use the gem that is install and not the current code from the project. This is a limitation
342
- I attempted to overcome using a special initializer in rails_root/config/initializers/uploader.rb but I didn't have any success getting it working.
343
-
344
342
  === Development notes
345
343
  The swfupload.js and swfupload.queue.js have been modified according to this forum post:
346
344
  http://www.swfupload.org/forum/generaldiscussion/2053
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  desc 'Translate this gem'
26
26
  task :translate do
27
- file = File.join(File.dirname(__FILE__), 'locales', 'en.yml')
27
+ file = File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml')
28
28
  system("babelphish -o -y #{file}")
29
29
  end
30
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 3.0.0
@@ -10,7 +10,7 @@ module UploaderHelper
10
10
  # file_types: Allowed file types. Default is "*.*"
11
11
  # file_types_description: Description for file types. Default is "All Files"
12
12
  # file_upload_limit: Maximum number of files per upload. Default is 100
13
- # button_image_url: Url of button image to use for swf upload. Default is "/images/SWFUploadButton.png"
13
+ # button_image_url: Url of button image to use for swf upload. Default is "/images/swfupload/SWFUploadButton.png"
14
14
  # button_width: Width of the image button being used. Default is 61
15
15
  # button_height: Height of the button being used. Default is 22
16
16
  # transparent: Turns the swfupload transparent so you can use the html behind it for the upload button.
@@ -69,8 +69,8 @@ module UploaderHelper
69
69
  uploadify_options_json.gsub!('"oncomplete_replace_"', 'function(event, queueID, fileObj, response, data){ upload_completed_callback(response); return true; }')
70
70
 
71
71
  render :partial => 'uploads/uploadify', :locals => { :parent => parent,
72
- :options => options,
73
- :uploadify_options => uploadify_options_json}
72
+ :options => options,
73
+ :uploadify_options => uploadify_options_json}
74
74
  end
75
75
 
76
76
  def new_upload_path_with_session_information(upload_parent, format = 'js')
@@ -12,7 +12,7 @@
12
12
  <% end -%>
13
13
  <% end -%>
14
14
 
15
- <% content_for :head do -%>
15
+ <%= content_for :head do -%>
16
16
  <% if options[:transparent] -%>
17
17
  <style type="text/css">
18
18
  #<%=container_prefix%>swfupload_container .swfupload {position: absolute;z-index: 1;}
@@ -20,7 +20,7 @@
20
20
  <% end -%>
21
21
  <% end -%>
22
22
 
23
- <% content_for :head do -%>
23
+ <%= content_for :head do -%>
24
24
  <script type='text/javascript'>
25
25
  jQuery(document).ready(function() {
26
26
  jQuery('.show_degraded_container').click(function(){
@@ -41,7 +41,9 @@
41
41
  </script>
42
42
  <% end -%>
43
43
 
44
- <% content_for :head do -%>
44
+ <% session_key_name = Rails.application.config.session_options[:key]%>
45
+
46
+ <%= content_for :head do -%>
45
47
  <script type='text/javascript'>
46
48
  var <%=container_prefix%>swfu;
47
49
  window.onload = function () {
@@ -57,10 +59,11 @@
57
59
  file_upload_limit : <%= options[:file_upload_limit] || 100 %>,
58
60
  file_queue_limit : 0,
59
61
  post_params : {
60
- authenticity_token : '<%= u form_authenticity_token.inspect -%>',
62
+ "<%= key = Rails.application.config.session_options[:key] %>" : "<%= cookies[key] %>",
63
+ "<%= request_forgery_protection_token %>" : "<%= form_authenticity_token %>"
61
64
  },
62
65
  custom_settings : {
63
- <%= 'progressTarget : "' + container_prefix + 'swf_fs_upload_progress",' if display_upload_indicators -%>
66
+ <%= ('progressTarget : "' + container_prefix + 'swf_fs_upload_progress",').html_safe if display_upload_indicators -%>
64
67
  cancelButtonId : "<%=container_prefix%>swf_cancel_button"
65
68
  },
66
69
  debug: false,
@@ -74,7 +77,7 @@
74
77
  button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
75
78
  button_cursor: SWFUpload.CURSOR.HAND,
76
79
  <% else -%>
77
- button_image_url : '<%= options[:button_image_url] || "/images/SWFUploadButton.png" %>', // Relative to the SWF file
80
+ button_image_url : '<%= options[:button_image_url] || "/images/swfupload/SWFUploadButton.png" %>', // Relative to the SWF file
78
81
  <% end -%>
79
82
 
80
83
  // The event handler functions are defined in handlers.js
@@ -1,5 +1,5 @@
1
1
  <div id="<%=container_prefix%>degraded_container" class="degraded_container" style="display:none;">
2
- <% form_for :upload, :url => uploads_path(make_parent_params(parent)), :html => { :multipart => true } do |f| -%>
2
+ <%= form_for :upload, :url => uploads_path(make_parent_params(parent)), :html => { :multipart => true } do |f| -%>
3
3
  <p><%= f.file_field :local, :size => 25 %></p>
4
4
  <%= submit_tag t('uploader.upload_file') %>
5
5
  <% end %>
@@ -10,7 +10,7 @@
10
10
  <p>
11
11
  <% if options[:transparent] -%>
12
12
  <span style="position:absolute;" id="<%=container_prefix%>swf_button_holder"></span>
13
- <%= options[:transparent_html] || '<input id="' + container_prefix + 'upload_button" type="button" value="Select Files" />' -%>
13
+ <%= (options[:transparent_html] || '<input id="' + container_prefix + 'upload_button" type="button" value="Select Files" />').html_safe -%>
14
14
  <% else -%>
15
15
  <span id="<%=container_prefix%>swf_button_holder"></span>
16
16
  <% end -%>
@@ -7,7 +7,7 @@
7
7
  <% end -%>
8
8
 
9
9
  <div id="<%=options[:container_prefix]%>_upload">
10
- <% form_for :upload, :url => uploads_path(make_parent_params(parent)), :html => { :multipart => true, :id => "#{options[:container_prefix]}_form" } do |f| -%>
10
+ <%= form_for :upload, :url => uploads_path(make_parent_params(parent)), :html => { :multipart => true, :id => "#{options[:container_prefix]}_form" } do |f| -%>
11
11
  <p><%= f.file_field :local, :size => 25 %></p>
12
12
  <%= submit_tag t('uploader.upload_file') %>
13
13
  <% end %>
@@ -15,10 +15,10 @@
15
15
 
16
16
  <script type='text/javascript'>
17
17
  <% if options[:omit_initializer] -%>
18
- var <%=options[:container_prefix]%>_options = <%=uploadify_options%>;
18
+ var <%=options[:container_prefix]%>_options = <%=uploadify_options.html_safe%>;
19
19
  <% else -%>
20
20
  jQuery(document).ready(function() {
21
- jQuery('#<%=options[:container_prefix]%>_upload').uploadify(<%=uploadify_options%>);
21
+ jQuery('#<%=options[:container_prefix]%>_upload').uploadify(<%=uploadify_options.html_safe%>);
22
22
  });
23
23
  <% end -%>
24
24
  </script>
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
@@ -4,7 +4,7 @@ fa:
4
4
  cancel_all: "لغو تمام ارسالهای"
5
5
  file_delete_permission_denied: "شما اجازه حذف آن فایل را ندارید."
6
6
  file_deleted: "حذف فایل"
7
- file_upload_error: "خطا رخ داده است در حالی که آپلود فایل."
7
+ file_upload_error: "خطا آپلود فایل."
8
8
  javascript_not_enabled: "متأسفیم. SWFUpload نمی تواند باز شود. شما باید جاوا اسکریپت را فعال کنید برای لذت بردن از SWFUpload."
9
9
  manage_files: "مدیریت فایلها"
10
10
  manage_photos_files: "عکس مدیریت / فایلها"
@@ -16,6 +16,6 @@ fa:
16
16
  successful_upload: "با موفقیت ارسال فایل."
17
17
  swf_loading: "SWFUpload است در حال بارگذاری. لطفا صبر کنید یک لحظه..."
18
18
  swf_not_loading: "متأسفیم. SWFUpload نمی تواند باز شود. شما ممکن است نیاز به نصب یا ارتقاء فلش پلیر. دفعات مشاهده %{url} برای دریافت فلش پلیر."
19
- swf_taking_to_long: "SWFUpload است مصرف مدت طولانی برای بار کردن و یا بار ناموفق بوده است. لطفا اطمینان حاصل کنید که پلاگین فلش فعال باشد و این کار از نسخه ادوبی فلش پلیر نصب شود."
19
+ swf_taking_to_long: "SWFUpload است مصرف مدت طولانی برای بار کردن و یا بار ناموفق بوده است. لطفا اطمینان حاصل کنید که پلاگین فلش فعال باشد و کار از نسخه ادوبی فلش پلیر نصب شود."
20
20
  upload_file: "ارسال فایل"
21
21
  upload_files: "ارسال فایلها"
File without changes
File without changes
File without changes
@@ -4,7 +4,7 @@ hi:
4
4
  cancel_all: "सभी अपलोड रद्द करें"
5
5
  file_delete_permission_denied: "आपको लगता है कि फ़ाइल को नष्ट की अनुमति नहीं है."
6
6
  file_deleted: "नष्ट कर दिया फ़ाइल"
7
- file_upload_error: "समय एक त्रुटि हुई फाइल अपलोड."
7
+ file_upload_error: "एक त्रुटि हुई फाइल अपलोड."
8
8
  javascript_not_enabled: "हमें खेद है. SWFUpload लोड नहीं कर सकते. तुम होगा करने के लिए जावास्क्रिप्ट SWFUpload आनंद सक्षम होना चाहिए."
9
9
  manage_files: "प्रबंधित फ़ाइलें"
10
10
  manage_photos_files: "फाइलें / प्रबंधित तस्वीरें"
File without changes
File without changes
@@ -15,7 +15,7 @@ id:
15
15
  standard_file_upload_error: "Sebuah kesalahan terjadi ketika mengupload file: %{error}. Harap pastikan bahwa file tersebut valid. Periksa untuk memastikan file tersebut tidak kosong. Kemudian coba lagi."
16
16
  successful_upload: "Berhasil upload file."
17
17
  swf_loading: "SWFUpload sedang loading. Mohon tunggu sebentar ..."
18
- swf_not_loading: "Kami minta maaf. SWFUpload tidak dapat memuat. Anda mungkin perlu menginstal atau meng-upgrade Flash Player. Kunjungi %{url} untuk mendapatkan Flash Player."
18
+ swf_not_loading: "Kami minta maaf. SWFUpload tidak dapat memuat. Anda mungkin perlu menginstal Flash Player atau upgrade. Kunjungi %{url} untuk mendapatkan Flash Player."
19
19
  swf_taking_to_long: "SWFUpload memakan waktu lama untuk beban atau beban telah gagal. Pastikan bahwa Flash Plugin diaktifkan dan bahwa versi kerja Adobe Flash Player diinstal."
20
20
  upload_file: "Upload File"
21
21
  upload_files: "Upload File"
File without changes
File without changes
File without changes
@@ -15,7 +15,7 @@ ko:
15
15
  standard_file_upload_error: "파일을 업로드하는 동안 오류가 발생했습니다 : %{error}.을 제발 해당 파일이 유효한지 확인합니다. 파일이 비어 있지 않은지 확인하십시오. 그런 다음 다시 시도해보십시오."
16
16
  successful_upload: "성공적으로 파일을 업로드."
17
17
  swf_loading: "SWFUpload가 로딩됩니다. 잠시 만요 ..."
18
- swf_not_loading: "죄송합니다. SWFUpload는 로드할 수 없습니다. 당신은 설치 또는 Flash Player를 업그레이 드해야 할 수도 있습니다. 방문 %{url} Flash Player를 다운받을 수 있습니다."
19
- swf_taking_to_long: "SWFUpload로드하거나 실패했습니다 하중을 오랜 시간이 걸립니다. 제발 Flash 플러그인이 활성화되어 있는지 확인하고 Adobe Flash Player의 작업 버전이 설치되어 있어야합니다."
18
+ swf_not_loading: "죄송합니다. SWFUpload는 로드할 수 없습니다. 당신은 설치 또는 Flash Player를 업그레이 드해야 할 수도 있습니다. 방문 %{url} 플래시 플레이어를보십시오."
19
+ swf_taking_to_long: "SWFUpload를로드하거나 실패했습니다 하중을 오랜 시간이 걸립니다. 제발 Flash 플러그인이 활성화되어 있는지 확인하고 Adobe Flash Player의 작업 버전이 설치되어 있어야합니다."
20
20
  upload_file: "파일 업로드"
21
21
  upload_files: "파일 업로드"
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
@@ -16,6 +16,6 @@ th:
16
16
  successful_upload: อัพโหลดไฟล์เรียบร้อยแล้ว
17
17
  swf_loading: "SWFUpload กำลังโหลด โปรดรอสักครู่ ..."
18
18
  swf_not_loading: "ขออภัย SWFUpload ไม่สามารถโหลด คุณอาจต้องติดตั้งหรืออัพเกรด Flash Player Visit %{url} เพื่อรับ Flash Player"
19
- swf_taking_to_long: "SWFUpload เป็นเวลานานในการโหลดหรือโหลดล้มเหลว โปรดให้แน่ใจว่ามีการเปิดใช้ปลั๊กอิน Flash และรุ่นที่ทำงานของ Adobe Flash Player ติดตั้ง"
19
+ swf_taking_to_long: "SWFUpload เป็นเวลานานในการโหลดหรือโหลดล้มเหลว โปรดตรวจสอบว่า Flash ปลั๊กอินที่เปิดใช้งานและรุ่นที่ทำงานของ Adobe Flash Player ติดตั้ง"
20
20
  upload_file: อัพโหลดไฟล์
21
21
  upload_files: อัพโหลดไฟล์
File without changes
File without changes
File without changes
@@ -8,13 +8,13 @@ vi:
8
8
  javascript_not_enabled: "Chúng tôi xin lỗi. SWFUpload không thể tải. Bạn phải có bật Javascript để tận hưởng SWFUpload."
9
9
  manage_files: "Quản lý tập tin"
10
10
  manage_photos_files: "Quản lý hình ảnh / tập tin"
11
- missing_parent_id_error: "Xin vui lòng xác định một đối tượng cha mẹ"
11
+ missing_parent_id_error: "Xin vui lòng chỉ định một đối tượng cha mẹ"
12
12
  permission_denied: "Bạn không có quyền để hoàn tất hành động này."
13
13
  show_degraded_container: "Sử dụng tiêu chuẩn tải lên"
14
14
  show_swfupload_container: "Sử dụng nhiều tập tin tải lên. (Cần phải có Flash)"
15
15
  standard_file_upload_error: "Một lỗi xảy ra trong khi tải lên tập tin: %{error}. Xin vui lòng đảm bảo rằng tập tin là hợp lệ. Kiểm tra để đảm bảo rằng tập tin là không có sản phẩm nào. Sau đó thử lại."
16
16
  successful_upload: "Thành công upload."
17
- swf_loading: "SWFUpload được tải. Xin vui lòng chờ trong giây lát ..."
17
+ swf_loading: "SWFUpload đang tải. Xin vui lòng chờ trong giây lát ..."
18
18
  swf_not_loading: "Chúng tôi xin lỗi. SWFUpload không thể tải. Bạn có thể cần phải cài đặt hoặc nâng cấp Flash Player. Khám phá %{url} để có được những cầu thủ Flash."
19
19
  swf_taking_to_long: "SWFUpload là mất nhiều thời gian để tải hoặc tải không thanh công. Hãy đảm bảo rằng các Plugin Flash được kích hoạt và rằng một phiên bản làm việc của Adobe Flash Player được cài đặt."
20
20
  upload_file: "Upload File"
File without changes
File without changes
File without changes
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ resources :uploads,
3
+ :controller => 'uploader/uploads' do
4
+ collection do
5
+ post :multiupload
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ namespace :uploader do
2
+
3
+ desc 'Send all uploads to S3. (Will only send uploads from a model named Upload)'
4
+ task :upload_to_s3 => :environment do
5
+ uploads = Upload.pending_s3_migrations
6
+ uploads.each do |upload|
7
+ upload.remote = upload.local
8
+ upload.save!
9
+ end
10
+ end
11
+
12
+ desc "Sync required files from uploader."
13
+ task :sync => :environment do
14
+ path = File.join(File.dirname(__FILE__), *%w[.. ..])
15
+ daemons_path = "#{::Rails.root.to_s}/lib/daemons"
16
+ system "rsync -ruv #{path}/public ."
17
+ system "rsync -ruv #{path}/db ."
18
+ FileUtils.mkdir_p(daemons_path) unless File.directory?(daemons_path)
19
+ FileUtils.cp_r("#{path}/lib/daemons/amazonaws.rb", "#{::Rails.root.to_s}/lib/daemons/amazonaws.rb")
20
+ end
21
+
22
+ end
@@ -0,0 +1,65 @@
1
+ # Configures the uploader gem
2
+ #
3
+ # For example:
4
+ # Uploader.configure do |config|
5
+ # config.enable_s3 = true
6
+ # config.s3_no_wait = true
7
+ # config.keep_local_file = true
8
+ # config.has_attached_file_options = {
9
+ # :url => "/system/:attachment/:id_partition/:style/:basename.:extension",
10
+ # :path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
11
+ # :styles => { :icon => "30x30!",
12
+ # :thumb => "100>",
13
+ # :small => "150>",
14
+ # :medium => "300>",
15
+ # :large => "660>" },
16
+ # :default_url => "/images/default.jpg",
17
+ # :storage => :s3,
18
+ # :s3_credentials => AMAZON_S3_CREDENTIALS,
19
+ # :bucket => "assets.example.com",
20
+ # :s3_host_alias => "assets.example.com",
21
+ # :convert_options => {
22
+ # :all => '-quality 80'
23
+ # }
24
+ # }
25
+ # end
26
+ module Uploader
27
+
28
+ def self.configuration
29
+ # In case the user doesn't setup a configure block we can always return default settings:
30
+ @configuration ||= Configuration.new
31
+ end
32
+
33
+ def self.configure
34
+ self.configuration ||= Configuration.new
35
+ yield(configuration)
36
+ end
37
+
38
+ class Configuration
39
+ attr_accessor :has_attached_file_options
40
+ attr_accessor :enable_s3
41
+ attr_accessor :s3_no_wait
42
+ attr_accessor :keep_local_file
43
+ attr_accessor :disable_halt_nonimage_processing
44
+
45
+ def initialize
46
+ @enable_s3 = false
47
+ @s3_no_wait = false
48
+ @keep_local_file = true
49
+ @disable_halt_nonimage_processing = false
50
+ @has_attached_file_options = {
51
+ :url => "/system/:attachment/:id_partition/:style/:basename.:extension",
52
+ :path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
53
+ :styles => { :icon => "30x30!",
54
+ :thumb => "100>",
55
+ :small => "150>",
56
+ :medium => "300>",
57
+ :large => "660>" },
58
+ :default_url => "/images/default.jpg",
59
+ :convert_options => {
60
+ :all => '-quality 80'
61
+ }
62
+ }
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,19 @@
1
+ require 'uploader'
2
+ require 'rails'
3
+
4
+ module Uploader
5
+ class Engine < ::Rails::Engine
6
+
7
+ initializer "uploader.add_middleware" do |app|
8
+ app.middleware.insert_before(ActionDispatch::Session::CookieStore,
9
+ Uploader::FlashSessionCookieMiddleware,
10
+ Rails.application.config.session_options[:key])
11
+ end
12
+
13
+ initializer 'uploader.uploader_helper' do |app|
14
+ ActiveSupport.on_load(:action_view) do
15
+ include UploaderHelper
16
+ end
17
+ end
18
+ end
19
+ end