rails_admin_jcrop 1.2.1 → 1.3.0
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.markdown +39 -28
- data/lib/rails_admin_jcrop/rails_admin.rb +2 -2
- data/lib/rails_admin_jcrop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d5489e657c9d9affc179738e5c61e0abc3b9eb
|
4
|
+
data.tar.gz: 08e64cefde8e422604c65d31aef910fa878e5191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1507eebf55b314a1e6977009647972f4347f55e424a81d46cc1f76bd6371f7a9b0f6db88d433b4ff8f96b685f1fde89d6a9cf489a995897a84af23c3802f1e65
|
7
|
+
data.tar.gz: 2c81e11ad84afe5a22e8df2d1a86d442e200e99a3d75d12800a167f07fe7977b0011b5cf6ac05e8c929d5b7b7cb8dfee16d5e07b76a12aaf082ecf49a126c555
|
data/README.markdown
CHANGED
@@ -4,37 +4,43 @@
|
|
4
4
|
|
5
5
|
1. Add it to your Gemfile and run `bundle install`:
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
```ruby
|
8
|
+
gem 'rails_admin'
|
9
|
+
# Because rails_admin_jcrop autoload modules by checking plugins you use, it's
|
10
|
+
# recommended to require it explictly before rails_admin_jcrop
|
11
|
+
# e.g. if you use carrierwave
|
12
|
+
# gem 'carrierwave', :require => 'carrierwave'
|
13
|
+
gem 'rails_admin_jcrop' #, git: 'git://github.com/janx/rails_admin_jcrop.git'
|
14
|
+
```
|
13
15
|
|
14
16
|
2. Configure your model field to use Jcrop:
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
```ruby
|
19
|
+
# RAILS_ROOT/config/initializers/rails_admin.rb
|
20
|
+
config.model User do
|
21
|
+
configure :avatar, :jcrop
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
# Below is optional
|
24
|
+
edit do
|
25
|
+
field :avatar do
|
26
|
+
jcrop_options aspectRatio: 500.0/320.0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
```
|
27
31
|
|
28
32
|
3. If you use Paperclip, you need to do nothing here, rails_admin_jcrop will append RailsAdminJcropper processor to your attachment automatically. If CarrierWave is used, please invoke :rails_admin_crop in your uploader:
|
29
33
|
|
30
|
-
|
34
|
+
```ruby
|
35
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
version :thumb do
|
38
|
+
process :rails_admin_crop
|
39
|
+
process :resize_to_fill: [500,320]
|
40
|
+
end
|
36
41
|
|
37
|
-
|
42
|
+
end
|
43
|
+
```
|
38
44
|
|
39
45
|
4. Done! Click the image on your RailsAdmin model edit page and enjoy cropping!
|
40
46
|

|
@@ -51,9 +57,11 @@
|
|
51
57
|
|
52
58
|
You can pass any Jcrop plugin allowed options here, for example, use `aspectRatio` to fix the ratio of selection box:
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
```ruby
|
61
|
+
field :avatar do
|
62
|
+
jcrop_options aspectRatio: 500.0/320.0
|
63
|
+
end
|
64
|
+
```
|
57
65
|
|
58
66
|
Please check [Jcrop document](http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options) for more available options.
|
59
67
|
|
@@ -61,9 +69,11 @@ Please check [Jcrop document](http://deepliquid.com/content/Jcrop_Manual.html#Se
|
|
61
69
|
|
62
70
|
By default, image is scaled properly to make cropping more easy, but sometimes the image is still too large to fit in the modal window, you may need to scroll image up/down to crop. If you set `fit_image` to true, image will always be resized to fit in modal window.
|
63
71
|
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
```ruby
|
73
|
+
field :avatar do
|
74
|
+
fit_image true
|
75
|
+
end
|
76
|
+
```
|
67
77
|
|
68
78
|
Check screenshots below to see the difference:
|
69
79
|
|
@@ -123,6 +133,7 @@ Any help is encouraged. Here are some ways you can contribute:
|
|
123
133
|
* [Alan Rosin Sikora](https://github.com/alansikora) ([alansikora](https://github.com/alansikora))
|
124
134
|
* [cec](https://github.com/cec)
|
125
135
|
* [Alex Chien](https://github.com/AlexChien)
|
136
|
+
* [Mitsuhiro Shibuya]([mshibuya](https://github.com/mshibuya))
|
126
137
|
|
127
138
|
### And ... ###
|
128
139
|
|
@@ -30,8 +30,8 @@ module RailsAdmin
|
|
30
30
|
end
|
31
31
|
|
32
32
|
RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
|
33
|
-
if properties[:name] == :jcrop
|
34
|
-
fields << RailsAdmin::Config::Fields::Types::Jcrop.new(parent,
|
33
|
+
if (properties.respond_to?(:name) ? properties.name : properties[:name]) == :jcrop
|
34
|
+
fields << RailsAdmin::Config::Fields::Types::Jcrop.new(parent, :jcrop, properties)
|
35
35
|
true
|
36
36
|
else
|
37
37
|
false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_jcrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.1.11
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Jcrop plugin for rails admin.
|