uploadbox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/_image_uploader.coffee +44 -0
  6. data/app/assets/javascripts/file_uploader.coffee +4 -0
  7. data/app/assets/javascripts/jquery.fileupload.js +1315 -0
  8. data/app/assets/javascripts/jquery.iframe-transport.js +205 -0
  9. data/app/assets/javascripts/jquery.ui.widget.js +521 -0
  10. data/app/assets/stylesheets/bootstrap/_buttons.css +93 -0
  11. data/app/assets/stylesheets/bootstrap/_progress.css +207 -0
  12. data/app/assets/stylesheets/file_uploader.sass +134 -0
  13. data/app/controllers/file_uploader/application_controller.rb +4 -0
  14. data/app/controllers/file_uploader/images_controller.rb +20 -0
  15. data/app/helpers/file_uploader/application_helper.rb +4 -0
  16. data/app/models/concerns/image_uploadable.rb +11 -0
  17. data/app/models/concerns/uploadable.rb +9 -0
  18. data/app/uploaders/concerns/image_processing.rb +33 -0
  19. data/app/views/file_uploader/images/_uploader.html.slim +16 -0
  20. data/app/views/file_uploader/images/create.json.jbuilder +6 -0
  21. data/app/views/layouts/file_uploader/application.html.erb +14 -0
  22. data/config/routes.rb +3 -0
  23. data/lib/file_uploader/engine.rb +23 -0
  24. data/lib/file_uploader/version.rb +3 -0
  25. data/lib/file_uploader.rb +4 -0
  26. data/lib/generators/file_uploader/image/USAGE +8 -0
  27. data/lib/generators/file_uploader/image/image_generator.rb +34 -0
  28. data/lib/generators/file_uploader/image/templates/initializers/carrierwave.rb +22 -0
  29. data/lib/generators/file_uploader/image/templates/migrate/create_images.rb +10 -0
  30. data/lib/generators/file_uploader/image/templates/models/image.rb +3 -0
  31. data/lib/generators/file_uploader/image/templates/uploaders/image_uploader.rb +3 -0
  32. data/lib/tasks/file_uploader_tasks.rake +4 -0
  33. data/test/dummy/README.rdoc +28 -0
  34. data/test/dummy/Rakefile +6 -0
  35. data/test/dummy/app/assets/javascripts/application.coffee +3 -0
  36. data/test/dummy/app/assets/stylesheets/application.sass +2 -0
  37. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  38. data/test/dummy/app/controllers/application_controller.rb +5 -0
  39. data/test/dummy/app/controllers/posts_controller.rb +61 -0
  40. data/test/dummy/app/helpers/application_helper.rb +2 -0
  41. data/test/dummy/app/helpers/home_helper.rb +2 -0
  42. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  43. data/test/dummy/app/models/post.rb +3 -0
  44. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  45. data/test/dummy/app/views/posts/_form.slim +26 -0
  46. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  47. data/test/dummy/app/views/posts/index.html.erb +32 -0
  48. data/test/dummy/app/views/posts/new.html.erb +5 -0
  49. data/test/dummy/app/views/posts/show.html.erb +19 -0
  50. data/test/dummy/bin/bundle +3 -0
  51. data/test/dummy/bin/rails +4 -0
  52. data/test/dummy/bin/rake +4 -0
  53. data/test/dummy/config/application.rb +23 -0
  54. data/test/dummy/config/boot.rb +5 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +11 -0
  58. data/test/dummy/config/environments/production.rb +80 -0
  59. data/test/dummy/config/environments/test.rb +36 -0
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/test/dummy/config/initializers/inflections.rb +16 -0
  63. data/test/dummy/config/initializers/mime_types.rb +5 -0
  64. data/test/dummy/config/initializers/secret_token.rb +12 -0
  65. data/test/dummy/config/initializers/session_store.rb +3 -0
  66. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  67. data/test/dummy/config/locales/en.yml +23 -0
  68. data/test/dummy/config/routes.rb +6 -0
  69. data/test/dummy/config.ru +4 -0
  70. data/test/dummy/db/development.sqlite3 +0 -0
  71. data/test/dummy/db/migrate/20130624130249_create_posts.rb +10 -0
  72. data/test/dummy/db/schema.rb +33 -0
  73. data/test/dummy/db/test.sqlite3 +0 -0
  74. data/test/dummy/log/development.log +20837 -0
  75. data/test/dummy/public/404.html +58 -0
  76. data/test/dummy/public/422.html +58 -0
  77. data/test/dummy/public/500.html +57 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/dummy/public/uploads/image/file/10/regular_tree1.jpg +0 -0
  80. data/test/dummy/public/uploads/image/file/10/tree1.jpg +0 -0
  81. data/test/dummy/public/uploads/image/file/11/regular_sports2.jpg +0 -0
  82. data/test/dummy/public/uploads/image/file/11/sports2.jpg +0 -0
  83. data/test/dummy/public/uploads/image/file/12/city1.jpg +0 -0
  84. data/test/dummy/public/uploads/image/file/12/regular_city1.jpg +0 -0
  85. data/test/dummy/public/uploads/image/file/13/regular_tree1.jpg +0 -0
  86. data/test/dummy/public/uploads/image/file/13/tree1.jpg +0 -0
  87. data/test/dummy/public/uploads/image/file/14/regular_sports1.jpg +0 -0
  88. data/test/dummy/public/uploads/image/file/14/sports1.jpg +0 -0
  89. data/test/dummy/public/uploads/image/file/15/regular_sports1.jpg +0 -0
  90. data/test/dummy/public/uploads/image/file/15/sports1.jpg +0 -0
  91. data/test/dummy/public/uploads/image/file/16/regular_sports1.jpg +0 -0
  92. data/test/dummy/public/uploads/image/file/16/sports1.jpg +0 -0
  93. data/test/dummy/public/uploads/image/file/17/regular_sports1.jpg +0 -0
  94. data/test/dummy/public/uploads/image/file/17/sports1.jpg +0 -0
  95. data/test/dummy/public/uploads/image/file/18/regular_sports3.jpg +0 -0
  96. data/test/dummy/public/uploads/image/file/18/sports3.jpg +0 -0
  97. data/test/dummy/public/uploads/image/file/19/regular_sports1.jpg +0 -0
  98. data/test/dummy/public/uploads/image/file/19/sports1.jpg +0 -0
  99. data/test/dummy/public/uploads/image/file/2/city1.jpg +0 -0
  100. data/test/dummy/public/uploads/image/file/2/regular_city1.jpg +0 -0
  101. data/test/dummy/public/uploads/image/file/20/regular_sports1.jpg +0 -0
  102. data/test/dummy/public/uploads/image/file/20/sports1.jpg +0 -0
  103. data/test/dummy/public/uploads/image/file/21/regular_sports1.jpg +0 -0
  104. data/test/dummy/public/uploads/image/file/21/sports1.jpg +0 -0
  105. data/test/dummy/public/uploads/image/file/22/regular_sports1.jpg +0 -0
  106. data/test/dummy/public/uploads/image/file/22/sports1.jpg +0 -0
  107. data/test/dummy/public/uploads/image/file/23/regular_sports2.jpg +0 -0
  108. data/test/dummy/public/uploads/image/file/23/sports2.jpg +0 -0
  109. data/test/dummy/public/uploads/image/file/27/monument1.jpg +0 -0
  110. data/test/dummy/public/uploads/image/file/27/regular_monument1.jpg +0 -0
  111. data/test/dummy/public/uploads/image/file/28/regular_sports3.jpg +0 -0
  112. data/test/dummy/public/uploads/image/file/28/sports3.jpg +0 -0
  113. data/test/dummy/public/uploads/image/file/3/city1.jpg +0 -0
  114. data/test/dummy/public/uploads/image/file/3/regular_city1.jpg +0 -0
  115. data/test/dummy/public/uploads/image/file/33/regular_tree1.jpg +0 -0
  116. data/test/dummy/public/uploads/image/file/33/tree1.jpg +0 -0
  117. data/test/dummy/public/uploads/image/file/34/city1.jpg +0 -0
  118. data/test/dummy/public/uploads/image/file/34/regular_city1.jpg +0 -0
  119. data/test/dummy/public/uploads/image/file/37/regular_sports3.jpg +0 -0
  120. data/test/dummy/public/uploads/image/file/37/sports3.jpg +0 -0
  121. data/test/dummy/public/uploads/image/file/38/regular_sports1.jpg +0 -0
  122. data/test/dummy/public/uploads/image/file/38/sports1.jpg +0 -0
  123. data/test/dummy/public/uploads/image/file/4/food1.jpg +0 -0
  124. data/test/dummy/public/uploads/image/file/4/regular_food1.jpg +0 -0
  125. data/test/dummy/public/uploads/image/file/40/regular_tree1.jpg +0 -0
  126. data/test/dummy/public/uploads/image/file/40/tree1.jpg +0 -0
  127. data/test/dummy/public/uploads/image/file/5/regular_sports1.jpg +0 -0
  128. data/test/dummy/public/uploads/image/file/5/sports1.jpg +0 -0
  129. data/test/dummy/public/uploads/image/file/50/city1.jpg +0 -0
  130. data/test/dummy/public/uploads/image/file/50/regular_city1.jpg +0 -0
  131. data/test/dummy/public/uploads/image/file/51/regular_sports1.jpg +0 -0
  132. data/test/dummy/public/uploads/image/file/51/sports1.jpg +0 -0
  133. data/test/dummy/public/uploads/image/file/56/city1.jpg +0 -0
  134. data/test/dummy/public/uploads/image/file/56/regular_city1.jpg +0 -0
  135. data/test/dummy/public/uploads/image/file/57/monument1.jpg +0 -0
  136. data/test/dummy/public/uploads/image/file/57/regular_monument1.jpg +0 -0
  137. data/test/dummy/public/uploads/image/file/58/regular_sports1.jpg +0 -0
  138. data/test/dummy/public/uploads/image/file/58/sports1.jpg +0 -0
  139. data/test/dummy/public/uploads/image/file/6/city1.jpg +0 -0
  140. data/test/dummy/public/uploads/image/file/6/regular_city1.jpg +0 -0
  141. data/test/dummy/public/uploads/image/file/60/regular_sports1.jpg +0 -0
  142. data/test/dummy/public/uploads/image/file/60/sports1.jpg +0 -0
  143. data/test/dummy/public/uploads/image/file/61/city1.jpg +0 -0
  144. data/test/dummy/public/uploads/image/file/61/regular_city1.jpg +0 -0
  145. data/test/dummy/public/uploads/image/file/62/regular_sports2.jpg +0 -0
  146. data/test/dummy/public/uploads/image/file/62/sports2.jpg +0 -0
  147. data/test/dummy/public/uploads/image/file/63/food1.jpg +0 -0
  148. data/test/dummy/public/uploads/image/file/63/regular_food1.jpg +0 -0
  149. data/test/dummy/public/uploads/image/file/64/food1.jpg +0 -0
  150. data/test/dummy/public/uploads/image/file/64/regular_food1.jpg +0 -0
  151. data/test/dummy/public/uploads/image/file/65/city1.jpg +0 -0
  152. data/test/dummy/public/uploads/image/file/65/regular_city1.jpg +0 -0
  153. data/test/dummy/public/uploads/image/file/66/regular_sports3.jpg +0 -0
  154. data/test/dummy/public/uploads/image/file/66/sports3.jpg +0 -0
  155. data/test/dummy/public/uploads/image/file/67/regular_sports1.jpg +0 -0
  156. data/test/dummy/public/uploads/image/file/67/sports1.jpg +0 -0
  157. data/test/dummy/public/uploads/image/file/68/regular_sports1.jpg +0 -0
  158. data/test/dummy/public/uploads/image/file/68/sports1.jpg +0 -0
  159. data/test/dummy/public/uploads/image/file/69/regular_sports1.jpg +0 -0
  160. data/test/dummy/public/uploads/image/file/69/sports1.jpg +0 -0
  161. data/test/dummy/public/uploads/image/file/7/regular_sports3.jpg +0 -0
  162. data/test/dummy/public/uploads/image/file/7/sports3.jpg +0 -0
  163. data/test/dummy/public/uploads/image/file/71/regular_sports2.jpg +0 -0
  164. data/test/dummy/public/uploads/image/file/71/sports2.jpg +0 -0
  165. data/test/dummy/public/uploads/image/file/73/regular_sports1.jpg +0 -0
  166. data/test/dummy/public/uploads/image/file/73/sports1.jpg +0 -0
  167. data/test/dummy/public/uploads/image/file/75/regular_sports2.jpg +0 -0
  168. data/test/dummy/public/uploads/image/file/75/sports2.jpg +0 -0
  169. data/test/dummy/public/uploads/image/file/76/city1.jpg +0 -0
  170. data/test/dummy/public/uploads/image/file/76/regular_city1.jpg +0 -0
  171. data/test/dummy/public/uploads/image/file/77/regular_sports1.jpg +0 -0
  172. data/test/dummy/public/uploads/image/file/77/sports1.jpg +0 -0
  173. data/test/dummy/public/uploads/image/file/78/regular_tree1.jpg +0 -0
  174. data/test/dummy/public/uploads/image/file/78/tree1.jpg +0 -0
  175. data/test/dummy/public/uploads/image/file/79/regular_sports3.jpg +0 -0
  176. data/test/dummy/public/uploads/image/file/79/sports3.jpg +0 -0
  177. data/test/dummy/public/uploads/image/file/8/regular_sports1.jpg +0 -0
  178. data/test/dummy/public/uploads/image/file/8/sports1.jpg +0 -0
  179. data/test/dummy/public/uploads/image/file/80/regular_tree1.jpg +0 -0
  180. data/test/dummy/public/uploads/image/file/80/tree1.jpg +0 -0
  181. data/test/dummy/public/uploads/image/file/81/food1.jpg +0 -0
  182. data/test/dummy/public/uploads/image/file/81/regular_food1.jpg +0 -0
  183. data/test/dummy/public/uploads/image/file/84/regular_tree1.jpg +0 -0
  184. data/test/dummy/public/uploads/image/file/84/tree1.jpg +0 -0
  185. data/test/dummy/public/uploads/image/file/9/monument1.jpg +0 -0
  186. data/test/dummy/public/uploads/image/file/9/regular_monument1.jpg +0 -0
  187. data/test/dummy/public/uploads/tmp/20130627-0910-4782-4339/regular_sports2.jpg +0 -0
  188. data/test/dummy/public/uploads/tmp/20130627-0910-4782-4339/sports2.jpg +0 -0
  189. data/test/dummy/tmp/cache/assets/development/sass/5b407eb4aa13436bd984a25ae192ac2652db5759/_buttons.cssc +0 -0
  190. data/test/dummy/tmp/cache/assets/development/sass/5b407eb4aa13436bd984a25ae192ac2652db5759/_progress.cssc +0 -0
  191. data/test/dummy/tmp/cache/assets/development/sass/7662e69738309f2449b5f34a623416e02bd31561/_buttons.cssc +0 -0
  192. data/test/dummy/tmp/cache/assets/development/sass/7662e69738309f2449b5f34a623416e02bd31561/_progress.cssc +0 -0
  193. data/test/dummy/tmp/cache/assets/development/sass/8160dfcd3114403b4930d081794c16af3ebe3ba6/file_uploader.sassc +0 -0
  194. data/test/dummy/tmp/cache/assets/development/sass/b3df06ca649a689a4fd2f92938f644fb80a0b76c/_bootstrap_btn.cssc +0 -0
  195. data/test/dummy/tmp/cache/assets/development/sass/b3df06ca649a689a4fd2f92938f644fb80a0b76c/_fileupload.sassc +0 -0
  196. data/test/dummy/tmp/cache/assets/development/sass/b3df06ca649a689a4fd2f92938f644fb80a0b76c/application.sassc +0 -0
  197. data/test/dummy/tmp/cache/assets/development/sass/b3df06ca649a689a4fd2f92938f644fb80a0b76c/bootstrap.cssc +0 -0
  198. data/test/dummy/tmp/cache/assets/development/sass/b3df06ca649a689a4fd2f92938f644fb80a0b76c/scaffold.cssc +0 -0
  199. data/test/dummy/tmp/cache/assets/development/sprockets/036b77eb9437a0b942e844f0664f2f4d +0 -0
  200. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  201. data/test/dummy/tmp/cache/assets/development/sprockets/17aca7a5440d34b72f7519ffa1ab8379 +0 -0
  202. data/test/dummy/tmp/cache/assets/development/sprockets/1a2ba42bd8d58781c7bf0e3d7a33c3c8 +0 -0
  203. data/test/dummy/tmp/cache/assets/development/sprockets/1a6ee5f7be55d7f22c31aef2af1aaad7 +0 -0
  204. data/test/dummy/tmp/cache/assets/development/sprockets/1c9faaf28d05409b88ad3113374d613c +0 -0
  205. data/test/dummy/tmp/cache/assets/development/sprockets/1e8f75a6b5b33970fb8e397347caa0a1 +0 -0
  206. data/test/dummy/tmp/cache/assets/development/sprockets/21252e0c63eb196e8181b7754194d61a +0 -0
  207. data/test/dummy/tmp/cache/assets/development/sprockets/22a20eb270b5f0f317e13738bcb73925 +0 -0
  208. data/test/dummy/tmp/cache/assets/development/sprockets/24204f742af588c8166d3160b500d20f +0 -0
  209. data/test/dummy/tmp/cache/assets/development/sprockets/2822de3b22c28bd5e718c9bf500457b2 +0 -0
  210. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  211. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  212. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  213. data/test/dummy/tmp/cache/assets/development/sprockets/40fc2f3d2a468a00e463f1d313cb1683 +0 -0
  214. data/test/dummy/tmp/cache/assets/development/sprockets/416150dc3ac35079c94273cc46e90aa6 +0 -0
  215. data/test/dummy/tmp/cache/assets/development/sprockets/4726dfba577c185e9355be4a832efb8e +0 -0
  216. data/test/dummy/tmp/cache/assets/development/sprockets/47b830f344f953bcd6328a49ab616646 +0 -0
  217. data/test/dummy/tmp/cache/assets/development/sprockets/4968b24dd091b0fd0e209d67b392be52 +0 -0
  218. data/test/dummy/tmp/cache/assets/development/sprockets/4de2e83f99a4262aa0c8cc6035da959a +0 -0
  219. data/test/dummy/tmp/cache/assets/development/sprockets/4fc9258d221c999ba0aa1d80dbf04e5f +0 -0
  220. data/test/dummy/tmp/cache/assets/development/sprockets/50afae431e200795f9adc76e38e6130d +0 -0
  221. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  222. data/test/dummy/tmp/cache/assets/development/sprockets/5384ad85f52d3272dbc64d46ef3876a4 +0 -0
  223. data/test/dummy/tmp/cache/assets/development/sprockets/54016e9e60301e29500bab9b9815de1e +0 -0
  224. data/test/dummy/tmp/cache/assets/development/sprockets/5608eba5a4ac26d717d876734486c3f5 +0 -0
  225. data/test/dummy/tmp/cache/assets/development/sprockets/5b6cfeddfda27d92843b8dac8d034ed3 +0 -0
  226. data/test/dummy/tmp/cache/assets/development/sprockets/60f1e97d7008b3ed41f72855a4228bb9 +0 -0
  227. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  228. data/test/dummy/tmp/cache/assets/development/sprockets/734b52a3ac29f5ddc9f0cb98046c2315 +0 -0
  229. data/test/dummy/tmp/cache/assets/development/sprockets/80edcfeb723573fc6499580e5771bb17 +0 -0
  230. data/test/dummy/tmp/cache/assets/development/sprockets/851e2975dd2977ad620f690b923f3253 +0 -0
  231. data/test/dummy/tmp/cache/assets/development/sprockets/87cf3e4938b1fefe951ae62b201d8874 +0 -0
  232. data/test/dummy/tmp/cache/assets/development/sprockets/9199b64aec237a59d258f4f149262be1 +0 -0
  233. data/test/dummy/tmp/cache/assets/development/sprockets/9742c38f2d32a6142740215f517a73f5 +0 -0
  234. data/test/dummy/tmp/cache/assets/development/sprockets/9bccb521761b095f6c0255ab7fc9b3fb +0 -0
  235. data/test/dummy/tmp/cache/assets/development/sprockets/a4b8f7dbc861343715de9ec929b0e4ca +0 -0
  236. data/test/dummy/tmp/cache/assets/development/sprockets/a6ec7a5f259e52c790fb0f84b69a696e +0 -0
  237. data/test/dummy/tmp/cache/assets/development/sprockets/a7ab4e7b3ec8c08a267319920b433fda +0 -0
  238. data/test/dummy/tmp/cache/assets/development/sprockets/a88d9c609d05fcc4670c8742b41816c0 +0 -0
  239. data/test/dummy/tmp/cache/assets/development/sprockets/a9eb7874ccfec01c26d50fdc46d50639 +0 -0
  240. data/test/dummy/tmp/cache/assets/development/sprockets/a9f028f7a492b5907ed80268be8f50f4 +0 -0
  241. data/test/dummy/tmp/cache/assets/development/sprockets/abbcfa48059290465d8e74aa4fd0d4de +0 -0
  242. data/test/dummy/tmp/cache/assets/development/sprockets/add025ab0eb13a6d4180af43d5df39df +0 -0
  243. data/test/dummy/tmp/cache/assets/development/sprockets/b878faf942403e313a5b103e5d80488e +0 -0
  244. data/test/dummy/tmp/cache/assets/development/sprockets/bd0405b0fbaa0e8a1924bd19f9d52570 +0 -0
  245. data/test/dummy/tmp/cache/assets/development/sprockets/c2a831ed79df487d6485a5c9c52766c2 +0 -0
  246. data/test/dummy/tmp/cache/assets/development/sprockets/c85016e7bbd4f3adbb7635d01f85d39b +0 -0
  247. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  248. data/test/dummy/tmp/cache/assets/development/sprockets/d066c004d1fd26ae76a61303a7a18145 +0 -0
  249. data/test/dummy/tmp/cache/assets/development/sprockets/d080d25d00bbfe7b19138cf7a648dd8c +0 -0
  250. data/test/dummy/tmp/cache/assets/development/sprockets/d247dc85ce71f977c809c8b94d0223ed +0 -0
  251. data/test/dummy/tmp/cache/assets/development/sprockets/d2a1c642980b0a48bd71e7021eea73a1 +0 -0
  252. data/test/dummy/tmp/cache/assets/development/sprockets/d4c6a4b4d2ce87da7c22742887071603 +0 -0
  253. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  254. data/test/dummy/tmp/cache/assets/development/sprockets/d795fd4f9a32e134a5dd37f973a17176 +0 -0
  255. data/test/dummy/tmp/cache/assets/development/sprockets/d87810c66e05721ba749c5901c1af296 +0 -0
  256. data/test/dummy/tmp/cache/assets/development/sprockets/ebe08f689f659c024f467b77f32a1c49 +0 -0
  257. data/test/dummy/tmp/cache/assets/development/sprockets/edbef6e0d0a4742346cf479f2c522eb0 +0 -0
  258. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  259. data/test/file_uploader_test.rb +7 -0
  260. data/test/integration/navigation_test.rb +10 -0
  261. data/test/test_helper.rb +15 -0
  262. metadata +717 -0
