s3_cors_fileupload 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -0
  3. data/CHANGELOG.md +10 -3
  4. data/Gemfile +11 -9
  5. data/Gemfile.lock +86 -65
  6. data/README.md +8 -4
  7. data/lib/generators/s3_cors_fileupload/install/install_generator.rb +5 -2
  8. data/lib/generators/s3_cors_fileupload/install/templates/s3_uploads_controller.rb +3 -1
  9. data/lib/generators/s3_cors_fileupload/install/templates/source_file.rb +4 -3
  10. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_download.html.erb +18 -7
  11. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_upload.html.erb +4 -4
  12. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_uploaded.html.erb +17 -6
  13. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/index.html.erb +1 -1
  14. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_download.html.haml +14 -4
  15. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_upload.html.haml +5 -5
  16. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_uploaded.html.haml +12 -1
  17. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/index.html.haml +1 -1
  18. data/lib/s3_cors_fileupload.rb +6 -0
  19. data/lib/s3_cors_fileupload/rails.rb +1 -1
  20. data/lib/s3_cors_fileupload/rails/form_helper.rb +15 -12
  21. data/lib/s3_cors_fileupload/version.rb +3 -3
  22. data/s3_cors_fileupload.gemspec +3 -4
  23. data/spec/dummy/Rakefile +0 -1
  24. data/spec/dummy/app/assets/javascripts/application.js +4 -3
  25. data/spec/dummy/app/assets/javascripts/s3_uploads.js +92 -0
  26. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  27. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  28. data/spec/dummy/app/controllers/s3_uploads_controller.rb +56 -0
  29. data/spec/dummy/app/models/source_file.rb +54 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  31. data/spec/dummy/app/views/s3_uploads/_template_download.html.erb +43 -0
  32. data/spec/dummy/app/views/s3_uploads/_template_upload.html.erb +36 -0
  33. data/spec/dummy/app/views/s3_uploads/_template_uploaded.html.erb +41 -0
  34. data/spec/dummy/app/views/s3_uploads/index.html.erb +41 -0
  35. data/spec/dummy/bin/bundle +3 -0
  36. data/spec/dummy/bin/rails +4 -0
  37. data/spec/dummy/bin/rake +4 -0
  38. data/spec/dummy/config.ru +1 -1
  39. data/spec/dummy/config/application.rb +2 -33
  40. data/spec/dummy/config/boot.rb +4 -9
  41. data/spec/dummy/config/environment.rb +2 -2
  42. data/spec/dummy/config/environments/development.rb +14 -19
  43. data/spec/dummy/config/environments/production.rb +40 -27
  44. data/spec/dummy/config/environments/test.rb +14 -12
  45. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/spec/dummy/config/initializers/inflections.rb +6 -5
  47. data/spec/dummy/config/initializers/secret_token.rb +7 -2
  48. data/spec/dummy/config/initializers/session_store.rb +0 -5
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  50. data/spec/dummy/config/locales/en.yml +20 -2
  51. data/spec/dummy/config/routes.rb +27 -24
  52. data/spec/dummy/db/migrate/20131001201535_create_source_files.rb +14 -0
  53. data/spec/dummy/db/schema.rb +27 -0
  54. data/spec/dummy/public/404.html +43 -11
  55. data/spec/dummy/public/422.html +43 -11
  56. data/spec/dummy/public/500.html +43 -11
  57. data/spec/features/uploads_spec.rb +37 -0
  58. data/spec/lib/s3_cors_fileupload/rails/engine_spec.rb +8 -0
  59. data/spec/lib/s3_cors_fileupload/rails/form_helper_spec.rb +30 -0
  60. data/spec/lib/s3_cors_fileupload/rails/policy_helper_spec.rb +95 -0
  61. data/spec/s3_cors_fileupload_spec.rb +8 -4
  62. data/spec/spec_helper.rb +8 -8
  63. data/spec/support/dummy.pdf +0 -0
  64. data/vendor/assets/javascripts/s3_cors_fileupload/index.js +1 -0
  65. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-image.js +111 -32
  66. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-ui.js +24 -18
  67. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-validate.js +7 -6
  68. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload.js +22 -15
  69. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/load-image-meta.js +137 -0
  70. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/tmpl.js +8 -8
  71. data/vendor/assets/stylesheets/jquery.fileupload-ui.css.erb +2 -1
  72. metadata +56 -28
  73. data/spec/dummy/script/rails +0 -6
@@ -1,5 +1,5 @@
1
1
  Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
@@ -7,22 +7,24 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
13
14
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
16
18
 
17
- # Show full error reports and disable caching
19
+ # Show full error reports and disable caching.
18
20
  config.consider_all_requests_local = true
19
21
  config.action_controller.perform_caching = false
20
22
 
21
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
22
24
  config.action_dispatch.show_exceptions = false
23
25
 
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
26
28
 
27
29
  # Tell Action Mailer not to deliver emails to the real world.
28
30
  # The :test delivery method accumulates sent emails in the
@@ -30,8 +32,8 @@ Dummy::Application.configure do
30
32
  # config.action_mailer.delivery_method = :test
31
33
 
32
34
  # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
35
+ config.active_record.mass_assignment_sanitizer = :strict if ::S3CorsFileupload.active_record_protected_attributes?
34
36
 
35
- # Print deprecation notices to the stderr
37
+ # Print deprecation notices to the stderr.
36
38
  config.active_support.deprecation = :stderr
