uploads 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +47 -0
- data/app/assets/javascripts/anjlab/uploads/button.js.coffee +1 -0
- data/lib/uploads/version.rb +1 -1
- data/lib/uploads.rb +2 -0
- metadata +4 -4
- data/README.rdoc +0 -3
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
= Uploads
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add it to our Gemfile
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'uploads'
|
9
|
+
```
|
10
|
+
|
11
|
+
## In your controller
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
class UserUploadsController < ApplicationController
|
15
|
+
# includes Uploads module for #respond_to_upload method
|
16
|
+
include Uploads
|
17
|
+
|
18
|
+
def create
|
19
|
+
# create you Upload model as usual
|
20
|
+
@upload = current_user.user_uploads.new
|
21
|
+
|
22
|
+
respond_to_upload(request) do |file, response|
|
23
|
+
# grab uploaded file
|
24
|
+
@upload.image = file
|
25
|
+
# try to save it
|
26
|
+
if response[:success] = @upload.save
|
27
|
+
# send back upload id and image preview
|
28
|
+
response[:user_upload_id] = @upload.id
|
29
|
+
response[:user_upload_preview_url] = @upload.image.url(:avator_editor)
|
30
|
+
else
|
31
|
+
# report errors if any
|
32
|
+
response[:errors] = @upload.errors
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
```
|
39
|
+
|
40
|
+
## In your views
|
41
|
+
|
42
|
+
```slim
|
43
|
+
#upload-area data-button='#upload-button' data-multiple='false' data-dropzones='#upload-area'
|
44
|
+
a#upload-button Choose a photo
|
45
|
+
```
|
46
|
+
|
47
|
+
This project rocks and uses MIT-LICENSE.
|
@@ -43,6 +43,7 @@ class @AnjLab.Uploads.Button
|
|
43
43
|
# the right side of the input
|
44
44
|
right: 0
|
45
45
|
top: 0
|
46
|
+
height: 'auto' # bootstrap input[file] height workaround
|
46
47
|
fontFamily: 'Arial'
|
47
48
|
# 4 persons reported this, the max values that worked for them were 243, 236, 236, 118
|
48
49
|
fontSize: '118px'
|
data/lib/uploads/version.rb
CHANGED
data/lib/uploads.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: uploads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yury Korolev
|
@@ -80,7 +80,7 @@ files:
|
|
80
80
|
- lib/uploads.rb
|
81
81
|
- MIT-LICENSE
|
82
82
|
- Rakefile
|
83
|
-
- README.
|
83
|
+
- README.md
|
84
84
|
- test/dummy/app/assets/javascripts/application.js
|
85
85
|
- test/dummy/app/assets/stylesheets/application.css
|
86
86
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- - ! '>='
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
|
-
hash:
|
177
|
+
hash: 2768478654661385862
|
178
178
|
segments:
|
179
179
|
- 0
|
180
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
- - ! '>='
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
|
-
hash:
|
186
|
+
hash: 2768478654661385862
|
187
187
|
segments:
|
188
188
|
- 0
|
189
189
|
requirements: []
|
data/README.rdoc
DELETED