@@ -0,0 +1,207 @@
1
+ @-webkit-keyframes progress-bar-stripes {
2
+ from {
3
+ background-position: 40px 0;
4
+ }
5
+ to {
6
+ background-position: 0 0;
7
+ }
8
+ }
9
+
10
+ @-moz-keyframes progress-bar-stripes {
11
+ from {
12
+ background-position: 40px 0;
13
+ }
14
+ to {
15
+ background-position: 0 0;
16
+ }
17
+ }
18
+
19
+ @-ms-keyframes progress-bar-stripes {
20
+ from {
21
+ background-position: 40px 0;
22
+ }
23
+ to {
24
+ background-position: 0 0;
25
+ }
26
+ }
27
+
28
+ @-o-keyframes progress-bar-stripes {
29
+ from {
30
+ background-position: 0 0;
31
+ }
32
+ to {
33
+ background-position: 40px 0;
34
+ }
35
+ }
36
+
37
+ @keyframes progress-bar-stripes {
38
+ from {
39
+ background-position: 40px 0;
40
+ }
41
+ to {
42
+ background-position: 0 0;
43
+ }
44
+ }
45
+
46
+ .progress {
47
+ height: 20px;
48
+ margin-bottom: 20px;
49
+ overflow: hidden;
50
+ background-color: #f7f7f7;
51
+ background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
52
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
53
+ background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
54
+ background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
55
+ background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9);
56
+ background-repeat: repeat-x;
57
+ -webkit-border-radius: 4px;
58
+ -moz-border-radius: 4px;
59
+ border-radius: 4px;
60
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);
61
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
62
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
63
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
64
+ }
65
+
66
+ .progress .bar {
67
+ float: left;
68
+ width: 0;
69
+ height: 100%;
70
+ font-size: 12px;
71
+ color: #ffffff;
72
+ text-align: center;
73
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
74
+ background-color: #0e90d2;
75
+ background-image: -moz-linear-gradient(top, #149bdf, #0480be);
76
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));
77
+ background-image: -webkit-linear-gradient(top, #149bdf, #0480be);
78
+ background-image: -o-linear-gradient(top, #149bdf, #0480be);
79
+ background-image: linear-gradient(to bottom, #149bdf, #0480be);
80
+ background-repeat: repeat-x;
81
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);
82
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
83
+ -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
84
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
85
+ -webkit-box-sizing: border-box;
86
+ -moz-box-sizing: border-box;
87
+ box-sizing: border-box;
88
+ -webkit-transition: width 0.6s ease;
89
+ -moz-transition: width 0.6s ease;
90
+ -o-transition: width 0.6s ease;
91
+ transition: width 0.6s ease;
92
+ }
93
+
94
+ .progress .bar + .bar {
95
+ -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
96
+ -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
97
+ box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
98
+ }
99
+
100
+ .progress-striped .bar {
101
+ background-color: #149bdf;
102
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
103
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
104
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
105
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
106
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
107
+ -webkit-background-size: 40px 40px;
108
+ -moz-background-size: 40px 40px;
109
+ -o-background-size: 40px 40px;
110
+ background-size: 40px 40px;
111
+ }
112
+
113
+ .progress.active .bar {
114
+ -webkit-animation: progress-bar-stripes 2s linear infinite;
115
+ -moz-animation: progress-bar-stripes 2s linear infinite;
116
+ -ms-animation: progress-bar-stripes 2s linear infinite;
117
+ -o-animation: progress-bar-stripes 2s linear infinite;
118
+ animation: progress-bar-stripes 2s linear infinite;
119
+ }
120
+
121
+ .progress-danger .bar,
122
+ .progress .bar-danger {
123
+ background-color: #dd514c;
124
+ background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
125
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));
126
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
127
+ background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
128
+ background-image: linear-gradient(to bottom, #ee5f5b, #c43c35);
129
+ background-repeat: repeat-x;
130
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0);
131
+ }
132
+
133
+ .progress-danger.progress-striped .bar,
134
+ .progress-striped .bar-danger {
135
+ background-color: #ee5f5b;
136
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
137
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
138
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
139
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
140
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
141
+ }
142
+
143
+ .progress-success .bar,
144
+ .progress .bar-success {
145
+ background-color: #5eb95e;
146
+ background-image: -moz-linear-gradient(top, #62c462, #57a957);
147
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));
148
+ background-image: -webkit-linear-gradient(top, #62c462, #57a957);
149
+ background-image: -o-linear-gradient(top, #62c462, #57a957);
150
+ background-image: linear-gradient(to bottom, #62c462, #57a957);
151
+ background-repeat: repeat-x;
152
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0);
153
+ }
154
+
155
+ .progress-success.progress-striped .bar,
156
+ .progress-striped .bar-success {
157
+ background-color: #62c462;
158
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
159
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
160
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
161
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
162
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
163
+ }
164
+
165
+ .progress-info .bar,
166
+ .progress .bar-info {
167
+ background-color: #4bb1cf;
168
+ background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);
169
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));
170
+ background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);
171
+ background-image: -o-linear-gradient(top, #5bc0de, #339bb9);
172
+ background-image: linear-gradient(to bottom, #5bc0de, #339bb9);
173
+ background-repeat: repeat-x;
174
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0);
175
+ }
176
+
177
+ .progress-info.progress-striped .bar,
178
+ .progress-striped .bar-info {
179
+ background-color: #5bc0de;
180
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
181
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
182
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
183
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
184
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
185
+ }
186
+
187
+ .progress-warning .bar,
188
+ .progress .bar-warning {
189
+ background-color: #faa732;
190
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
191
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
192
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
193
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
194
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
195
+ background-repeat: repeat-x;
196
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
197
+ }
198
+
199
+ .progress-warning.progress-striped .bar,
200
+ .progress-striped .bar-warning {
201
+ background-color: #fbb450;
202
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
203
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
204
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
205
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
206
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
207
+ }
@@ -0,0 +1,134 @@
1
+ @import bootstrap/progress
2
+
3
+ .btn
4
+ background-color: #f7f7f7
5
+ padding: 10px
6
+ text-align: center
7
+ text-decoration: none
8
+
9
+ .clearfix
10
+ *zoom: 1
11
+ &:before
12
+ display: table
13
+ content: ""
14
+ line-height: 0
15
+ &:after
16
+ display: table
17
+ content: ""
18
+ line-height: 0
19
+ clear: both
20
+
21
+ .hide-text
22
+ font: 0/0 a
23
+ color: transparent
24
+ text-shadow: none
25
+ background-color: transparent
26
+ border: 0
27
+
28
+ .input-block-level
29
+ display: block
30
+ width: 100%
31
+ min-height: 30px
32
+ box-sizing: border-box
33
+
34
+ .btn-file
35
+ overflow: hidden
36
+ position: relative
37
+ vertical-align: middle
38
+ display: block
39
+ > input
40
+ position: absolute
41
+ top: 0
42
+ right: 0
43
+ margin: 0
44
+ opacity: 0
45
+ filter: alpha(opacity = 0)
46
+ transform: translate(-300px, 0) scale(4)
47
+ font-size: 23px
48
+ direction: ltr
49
+ cursor: pointer
50
+ width: 100%
51
+
52
+ .fileupload
53
+ position: relative
54
+ background-color: #eee
55
+ text-align: center
56
+ .uneditable-input
57
+ display: inline-block
58
+ margin-bottom: 0px
59
+ vertical-align: middle
60
+ cursor: text
61
+ .thumbnail
62
+ overflow: hidden
63
+ display: inline-block
64
+ vertical-align: middle
65
+ text-align: center
66
+ > img
67
+ display: inline-block
68
+ vertical-align: middle
69
+ max-height: 100%
70
+ .btn
71
+ vertical-align: middle
72
+
73
+ .fileupload-exists .fileupload-new, .fileupload-new .fileupload-exists
74
+ display: none
75
+
76
+ .fileupload-inline .fileupload-controls
77
+ display: inline
78
+
79
+ .fileupload-new .input-append .btn-file
80
+ border-radius: 0 3px 3px 0
81
+
82
+ .thumbnail-borderless .thumbnail
83
+ border: none
84
+ padding: 0
85
+ border-radius: 0
86
+ box-shadow: none
87
+
88
+ .fileupload-new.thumbnail-borderless .thumbnail
89
+ border: 1px solid #ddd
90
+
91
+ .control-group
92
+ &.warning .fileupload
93
+ .uneditable-input
94
+ color: #a47e3c
95
+ border-color: #a47e3c
96
+ .fileupload-preview
97
+ color: #a47e3c
98
+ .thumbnail
99
+ border-color: #a47e3c
100
+ &.error .fileupload
101
+ .uneditable-input
102
+ color: #b94a48
103
+ border-color: #b94a48
104
+ .fileupload-preview
105
+ color: #b94a48
106
+ .thumbnail
107
+ border-color: #b94a48
108
+ &.success .fileupload
109
+ .uneditable-input
110
+ color: #468847
111
+ border-color: #468847
112
+ .fileupload-preview
113
+ color: #468847
114
+ .thumbnail
115
+ border-color: #468847
116
+
117
+ .fileupload-new .fileupload-preview
118
+ display: none
119
+
120
+ .fileupload-preview
121
+ text-align: center
122
+
123
+ .fileupload-remove
124
+ position: absolute
125
+ top: 0
126
+ right: 0
127
+
128
+ .fileupload-actions
129
+ position: relative
130
+
131
+ .progress
132
+ height: 14px
133
+ margin-bottom: 0
134
+ border-radius: 0
@@ -0,0 +1,4 @@
1
+ module FileUploader
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module FileUploader
2
+ class ImagesController < ApplicationController
3
+ def create
4
+ @image = Image.create!(image_params)
5
+ end
6
+
7
+ def update
8
+ @image = Image.create!(image_params)
9
+ end
10
+
11
+ def destroy
12
+ render json: Image.find(params[:id]).destroy
13
+ end
14
+
15
+ private
16
+ def image_params
17
+ params.require(:image).permit(:file)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module FileUploader
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module ImageUploadable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ has_one :image, as: :imageable, dependent: :destroy
6
+ end
7
+
8
+ def image?
9
+ image and image.file?
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Uploadable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ belongs_to :imageable, polymorphic: true
6
+ mount_uploader :file, ImageUploader
7
+ delegate :regular, to: :file
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ module ImageProcessing
2
+ extend ActiveSupport::Concern
3
+
4
+ include CarrierWave::MimeTypes
5
+ include CarrierWave::MiniMagick
6
+ include CarrierWave::Processing::MiniMagick
7
+
8
+ included do
9
+ process :set_content_type
10
+ process :strip
11
+
12
+ version :regular do
13
+ process resize_to_fill: [100, 100]
14
+ process quality: 30
15
+ end
16
+ end
17
+
18
+ def store_dir
19
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
20
+ end
21
+
22
+ def extension_white_list
23
+ %w(jpg jpeg gif png)
24
+ end
25
+
26
+ def filename
27
+ if original_filename
28
+ extension = File.extname(original_filename)
29
+ name = File.basename(original_filename, extension).parameterize.dasherize
30
+ "#{name}#{extension}"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ = form.fields_for :image do
2
+ div data-component="ImageUploader"
3
+ input name="image_id" data-item="id" type="hidden"
4
+ .fileupload data-provides="fileupload" class="fileupload-#{resource.image? ? 'exists' : 'new'}"
5
+ .fileupload-preview.thumbnail style="width: 50px; height: 50px;"
6
+ = image_tag resource.image.file.regular, width: 50, height: 50 if resource.image?
7
+ div
8
+ span.btn.btn-file
9
+ span.fileupload-new Escolher imagem
10
+ span.fileupload-exists Alterar
11
+ input type="file" data-url="#{file_uploader.images_path}" name="image[file]"
12
+ - if resource.image?
13
+ = link_to 'Excluir', file_uploader.image_path(resource.image), class: 'btn fileupload-exists', remote: true, method: :delete
14
+ - else
15
+ = link_to 'Excluir', '#', class: 'btn fileupload-exists', remote: true, method: :delete
16
+
@@ -0,0 +1,6 @@
1
+ json.(@image, :id)
2
+ json.versions do
3
+ json.original @image.file.url
4
+ json.regular @image.file.regular.url
5
+ end
6
+ json.url image_path(@image)
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>FileUploader</title>
5
+ <%= stylesheet_link_tag "file_uploader/application", media: "all" %>
6
+ <%= javascript_include_tag "file_uploader/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ FileUploader::Engine.routes.draw do
2
+ resources :images, only: [:create, :update, :destroy]
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'slim'
2
+ require 'sass-rails'
3
+ require 'coffee-rails'
4
+ require 'fog'
5
+ require 'carrierwave'
6
+ require 'carrierwave-processing'
7
+ require 'mini_magick'
8
+ require 'jbuilder'
9
+
10
+
11
+ module FileUploader
12
+ class Engine < ::Rails::Engine
13
+ config.autoload_paths << File.expand_path('../../../app/uploaders/concerns', __FILE__)
14
+ p config.autoload_paths
15
+ isolate_namespace FileUploader
16
+ end
17
+ end
18
+
19
+ class ActionView::Helpers::FormBuilder
20
+ def image_uploader
21
+ @template.render partial: 'file_uploader/images/uploader', locals: {resource: @object, form: self}
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module FileUploader
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "file_uploader/engine"
2
+
3
+ module FileUploader
4
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate image Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,34 @@
1
+ module FileUploader
2
+ class ImageGenerator < Rails::Generators::Base
3
+ include Rails::Generators::Migration
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_initializer
8
+ copy_file 'initializers/carrierwave.rb', 'config/initializers/carrierwave.rb'
9
+ end
10
+
11
+ def create_uploader
12
+ copy_file 'uploaders/image_uploader.rb', 'app/uploaders/image_uploader.rb'
13
+ end
14
+
15
+ def create_model
16
+ copy_file 'models/image.rb', 'app/models/image.rb'
17
+ end
18
+
19
+ def create_migration
20
+ migration_template 'migrate/create_images.rb', 'db/migrate/create_images.rb'
21
+ end
22
+
23
+
24
+ private
25
+
26
+ def self.next_migration_number(dirname)
27
+ if ActiveRecord::Base.timestamped_migrations
28
+ Time.now.utc.strftime('%Y%m%d%H%M%S')
29
+ else
30
+ '%.3d' % (current_migration_number(dirname) + 1)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ if Rails.env.production?
2
+ CarrierWave.configure do |config|
3
+ config.storage = :fog
4
+
5
+ config.fog_credentials = {
6
+ provider: 'AWS',
7
+ aws_access_key_id: ENV['S3_KEY'],
8
+ aws_secret_access_key: ENV['S3_SECRET'],
9
+ region: ENV['S3_REGION']
10
+ }
11
+
12
+ config.fog_directory = ENV['S3_BUCKET']
13
+ config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}
14
+ end
15
+ end
16
+
17
+ if Rails.env.test?
18
+ CarrierWave.configure do |config|
19
+ config.storage :file
20
+ config.enable_processing = false
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ class CreateImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :file
5
+ t.references :imageable, polymorphic: true, index: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ class Image < ActiveRecord::Base
2
+ include Uploadable
3
+ end
@@ -0,0 +1,3 @@
1
+ class ImageUploader < CarrierWave::Uploader::Base
2
+ include ImageProcessing
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :file_uploader do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+ #= require file_uploader
@@ -0,0 +1,2 @@
1
+ @import scaffold
2
+ @import file_uploader