37
39
  end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -1,15 +1,16 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
6
7
  # inflect.plural /^(ox)$/i, '\1en'
7
8
  # inflect.singular /^(ox)en/i, '\1'
8
9
  # inflect.irregular 'person', 'people'
9
10
  # inflect.uncountable %w( fish sheep )
10
11
  # end
11
- #
12
+
12
13
  # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
14
15
  # inflect.acronym 'RESTful'
15
16
  # end
@@ -1,7 +1,12 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Your secret key for verifying the integrity of signed cookies.
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
4
  # If you change this key, all old signed cookies will become invalid!
5
+
5
6
  # Make sure the secret is at least 30 characters and all random,
6
7
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '79ae60601fdef7837e78e69befd83417da56e109a7134b084a20f36fac651636bd675f934333a842e31030db4dc53cfc8e9901620a6e2e61d55f305da550e448'
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '939ea17b2e2897cb88d84b8e1ddb092712077206a0dc84b21d0e47f20f090fbea1a774d0005c584035f7308c587928f94c07f3b279f741d36b231da7da7db23a'
@@ -1,8 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
@@ -1,14 +1,14 @@
1
1
  # Be sure to restart your server when you modify this file.
2
- #
2
+
3
3
  # This file contains settings for ActionController::ParamsWrapper which
4
4
  # is enabled by default.
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
9
  end
10
10
 
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -1,5 +1,23 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
3
21
 
4
22
  en:
5
23
  hello: "Hello world"
@@ -1,19 +1,25 @@
1
1
  Dummy::Application.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
4
2
 
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
3
+ resources :source_files, :only => [:index, :create, :destroy], :controller => 's3_uploads' do
4
+ get :generate_key, :on => :collection
5
+ end
8
6
 
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
- # This route can be invoked with purchase_url(:id => product.id)
7
+ # The priority is based upon order of creation: first created -> highest priority.
8
+ # See how all your routes lay out with "rake routes".
12
9
 
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
10
+ # You can have the root of your site routed with "root"
11
+ # root 'welcome#index'
12
+
13
+ # Example of regular route:
14
+ # get 'products/:id' => 'catalog#view'
15
+
16
+ # Example of named route that can be invoked with purchase_url(id: product.id)
17
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
18
+
19
+ # Example resource route (maps HTTP verbs to controller actions automatically):
14
20
  # resources :products
15
21
 
16
- # Sample resource route with options:
22
+ # Example resource route with options:
17
23
  # resources :products do
18
24
  # member do
19
25
  # get 'short'
@@ -25,34 +31,31 @@ Dummy::Application.routes.draw do
25
31
  # end
26
32
  # end
27
33
 
28
- # Sample resource route with sub-resources:
34
+ # Example resource route with sub-resources:
29
35
  # resources :products do
30
36
  # resources :comments, :sales
31
37
  # resource :seller
32
38
  # end
33
39
 
34
- # Sample resource route with more complex sub-resources
40
+ # Example resource route with more complex sub-resources:
35
41
  # resources :products do
36
42
  # resources :comments
37
43
  # resources :sales do
38
- # get 'recent', :on => :collection
44
+ # get 'recent', on: :collection
39
45
  # end
40
46
  # end
47
+
48
+ # Example resource route with concerns:
49
+ # concern :toggleable do
50
+ # post 'toggle'
51
+ # end
52
+ # resources :posts, concerns: :toggleable
53
+ # resources :photos, concerns: :toggleable
41
54
 
42
- # Sample resource route within a namespace:
55
+ # Example resource route within a namespace:
43
56
  # namespace :admin do
44
57
  # # Directs /admin/products/* to Admin::ProductsController
45
58
  # # (app/controllers/admin/products_controller.rb)
46
59
  # resources :products
47
60
  # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root :to => 'welcome#index'
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id))(.:format)'
58
61
  end
@@ -0,0 +1,14 @@
1
+ class CreateSourceFiles < ActiveRecord::Migration
2
+ def change
3
+ create_table :source_files do |t|
4
+ t.string :file_name
5
+ t.string :file_content_type
6
+ t.integer :file_size
7
+ t.string :url
8
+ t.string :key
9
+ t.string :bucket
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20131001201535) do
15
+
16
+ create_table "source_files", force: true do |t|
17
+ t.string "file_name"
18
+ t.string "file_content_type"
19
+ t.integer "file_size"
20
+ t.string "url"
21
+ t.string "key"
22
+ t.string "bucket"
23
+ t.datetime "created_at"
24
+ t.datetime "updated_at"
25
+ end
26
+
27
+ end
@@ -2,17 +2,48 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -22,5 +53,6 @@
22
53
  <h1>The page you were looking for doesn't exist.</h1>
23
54
  <p>You may have mistyped the address or the page may have moved.</p>
24
55
  </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
25
57
  </body>
26
58
  </html>
@@ -2,17 +2,48 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -22,5 +53,6 @@
22
53
  <h1>The change you wanted was rejected.</h1>
23
54
  <p>Maybe you tried to change something you didn't have access to.</p>
24
55
  </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
25
57
  </body>
26
58
  </html>
@@ -2,17 +2,48 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -21,5 +52,6 @@
21
52
  <div class="dialog">
22
53
  <h1>We're sorry, but something went wrong.</h1>
23
54
  </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
24
56
  </body>
25
57
  </html>