uploadbox 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -8
- data/app/controllers/uploadbox/images_controller.rb +0 -4
- data/app/views/uploadbox/images/_uploader.html.slim +1 -1
- data/lib/uploadbox/image_uploader.rb +6 -0
- data/lib/uploadbox/version.rb +1 -1
- metadata +52 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a662f240833c250a53327176e51bb6062dec9c96
|
4
|
+
data.tar.gz: 54283fa644cf50a8e952dcc31117fdc4a8552819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23144c6bfa4c07e8ede2993fb0fb57697c145e5e1a197c131c6cacb401a11d7b5b9a8a4546f85ab632a38dbce07db32b2bb7721f2bba3090d9787f5dfa0aea6b
|
7
|
+
data.tar.gz: 948fbf64ea6c9cfc18b0f191fa00660c329b4090111974a11501b920ece07632c357c6dd0d14b3b294a88d437cf446579d30a463ec98d7c9dcb11be7f4349cfd
|
data/README.md
CHANGED
@@ -3,10 +3,14 @@
|
|
3
3
|
## Installation
|
4
4
|
|
5
5
|
Add to Gemfile
|
6
|
-
|
6
|
+
```
|
7
|
+
gem 'uploadbox'
|
8
|
+
```
|
7
9
|
|
8
10
|
Run generators
|
9
|
-
|
11
|
+
```
|
12
|
+
rails g uploadbox:image
|
13
|
+
```
|
10
14
|
|
11
15
|
Add jquery and uploadbox to `application.js`
|
12
16
|
```
|
@@ -23,20 +27,42 @@ Add uploadbox to `application.css`
|
|
23
27
|
```
|
24
28
|
|
25
29
|
Migrate database
|
26
|
-
|
30
|
+
```
|
31
|
+
rake db:migrate
|
32
|
+
```
|
27
33
|
|
28
34
|
Update `routes.rb`
|
29
|
-
|
35
|
+
```
|
36
|
+
mount Uploadbox::Engine => '/uploadbox', as: :uploadbox
|
37
|
+
```
|
30
38
|
|
31
39
|
## Usage
|
32
40
|
Add `uploads_one` to your model
|
33
|
-
|
41
|
+
```
|
42
|
+
class Post < ActiveRecord::Base
|
43
|
+
uploads_one :picture, thumb: [100, 100], regular: [600, 300]
|
44
|
+
end
|
45
|
+
```
|
34
46
|
|
35
47
|
Add field to form
|
36
|
-
|
48
|
+
```
|
49
|
+
<%= f.uploader :picture %>
|
50
|
+
```
|
37
51
|
|
38
52
|
Attach upload on controller
|
39
|
-
|
53
|
+
```
|
54
|
+
@post.attach_picture(params[:picture_id])
|
55
|
+
```
|
40
56
|
|
41
57
|
Show image
|
42
|
-
|
58
|
+
```
|
59
|
+
<%= img @post.picture.regular if @post.picture? %>
|
60
|
+
```
|
61
|
+
|
62
|
+
## Recreate versions
|
63
|
+
You might come to a situation where you want to retroactively change a version or add a new one. You can use the `update_#{upload_name}_versions!` method to recreate the versions from the base file.
|
64
|
+
For a post with a picture:
|
65
|
+
|
66
|
+
```
|
67
|
+
Post.update_picture_versions!
|
68
|
+
```
|
@@ -26,6 +26,12 @@ module Uploadbox
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
# @post.remote_picture_url=('http://exemple.com/image.jpg')
|
30
|
+
define_method("remote_#{upload_name}_url=") do |url|
|
31
|
+
upload = Uploadbox.const_get(upload_class_name).create!(remote_file_url: url)
|
32
|
+
self.send("#{upload_name}=", upload)
|
33
|
+
end
|
34
|
+
|
29
35
|
# @post.attach_picture!
|
30
36
|
define_method("attach_#{upload_name}!") do |upload_id|
|
31
37
|
self.send("#{upload_name}=", upload_class.find(upload_id))
|
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.5
|
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-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 2.0.
|
34
|
+
version: 2.0.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 2.0.
|
41
|
+
version: 2.0.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sass-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: 0.9.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.9.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: carrierwave-processing
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,28 +129,28 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - ~>
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.
|
132
|
+
version: 1.5.0
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ~>
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: 1.
|
139
|
+
version: 1.5.0
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: jquery-rails
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - ~>
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 3.0.
|
146
|
+
version: 3.0.4
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
151
|
- - ~>
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: 3.0.
|
153
|
+
version: 3.0.4
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: better_errors
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +235,48 @@ dependencies:
|
|
235
235
|
- - ~>
|
236
236
|
- !ruby/object:Gem::Version
|
237
237
|
version: 4.2.1
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: poltergeist
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - ~>
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: 1.3.0
|
245
|
+
type: :development
|
246
|
+
prerelease: false
|
247
|
+
version_requirements: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ~>
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: 1.3.0
|
252
|
+
- !ruby/object:Gem::Dependency
|
253
|
+
name: database_cleaner
|
254
|
+
requirement: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - '='
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 1.0.1
|
259
|
+
type: :development
|
260
|
+
prerelease: false
|
261
|
+
version_requirements: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - '='
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: 1.0.1
|
266
|
+
- !ruby/object:Gem::Dependency
|
267
|
+
name: sham_rack
|
268
|
+
requirement: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - '>='
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: '0'
|
273
|
+
type: :development
|
274
|
+
prerelease: false
|
275
|
+
version_requirements: !ruby/object:Gem::Requirement
|
276
|
+
requirements:
|
277
|
+
- - '>='
|
278
|
+
- !ruby/object:Gem::Version
|
279
|
+
version: '0'
|
238
280
|
description: Uploadbox makes easy to manage files in your Rails application.
|
239
281
|
email:
|
240
282
|
- julio@startae.com.br
|