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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22b54fe2251df7de8f7d1601136ff83f71909d78
4
- data.tar.gz: 1e46ee36eb3df515edcd80979644a58f82cb439a
3
+ metadata.gz: 8cb20f94f07d947d64aae67ea6279593443c4d8b
4
+ data.tar.gz: 85d0744e07696a77a22e1b23fe82e736ef0d7369
5
5
  SHA512:
6
- metadata.gz: 3fc7fca562cf1f4506a32a3bd8c98dc21c68818fbd7e0e483df0e9712c2828e04b58d134404687c8d6f7ea8e4114c219f8749a1e9be22a51b7b122f043c8643a
7
- data.tar.gz: df620147c17b2951d8a4c6b1ffd39be95492b26bcbd1f23f9e6a29f987c4eae5156e5ff71c0ecf683475c54236deddf751f30a78cfd3c58d6a5e265995f4880f
6
+ metadata.gz: 12f724b158da053db93803de7e0f14f93fb1b167c5609f53fd0c01f23de16903ad2e85957b809c687309e9f92bab96fedf7d5a3b6ca742d0f4032b425e197051
7
+ data.tar.gz: 4bef434fe80fba7491d06e2fe54943b45ac0ac5f07df195b9b534bc5af20a0e0278595cfa0660957912c5ff9f62a09b65a2dd655b12555f00098209a829ad409
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/upload-image.svg)](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
  ![](http://7xvqi7.com1.z0.glb.clouddn.com/upload_image_snapshot-2.png)
12
14
  ![](http://7xvqi7.com1.z0.glb.clouddn.com/upload_image_snapshot-3.png)
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', github: 'dongli/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 'upload_image'
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 id='b9bf30-upload-image-<%= tag %>'
5
- class='b9bf30-upload-image'
6
- data-image-name='<%= image_name %>'
7
- data-disable-trigger='false'
8
- data-disable-hover='false'
9
- style='max-width: <%= width %>px; max-height: <%= height %>px; width: <%= width %>px; height: <%= height %>px;'>
10
- <% image = form.object.send(image_name) %>
11
- <% if image.url %>
12
- <% begin %>
13
- <%= image_tag image.url(:medium), id: "b9bf30-preview-#{tag}" %>
14
- <% rescue %>
15
- <%= image_tag image.url, id: "b9bf30-preview-#{tag}" %>
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
- <% else %>
18
- <img class='b9bf30-blank-image' id='b9bf30-preview-<%= tag %>'></img>
19
- <% end %>
20
- <div id='b9bf30-change-shade-<%= tag %>' class='b9bf30-change-shade'>
21
- <div class='b9bf30-container'><div class='b9bf30-center'>
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
@@ -1,3 +1,3 @@
1
1
  module UploadImage
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -0,0 +1,3 @@
1
+ require 'upload-image/version'
2
+ require 'upload-image/upload-image'
3
+ require 'upload-image/railtie'
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.2
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-08-30 00:00:00.000000000 Z
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/upload_image.js
131
- - app/assets/upload_image.scss
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/upload_image.rb
138
- - lib/upload_image/railtie.rb
139
- - lib/upload_image/upload_image.rb
140
- - lib/upload_image/version.rb
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
@@ -1,3 +0,0 @@
1
- require 'upload_image/version'
2
- require 'upload_image/upload_image'
3
- require 'upload_image/railtie'