upload-image 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +15 -2
- data/app/assets/{upload_image.js → upload-image.js} +0 -0
- data/app/assets/{upload_image.scss → upload-image.scss} +0 -0
- data/app/views/_upload_image.html.erb +24 -19
- data/lib/{upload_image → upload-image}/railtie.rb +0 -0
- data/lib/{upload_image/upload_image.rb → upload-image/upload-image.rb} +0 -0
- data/lib/{upload_image → upload-image}/version.rb +1 -1
- data/lib/upload-image.rb +3 -0
- metadata +8 -8
- data/lib/upload_image.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cb20f94f07d947d64aae67ea6279593443c4d8b
|
4
|
+
data.tar.gz: 85d0744e07696a77a22e1b23fe82e736ef0d7369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f724b158da053db93803de7e0f14f93fb1b167c5609f53fd0c01f23de16903ad2e85957b809c687309e9f92bab96fedf7d5a3b6ca742d0f4032b425e197051
|
7
|
+
data.tar.gz: 4bef434fe80fba7491d06e2fe54943b45ac0ac5f07df195b9b534bc5af20a0e0278595cfa0660957912c5ff9f62a09b65a2dd655b12555f00098209a829ad409
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://badge.fury.io/rb/upload-image)
|
2
|
+
|
1
3
|
# Upload Image
|
2
4
|
This Rails gem simplifies the implementation of uploading image. With it, you can write the following line in your `*.html.erb` as a view component:
|
3
5
|
|
@@ -11,9 +13,20 @@ Then you will get:
|
|
11
13
|

|
12
14
|

|
13
15
|
|
16
|
+
It takes advantages of `carrierwave` and `cropper.js`.
|
17
|
+
|
14
18
|
## Usage
|
15
19
|
There are some places you need to modify in your Rails app. For example:
|
16
20
|
|
21
|
+
- JavaScript asset file `app/assets/javascripts/application.js`
|
22
|
+
```js
|
23
|
+
//= require upload-image
|
24
|
+
```
|
25
|
+
- Stylesheet asset file `app/assets/stylesheets/application.scss`
|
26
|
+
|
27
|
+
```scss
|
28
|
+
//= require upload-image
|
29
|
+
```
|
17
30
|
- Model file
|
18
31
|
```ruby
|
19
32
|
class User < ApplicationRecord
|
@@ -46,7 +59,7 @@ Then you are good to go.
|
|
46
59
|
Add this line to your application's Gemfile:
|
47
60
|
|
48
61
|
```ruby
|
49
|
-
gem 'upload-image',
|
62
|
+
gem 'upload-image', '~> 0.1'
|
50
63
|
```
|
51
64
|
|
52
65
|
And then execute:
|
@@ -57,7 +70,7 @@ $ bundle
|
|
57
70
|
Add the require statement in your `config/application.rb`:
|
58
71
|
|
59
72
|
```ruby
|
60
|
-
require '
|
73
|
+
require 'upload-image'
|
61
74
|
```
|
62
75
|
|
63
76
|
## Contributing
|
File without changes
|
File without changes
|
@@ -1,26 +1,31 @@
|
|
1
1
|
<% object_name = form.object.class.name.underscore %>
|
2
2
|
<% tag = "#{object_name}__#{image_name}" %>
|
3
3
|
|
4
|
-
<div
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<%
|
15
|
-
|
4
|
+
<div class='b9bf30-upload-image-group'>
|
5
|
+
<label id='b9bf30-upload-image-label-<%= tag %>'>
|
6
|
+
<%= t("activerecord.attributes.#{object_name}.#{image_name}") %>
|
7
|
+
</label>
|
8
|
+
<div id='b9bf30-upload-image-<%= tag %>'
|
9
|
+
class='b9bf30-upload-image'
|
10
|
+
data-image-name='<%= image_name %>'
|
11
|
+
data-disable-trigger='false'
|
12
|
+
data-disable-hover='false'
|
13
|
+
style='max-width: <%= width %>px; max-height: <%= height %>px; width: <%= width %>px; height: <%= height %>px;'>
|
14
|
+
<% image = form.object.send(image_name) %>
|
15
|
+
<% if image.url %>
|
16
|
+
<% begin %>
|
17
|
+
<%= image_tag image.url(:medium), id: "b9bf30-preview-#{tag}" %>
|
18
|
+
<% rescue %>
|
19
|
+
<%= image_tag image.url, id: "b9bf30-preview-#{tag}" %>
|
20
|
+
<% end %>
|
21
|
+
<% else %>
|
22
|
+
<img class='b9bf30-blank-image' id='b9bf30-preview-<%= tag %>'></img>
|
16
23
|
<% end %>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<span><%= t('upload_image.actions.change') %></span>
|
23
|
-
</div></div>
|
24
|
+
<div id='b9bf30-change-shade-<%= tag %>' class='b9bf30-change-shade'>
|
25
|
+
<div class='b9bf30-container'><div class='b9bf30-center'>
|
26
|
+
<span><%= t('upload_image.actions.change') %></span>
|
27
|
+
</div></div>
|
28
|
+
</div>
|
24
29
|
</div>
|
25
30
|
</div>
|
26
31
|
<%= form.file_field image_name, class: 'b9bf30-hide' %>
|
File without changes
|
File without changes
|
data/lib/upload-image.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upload-image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Li Dong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -127,17 +127,17 @@ files:
|
|
127
127
|
- Rakefile
|
128
128
|
- app/assets/cropper.min.css
|
129
129
|
- app/assets/cropper.min.js
|
130
|
-
- app/assets/
|
131
|
-
- app/assets/
|
130
|
+
- app/assets/upload-image.js
|
131
|
+
- app/assets/upload-image.scss
|
132
132
|
- app/concerns/croppable.rb
|
133
133
|
- app/helpers/upload_image_helper.rb
|
134
134
|
- app/views/_upload_image.html.erb
|
135
135
|
- config/locales/upload_image.en.yml
|
136
136
|
- config/locales/upload_image.zh-CN.yml
|
137
|
-
- lib/
|
138
|
-
- lib/
|
139
|
-
- lib/
|
140
|
-
- lib/
|
137
|
+
- lib/upload-image.rb
|
138
|
+
- lib/upload-image/railtie.rb
|
139
|
+
- lib/upload-image/upload-image.rb
|
140
|
+
- lib/upload-image/version.rb
|
141
141
|
homepage: https://github.com/dongli/upload-image
|
142
142
|
licenses:
|
143
143
|
- MIT
|
data/lib/upload_image.rb
DELETED