uploadbox 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/app/assets/javascripts/_image_uploader.coffee +17 -4
- data/app/helpers/uploadbox/img_helper.rb +29 -0
- data/app/views/uploadbox/images/_uploader.html.slim +3 -3
- data/lib/generators/uploadbox/image/image_generator.rb +8 -0
- data/lib/generators/uploadbox/image/templates/Procfile +1 -0
- data/lib/generators/uploadbox/image/templates/initializers/uploadbox.rb +3 -5
- data/lib/uploadbox/image_uploader.rb +1 -1
- data/lib/uploadbox/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793534702191f8ac2e654b13f87e970320effc4e
|
4
|
+
data.tar.gz: 27ebcf04dfdd0e5af5bf96563f6a49cbe5cf6ead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 330cf7e386cf7f18807f9b81170b3bd0efeb7bf0e2b6c6800c353e471d4dfc23ff3e6f718c9b53f3249feb8fcb83ddd75a702637271e584f1f2d8b34c10e02a8
|
7
|
+
data.tar.gz: c7811bc5e8d1b982f808da97d7742e7cb72843d00bdc7189f60e111d513573dc7623f4508d86a2b8e53d1a9edaee8d536e3a35161833e12143a3974c0caa7eec
|
data/README.md
CHANGED
@@ -33,9 +33,14 @@ Migrate database
|
|
33
33
|
rake db:migrate
|
34
34
|
```
|
35
35
|
|
36
|
-
|
36
|
+
Create a bucket on S3 (US region)
|
37
|
+
|
38
|
+
Set environmet variables
|
37
39
|
```
|
38
|
-
|
40
|
+
S3_KEY=AAAA123BBBB
|
41
|
+
S3_SECRET=abc123ABcEffgee122
|
42
|
+
S3_REGION=sa-east-1
|
43
|
+
S3_BUCKET=uploads
|
39
44
|
```
|
40
45
|
|
41
46
|
## Usage
|
@@ -68,3 +73,16 @@ For a post with a picture:
|
|
68
73
|
```
|
69
74
|
Post.update_picture_versions!
|
70
75
|
```
|
76
|
+
|
77
|
+
|
78
|
+
## Heroku
|
79
|
+
Set environmet variables
|
80
|
+
```
|
81
|
+
HEROKU_API_KEY=ab12acvc12
|
82
|
+
HEROKU_APP=your-app-name
|
83
|
+
```
|
84
|
+
|
85
|
+
Add Redis to Go addon
|
86
|
+
```
|
87
|
+
heroku addons:add rediscloud:20
|
88
|
+
```
|
@@ -7,6 +7,8 @@ class @ImageUploader
|
|
7
7
|
@idInput = @container.find('[data-item="id"]')
|
8
8
|
@container.find('a.btn.fileupload-exists').bind('ajax:success', @delete)
|
9
9
|
@thumbContainer = @container.find('.fileupload-preview.thumbnail')
|
10
|
+
|
11
|
+
@fileInput.show()
|
10
12
|
|
11
13
|
@fileInput.fileupload
|
12
14
|
type: 'POST'
|
@@ -14,17 +16,28 @@ class @ImageUploader
|
|
14
16
|
replaceFileInput: false
|
15
17
|
autoUpload: true
|
16
18
|
formData: @getFormData
|
19
|
+
dropZone: @container
|
20
|
+
pasteZone: @container
|
17
21
|
add: @add
|
18
22
|
progress: @progress
|
19
23
|
done: @done
|
20
24
|
|
21
25
|
add: (e, data) =>
|
22
|
-
@
|
23
|
-
|
24
|
-
|
26
|
+
@file = data.files[0]
|
27
|
+
|
28
|
+
if @loader
|
29
|
+
@loader.detach()
|
30
|
+
|
31
|
+
if @verifyProcessingInterval
|
32
|
+
clearInterval(@verifyProcessingInterval)
|
33
|
+
|
34
|
+
if @file.type.match /gif|jpe?g|png/
|
35
|
+
@loader = $('<div class="progress progress-striped active"><div class="bar" style="width: 0%;"></div></div>').hide()
|
36
|
+
@preview.prepend(@loader.fadeIn())
|
37
|
+
data.submit()
|
25
38
|
|
26
39
|
getFormData: (arg) =>
|
27
|
-
file = @
|
40
|
+
file = @file
|
28
41
|
@filePath = @container.find('input[name="key"]').val() + file.name
|
29
42
|
[
|
30
43
|
{ name: 'key', value: @filePath },
|
@@ -1,5 +1,20 @@
|
|
1
1
|
module Uploadbox
|
2
2
|
module ImgHelper
|
3
|
+
def s3_policy
|
4
|
+
Base64.encode64(policy_data.to_json).gsub("\n", "")
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
def s3_signature
|
9
|
+
Base64.encode64(
|
10
|
+
OpenSSL::HMAC.digest(
|
11
|
+
OpenSSL::Digest::Digest.new('sha1'),
|
12
|
+
ENV['S3_SECRET'],
|
13
|
+
s3_policy
|
14
|
+
)
|
15
|
+
).gsub("\n", "")
|
16
|
+
end
|
17
|
+
|
3
18
|
def img(*args)
|
4
19
|
upload = args[0]
|
5
20
|
if upload.is_a? CarrierWave::Uploader::Base
|
@@ -8,5 +23,19 @@ module Uploadbox
|
|
8
23
|
image_tag(*args)
|
9
24
|
end
|
10
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def policy_data
|
29
|
+
{
|
30
|
+
expiration: 10.hours.from_now.utc.iso8601,
|
31
|
+
conditions: [
|
32
|
+
["starts-with", "$key", 'uploads/'],
|
33
|
+
["content-length-range", 0, 500.megabytes],
|
34
|
+
["starts-with","$content-type",""],
|
35
|
+
{bucket: ENV['S3_BUCKET']},
|
36
|
+
{acl: 'public-read'}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
end
|
11
40
|
end
|
12
41
|
end
|
@@ -17,9 +17,9 @@
|
|
17
17
|
span.fileupload-new = choose_label
|
18
18
|
span.fileupload-exists = update_label
|
19
19
|
|
20
|
-
input type="file" name="image[file]" data-callback-url="#{uploadbox.images_path}" data-find-url="#{uploadbox.find_images_path(format: :json)}" data-url="https://#{ENV['S3_BUCKET']}.s3.amazonaws.com/" data-secure-random="#{secure_random}"
|
21
|
-
input type="hidden" name="policy" value="#{
|
22
|
-
input type="hidden" name="signature" value="#{
|
20
|
+
input type="file" name="image[file]" data-callback-url="#{uploadbox.images_path}" data-find-url="#{uploadbox.find_images_path(format: :json)}" data-url="https://#{ENV['S3_BUCKET']}.s3.amazonaws.com/" data-secure-random="#{secure_random}" accept="image/x-png, image/gif, image/jpeg" style="display: none"
|
21
|
+
input type="hidden" name="policy" value="#{s3_policy}"
|
22
|
+
input type="hidden" name="signature" value="#{s3_signature}"
|
23
23
|
input type="hidden" name="AWSAccessKeyId" value="#{ENV['S3_KEY']}"
|
24
24
|
input type="hidden" name="acl" value="public-read"
|
25
25
|
input type="hidden" name="key" value="uploads/#{secure_random}/"
|
@@ -14,6 +14,14 @@ module Uploadbox
|
|
14
14
|
append_to_file '.gitignore', "\npublic/uploads"
|
15
15
|
end
|
16
16
|
|
17
|
+
def copy_procfile
|
18
|
+
copy_file 'Procfile', 'Procfile'
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_route
|
22
|
+
route "mount Uploadbox::Engine => '/uploadbox', as: :uploadbox"
|
23
|
+
end
|
24
|
+
|
17
25
|
def create_migration
|
18
26
|
migration_template 'migrate/create_images.rb', 'db/migrate/create_images.rb'
|
19
27
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec rails server -p $PORT
|
@@ -3,19 +3,17 @@ Uploadbox.retina_quality = 30
|
|
3
3
|
Uploadbox.image_quality = 70
|
4
4
|
|
5
5
|
if Rails.env.production?
|
6
|
-
REDIS = Redis.connect
|
6
|
+
REDIS = Redis.connect(url: ENV["REDISCLOUD_URL"])
|
7
7
|
Resque.redis = REDIS
|
8
|
-
|
8
|
+
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
|
9
9
|
|
10
|
-
if Rails.env.production?
|
11
10
|
CarrierWave.configure do |config|
|
12
11
|
config.storage = :fog
|
13
12
|
|
14
13
|
config.fog_credentials = {
|
15
14
|
provider: 'AWS',
|
16
15
|
aws_access_key_id: ENV['S3_KEY'],
|
17
|
-
aws_secret_access_key: ENV['S3_SECRET']
|
18
|
-
region: ENV['S3_REGION']
|
16
|
+
aws_secret_access_key: ENV['S3_SECRET']
|
19
17
|
}
|
20
18
|
|
21
19
|
config.fog_directory = ENV['S3_BUCKET']
|
@@ -58,7 +58,7 @@ module Uploadbox
|
|
58
58
|
|
59
59
|
# Uploabox::PostPictureUploader < UploadBox::ImgProcessing < CarrierWave
|
60
60
|
dynamic_uploader = Class.new(Uploadbox::ImageProcessingUploader)
|
61
|
-
Uploadbox.const_set(self.
|
61
|
+
Uploadbox.const_set(self.name.demodulize + 'Uploader', dynamic_uploader)
|
62
62
|
dynamic_uploader.class_eval do
|
63
63
|
upload_versions.each do |version_name, dimensions|
|
64
64
|
if options[:retina]
|
data/lib/uploadbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploadbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julio Protzek
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -151,6 +151,20 @@ dependencies:
|
|
151
151
|
- - ~>
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 1.25.0
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: redis
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ~>
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 3.0.4
|
161
|
+
type: :runtime
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ~>
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 3.0.4
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: heroku-api
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +366,7 @@ files:
|
|
352
366
|
- lib/generators/uploadbox/image/templates/initializers/uploadbox.rb
|
353
367
|
- lib/generators/uploadbox/image/templates/migrate/create_images.rb
|
354
368
|
- lib/generators/uploadbox/image/templates/models/image.rb
|
369
|
+
- lib/generators/uploadbox/image/templates/Procfile
|
355
370
|
- lib/generators/uploadbox/image/USAGE
|
356
371
|
- lib/heroku_resque_auto_scale.rb
|
357
372
|
- lib/tasks/uploadbox_tasks.rake
|