carrierwave-crop 0.1.0 → 0.1.1
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/.gitignore +0 -1
- data/CHANGELOG.md +43 -0
- data/README.md +71 -12
- data/carrierwave-crop.gemspec +5 -5
- data/lib/carrierwave/crop.rb +3 -8
- data/lib/carrierwave/crop/all.rb +11 -0
- data/lib/carrierwave/crop/engine.rb +3 -1
- data/lib/carrierwave/crop/error.rb +8 -0
- data/lib/carrierwave/crop/helpers.rb +59 -19
- data/lib/carrierwave/crop/model_additions.rb +63 -18
- data/lib/carrierwave/crop/railtie.rb +3 -1
- data/lib/carrierwave/crop/version.rb +2 -2
- data/lib/generators/templates/carrierwave_cropper.js.coffee +3 -3
- data/spec/crop/model_additions_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/vendor/assets/javascripts/.keep +0 -0
- data/vendor/assets/stylesheets/.keep +0 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ffd4701225ed31cd44ecc10ca63ba345edca3f8
|
4
|
+
data.tar.gz: d03384b62cf0efe5fdf4269d968f1ddfe9ae30be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2f655debcdba1371c813da797463e25b6597b8dc9f61a1b7f2c9940774490d683ccd706798f87b9461eb81dded61a8bc1cf3b1e7b5fa0c3686abd49e55b9c7
|
7
|
+
data.tar.gz: 245afb4af8f922cfe24854742e4aca04072fee87f462d1712a8ccd3c42c6532c2ba60574e9e57946726a6c7160270c6e5650c6c059b44c21d9eb36bfe6ceb4fb
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
## CarrierWave-Crop v0.1.0
|
2
|
+
* Initial commit
|
3
|
+
* Supports processors `rmagick`.
|
4
|
+
* `process crop: :avatar` resizes the original image to `600x600` and performs cropping on it.
|
5
|
+
|
6
|
+
## CarrierWave-Crop v0.1.1
|
7
|
+
* Supports processors `rmagick` and `mini-magick`.
|
8
|
+
* Changed module name `Carrierwave` to `CarrierWave` in sync with `CarrierWave` gem.
|
9
|
+
* Deprecated `cropped_preview` form helper. Replaced it with `previewbox`.
|
10
|
+
* Supports cropping of ONE attachment per model. Can be directly applied on original attachment if no versions exists.
|
11
|
+
|
12
|
+
process crop: :avatar
|
13
|
+
* Supports cropping of MULTIPLE versions of one attachment per model.
|
14
|
+
* Updated the cropping coffeescript (created by rails generator) to incorporate the changes in form helpers.
|
15
|
+
* Added `version`, `width` and `height` options to form helpers `cropbox` and `previewbox`.
|
16
|
+
##To render a specific version for cropping pass `version` option.
|
17
|
+
<%= f.cropbox :avatar , version: :medium %>
|
18
|
+
<%= f.peviewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox
|
19
|
+
|
20
|
+
## If you override ONE of width/height you MUST override both, otherwise passed option would be ignored.
|
21
|
+
<%= f.cropbox :avatar, width: 550, height: 600 %>
|
22
|
+
<%= f.previewbox :avatar, width: 200, height: 200 %>
|
23
|
+
* Added `width` and `height` arguments to proccessor method `crop`.
|
24
|
+
## If ONLY "thumb" version is to be cropped
|
25
|
+
version :jumbo do
|
26
|
+
resize_to_limit(600,600)
|
27
|
+
end
|
28
|
+
version :thumb do
|
29
|
+
process crop: :avatar ## Crops this version based on original image
|
30
|
+
resize_to_limit(100,100)
|
31
|
+
end
|
32
|
+
|
33
|
+
## With width and height
|
34
|
+
## If ONLY "thumb" version is to be cropped
|
35
|
+
version :jumbo do
|
36
|
+
resize_to_limit(600,600)
|
37
|
+
end
|
38
|
+
version :thumb do
|
39
|
+
## To crop this version based on `jumbo` version, pass width = 600 and height = 600
|
40
|
+
## Specify both width and height values otherwise they would be ignored
|
41
|
+
process crop: [:avatar, 600, 600]
|
42
|
+
resize_to_limit(100,100)
|
43
|
+
end
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# CarrierWave-Crop
|
2
2
|
|
3
3
|
[](https://travis-ci.org/kirtithorat/carrierwave-crop)
|
4
4
|
|
5
|
-
|
5
|
+
CarrierWave extension to crop uploaded images using Jcrop plugin with preview.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Install the latest stable release:
|
10
10
|
|
11
|
-
$[sudo] gem install carrierwave
|
11
|
+
$[sudo] gem install carrierwave-crop
|
12
12
|
|
13
13
|
In Rails, add it to your Gemfile:
|
14
14
|
|
@@ -84,7 +84,7 @@ In the view, say `crop.html.erb`:
|
|
84
84
|
|
85
85
|
<%= form_for @user do |f| %>
|
86
86
|
<%= f.cropbox :avatar %>
|
87
|
-
<%= f.
|
87
|
+
<%= f.previewbox :avatar %>
|
88
88
|
<%= f.submit 'Crop' %>
|
89
89
|
<% end %>
|
90
90
|
|
@@ -93,16 +93,75 @@ In the carrierwave uploader, say `AvatarUploader`:
|
|
93
93
|
Call process on the version you would like to be cropped:
|
94
94
|
|
95
95
|
## If ONLY "thumb" version is to be cropped
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
version :jumbo do
|
97
|
+
resize_to_limit(600,600)
|
98
|
+
end
|
99
|
+
|
100
|
+
version :thumb do
|
101
|
+
process crop: :avatar ## Crops this version based on original image
|
102
|
+
resize_to_limit(100,100)
|
103
|
+
end
|
104
|
+
|
105
|
+
If there are no versions, and original file is to be cropped directly then call the process directly within `AvatarUploader`,
|
106
|
+
|
107
|
+
process crop: :avatar
|
108
|
+
|
109
|
+
##NOTES
|
110
|
+
|
111
|
+
1. Current Documentation is for **CarrierWave-Crop v0.1.1**
|
112
|
+
2. Supports processors `rmagick` and `mini-magick`.
|
113
|
+
|
114
|
+
**To use `rmagick`, add it in your `Gemfile` as:**
|
115
|
+
|
116
|
+
gem 'rmagick', :require => 'RMagick' ## Specify appropriate version, if needed
|
117
|
+
|
118
|
+
Run `bundle`
|
119
|
+
|
120
|
+
Include it in your CarrierWave Uploader. For example:
|
121
|
+
|
122
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
123
|
+
include CarrierWave::RMagick
|
124
|
+
...
|
125
|
+
end
|
126
|
+
|
127
|
+
**To use `mini_magick`, add it in your `Gemfile` as:**
|
128
|
+
|
129
|
+
gem 'mini_magick' ## Specify appropriate version, if needed
|
130
|
+
|
131
|
+
Run `bundle`
|
132
|
+
|
133
|
+
Include it in your CarrierWave Uploader. For example:
|
134
|
+
|
135
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
136
|
+
include CarrierWave::MiniMagick
|
137
|
+
...
|
138
|
+
end
|
139
|
+
|
140
|
+
3. Supports cropping of ONE attachment per model. Can be directly applied on original attachment if no versions exists.
|
141
|
+
process crop: :avatar
|
142
|
+
4. Supports cropping of MULTIPLE versions of one attachment per model.
|
143
|
+
5. In form helpers, by default *original image* is rendered. To render a specific version for cropping pass `version` option. For example:
|
144
|
+
<%= f.cropbox :avatar , version: :medium %>
|
145
|
+
<%= f.peviewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox
|
146
|
+
6. By default `previewbox` has `100x100` dimensions and `cropbox` defaults to the target geometry for the version.
|
147
|
+
`width` and `height` can be specified for these form helpers. BUT If you override ONE of width/height you MUST override both, otherwise passed option would be ignored.
|
148
|
+
<%= f.cropbox :avatar, width: 550, height: 600 %>
|
149
|
+
<%= f.previewbox :avatar, width: 200, height: 200 %>
|
150
|
+
7. By default, `process crop: :avatar` will create the cropped version based on original image.
|
151
|
+
To resize the image to a particular dimension before cropping, pass two more arguments `width` and `height`.
|
152
|
+
## If ONLY "thumb" version is to be cropped
|
153
|
+
version :jumbo do
|
154
|
+
resize_to_limit(600,600)
|
155
|
+
end
|
99
156
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
157
|
+
version :thumb do
|
158
|
+
## To crop this version based on `jumbo` version, pass width = 600 and height = 600
|
159
|
+
## Specify both width and height values otherwise they would be ignored
|
160
|
+
process crop: [:avatar, 600, 600]
|
161
|
+
resize_to_limit(100,100)
|
162
|
+
end
|
104
163
|
|
105
164
|
### Credits and resources
|
106
|
-
* [
|
165
|
+
* [CarrierWave](https://github.com/carrierwaveuploader/carrierwave)
|
107
166
|
* [Deep Liquid's JCrop](http://deepliquid.com/content/Jcrop.html)
|
108
167
|
* And Ryan Bates [Railscast#182](http://railscasts.com/episodes/182-cropping-images/)
|
data/carrierwave-crop.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'carrierwave/crop/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "carrierwave-crop"
|
8
|
-
spec.version =
|
8
|
+
spec.version = CarrierWave::Crop::VERSION
|
9
9
|
spec.authors = ["kirtithorat"]
|
10
10
|
spec.email = ["kirti.brenz@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{CarrierWave extension for cropping images with preview.}
|
12
|
+
spec.description = %q{CarrierWave extension to crop uploaded images using Jcrop plugin.}
|
13
13
|
spec.homepage = "https://github.com/kirtithorat/carrierwave-crop"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "rails", ">= 3.
|
21
|
+
spec.add_dependency "rails", ">= 3.2"
|
22
22
|
spec.add_dependency "jquery-rails"
|
23
23
|
spec.add_dependency "carrierwave", [">= 0.8.0", "< 0.11.0"]
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.5"
|
26
26
|
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
28
|
end
|
data/lib/carrierwave/crop.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
if defined? Rails
|
5
|
-
require 'carrierwave/crop/engine'
|
6
|
-
require "carrierwave/crop/railtie"
|
7
|
-
require 'carrierwave/crop/helpers'
|
8
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'carrierwave/crop/all'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "carrierwave/crop/version"
|
4
|
+
require "carrierwave/crop/error"
|
5
|
+
|
6
|
+
if defined? Rails
|
7
|
+
require "carrierwave/crop/engine"
|
8
|
+
require 'carrierwave/crop/helpers'
|
9
|
+
require "carrierwave/crop/model_additions"
|
10
|
+
require "carrierwave/crop/railtie"
|
11
|
+
end
|
@@ -1,38 +1,78 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module CarrierWave
|
2
4
|
module Crop
|
3
5
|
module Helpers
|
4
6
|
|
5
|
-
|
7
|
+
# Form helper to render the preview of a cropped attachment.
|
8
|
+
# Loads the actual image. Previewbox has no constraints on dimensions, image is renedred at full size.
|
9
|
+
# By default box size is 100x100. Size can be customized by setting the :width and :height option.
|
10
|
+
# If you override one of width/height you must override both.
|
11
|
+
# By default original image is rendered. Specific version can be specified by passing version option
|
12
|
+
#
|
13
|
+
# previewbox :avatar
|
14
|
+
# previewbox :avatar, width: 200, height: 200
|
15
|
+
# previewbox :avatar, version: :medium
|
16
|
+
#
|
17
|
+
# @param attachment [Symbol] attachment name
|
18
|
+
# @param opts [Hash] specify version or width and height options
|
19
|
+
def previewbox(attachment, opts = {})
|
6
20
|
attachment = attachment.to_sym
|
7
|
-
width = opts[:width] || 100
|
8
|
-
height = (width / 1).round
|
9
21
|
|
10
22
|
if(self.object.send(attachment).class.ancestors.include? CarrierWave::Uploader::Base )
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
23
|
+
model_name = self.object.class.name.downcase
|
24
|
+
width, height = 100, 100
|
25
|
+
if(opts[:width] && opts[:height])
|
26
|
+
width, height = opts[:width].round, opts[:height].round
|
27
|
+
end
|
28
|
+
wrapper_attributes = {id: "#{model_name}_#{attachment}_previewbox_wrapper", style: "width:#{width}px; height:#{height}px; overflow:hidden"}
|
29
|
+
if opts[:version]
|
30
|
+
img = self.object.send(attachment).url(opts[:version])
|
31
|
+
else
|
32
|
+
img = self.object.send(attachment).url
|
33
|
+
end
|
34
|
+
preview_image = @template.image_tag(img, id: "#{model_name}_#{attachment}_previewbox")
|
35
|
+
@template.content_tag(:div, preview_image, wrapper_attributes)
|
19
36
|
end
|
20
37
|
end
|
21
38
|
|
22
|
-
|
39
|
+
# Form helper to render the actual cropping box of an attachment.
|
40
|
+
# Loads the actual image. Cropbox has no constraints on dimensions, image is renedred at full size.
|
41
|
+
# Box size can be restricted by setting the :width and :height option. If you override one of width/height you must override both.
|
42
|
+
# By default original image is rendered. Specific version can be specified by passing version option
|
43
|
+
#
|
44
|
+
# cropbox :avatar
|
45
|
+
# cropbox :avatar, width: 550, height: 600
|
46
|
+
# cropbox :avatar, version: :medium
|
47
|
+
#
|
48
|
+
# @param attachment [Symbol] attachment name
|
49
|
+
# @param opts [Hash] specify version or width and height options
|
23
50
|
def cropbox(attachment, opts={})
|
24
51
|
attachment = attachment.to_sym
|
52
|
+
attachment_instance = self.object.send(attachment)
|
25
53
|
|
26
|
-
if(
|
27
|
-
|
54
|
+
if(attachment_instance.class.ancestors.include? CarrierWave::Uploader::Base )
|
55
|
+
|
56
|
+
model_name = self.object.class.name.downcase
|
57
|
+
hidden_elements = self.hidden_field(:"#{attachment}_crop_x", id: "#{model_name}_#{attachment}_crop_x")
|
28
58
|
[:crop_y, :crop_w, :crop_h].each do |attribute|
|
29
|
-
|
59
|
+
hidden_elements << self.hidden_field(:"#{attachment}_#{attribute}", id: "#{model_name}_#{attachment}_#{attribute}")
|
30
60
|
end
|
31
61
|
|
32
|
-
|
62
|
+
box = @template.content_tag(:div, hidden_elements, style: "display:none")
|
33
63
|
|
34
|
-
|
64
|
+
wrapper_attributes = {id: "#{model_name}_#{attachment}_cropbox_wrapper"}
|
65
|
+
if(opts[:width] && opts[:height])
|
66
|
+
wrapper_attributes.merge!(style: "width:#{opts[:width].round}px; height:#{opts[:height].round}px; overflow:hidden")
|
67
|
+
end
|
35
68
|
|
69
|
+
if opts[:version]
|
70
|
+
img = self.object.send(attachment).url(opts[:version])
|
71
|
+
else
|
72
|
+
img = self.object.send(attachment).url
|
73
|
+
end
|
74
|
+
crop_image = @template.image_tag(img, :id => "#{model_name}_#{attachment}_cropbox")
|
75
|
+
box << @template.content_tag(:div, crop_image, wrapper_attributes)
|
36
76
|
end
|
37
77
|
end
|
38
78
|
end
|
@@ -41,6 +81,6 @@ end
|
|
41
81
|
|
42
82
|
if defined? ActionView::Helpers::FormBuilder
|
43
83
|
ActionView::Helpers::FormBuilder.class_eval do
|
44
|
-
include
|
84
|
+
include CarrierWave::Crop::Helpers
|
45
85
|
end
|
46
86
|
end
|
@@ -1,21 +1,32 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module CarrierWave
|
2
4
|
module Crop
|
3
5
|
module ModelAdditions
|
4
|
-
|
5
6
|
module ClassMethods
|
6
7
|
|
7
|
-
|
8
|
+
# Adds cropping feature on a specific attribute of your model
|
9
|
+
#
|
10
|
+
# crop_uploaded :avatar
|
11
|
+
#
|
12
|
+
# @param attachment [Symbol] Name of the attachment attribute to be cropped
|
8
13
|
def crop_uploaded(attachment)
|
9
14
|
|
10
15
|
[:crop_x, :crop_y, :crop_w, :crop_h].each do |a|
|
11
16
|
attr_accessor :"#{attachment}_#{a}"
|
12
17
|
end
|
13
18
|
after_update :"recreate_#{attachment}_versions"
|
19
|
+
|
14
20
|
end
|
15
|
-
|
21
|
+
|
22
|
+
end ## End of ClassMethods
|
16
23
|
|
17
24
|
module InstanceMethods
|
18
25
|
|
26
|
+
# Checks if the attachment received cropping attributes
|
27
|
+
# @param attachment [Symbol] Name of the attribute to be croppedv
|
28
|
+
#
|
29
|
+
# @return [Boolean]
|
19
30
|
def cropping?(attachment)
|
20
31
|
!self.send(:"#{attachment}_crop_x").blank? &&
|
21
32
|
!self.send(:"#{attachment}_crop_y").blank? &&
|
@@ -23,6 +34,7 @@ module Carrierwave
|
|
23
34
|
!self.send(:"#{attachment}_crop_h").blank?
|
24
35
|
end
|
25
36
|
|
37
|
+
# method_missing is used to respond to the model callback
|
26
38
|
def method_missing(method, *args)
|
27
39
|
if method.to_s =~ /recreate_(\S{1,})_versions/
|
28
40
|
crop_image(method.to_s.scan(/recreate_(\S{1,})_versions/).flatten.first.to_sym)
|
@@ -31,6 +43,8 @@ module Carrierwave
|
|
31
43
|
end
|
32
44
|
end
|
33
45
|
|
46
|
+
# Saves the attachment if the crop attributes are present
|
47
|
+
# @param attachment [Symbol] Name of the attribute to be cropped
|
34
48
|
def crop_image(attachment)
|
35
49
|
if cropping?(attachment)
|
36
50
|
attachment_instance = send(attachment)
|
@@ -38,30 +52,61 @@ module Carrierwave
|
|
38
52
|
end
|
39
53
|
end
|
40
54
|
|
41
|
-
end
|
42
|
-
|
55
|
+
end ## End of InstanceMethods
|
56
|
+
|
57
|
+
end ## End of ModelAdditions
|
43
58
|
|
44
59
|
module Uploader
|
45
60
|
|
46
|
-
|
61
|
+
# Perfoems cropping.
|
62
|
+
#
|
63
|
+
# On original version of attachment
|
64
|
+
# process crop: :avatar
|
65
|
+
#
|
66
|
+
# Resizes the original image to 600x600 and then performs cropping
|
67
|
+
# process crop: [:avatar, 600, 600]
|
68
|
+
#
|
69
|
+
# @param attachment [Symbol] Name of the attachment attribute to be cropped
|
70
|
+
def crop(attachment, width = nil, height = nil)
|
47
71
|
if model.cropping?(attachment)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
72
|
+
x = model.send("#{attachment}_crop_x").to_i
|
73
|
+
y = model.send("#{attachment}_crop_y").to_i
|
74
|
+
w = model.send("#{attachment}_crop_w").to_i
|
75
|
+
h = model.send("#{attachment}_crop_h").to_i
|
76
|
+
attachment_instance = model.send(attachment)
|
77
|
+
|
78
|
+
if self.respond_to? "resize_to_limit"
|
79
|
+
|
80
|
+
begin
|
81
|
+
if width && height
|
82
|
+
resize_to_limit(width, height)
|
83
|
+
end
|
84
|
+
manipulate! do |img|
|
85
|
+
if attachment_instance.kind_of? CarrierWave::RMagick
|
86
|
+
img.crop!(x, y, w, h)
|
87
|
+
elsif attachment_instance.kind_of? CarrierWave::MiniMagick
|
88
|
+
img.crop("#{w}x#{h}+#{x}+#{y}")
|
89
|
+
img
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
rescue Exception => e
|
94
|
+
raise CarrierWave::Crop::ProcessingError, "Failed to crop - #{e.message}"
|
95
|
+
end
|
96
|
+
|
97
|
+
else
|
98
|
+
raise CarrierWave::Crop::MissingProcessorError, "Failed to crop #{attachment}. Add rmagick or mini_magick."
|
55
99
|
end
|
56
100
|
end
|
57
101
|
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
102
|
+
|
103
|
+
end ## End of Uploader
|
104
|
+
end ## End of Crop
|
105
|
+
end ## End of CarrierWave
|
61
106
|
|
62
107
|
|
63
108
|
if defined? CarrierWave::Uploader::Base
|
64
109
|
CarrierWave::Uploader::Base.class_eval do
|
65
|
-
include
|
110
|
+
include CarrierWave::Crop::Uploader
|
66
111
|
end
|
67
112
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
jQuery ->
|
2
|
-
new
|
2
|
+
new CarrierWaveCropper()
|
3
3
|
|
4
|
-
class
|
4
|
+
class CarrierWaveCropper
|
5
5
|
constructor: ->
|
6
6
|
$('#<%= file_name %>_<%= attachment_name %>_cropbox').Jcrop
|
7
7
|
aspectRatio: 1
|
@@ -17,7 +17,7 @@ class CarrierwaveCropper
|
|
17
17
|
@updatePreview(coords)
|
18
18
|
|
19
19
|
updatePreview: (coords) =>
|
20
|
-
$('
|
20
|
+
$('#<%= file_name %>_<%= attachment_name %>_previewbox').css
|
21
21
|
width: Math.round(100/coords.w * $('#<%= file_name %>_<%= attachment_name %>_cropbox').width()) + 'px'
|
22
22
|
height: Math.round(100/coords.h * $('#<%= file_name %>_<%= attachment_name %>_cropbox').height()) + 'px'
|
23
23
|
marginLeft: '-' + Math.round(100/coords.w * coords.x) + 'px'
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'carrierwave/crop'
|
2
|
-
|
2
|
+
require 'carrierwave/crop/model_additions'
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-crop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kirtithorat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jquery-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +100,7 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
-
description:
|
103
|
+
description: CarrierWave extension to crop uploaded images using Jcrop plugin.
|
104
104
|
email:
|
105
105
|
- kirti.brenz@gmail.com
|
106
106
|
executables: []
|
@@ -110,13 +110,16 @@ files:
|
|
110
110
|
- ".gitignore"
|
111
111
|
- ".rspec"
|
112
112
|
- ".travis.yml"
|
113
|
+
- CHANGELOG.md
|
113
114
|
- Gemfile
|
114
115
|
- LICENSE.txt
|
115
116
|
- README.md
|
116
117
|
- Rakefile
|
117
118
|
- carrierwave-crop.gemspec
|
118
119
|
- lib/carrierwave/crop.rb
|
120
|
+
- lib/carrierwave/crop/all.rb
|
119
121
|
- lib/carrierwave/crop/engine.rb
|
122
|
+
- lib/carrierwave/crop/error.rb
|
120
123
|
- lib/carrierwave/crop/helpers.rb
|
121
124
|
- lib/carrierwave/crop/model_additions.rb
|
122
125
|
- lib/carrierwave/crop/railtie.rb
|
@@ -154,7 +157,7 @@ rubyforge_project:
|
|
154
157
|
rubygems_version: 2.2.0
|
155
158
|
signing_key:
|
156
159
|
specification_version: 4
|
157
|
-
summary:
|
160
|
+
summary: CarrierWave extension for cropping images with preview.
|
158
161
|
test_files:
|
159
162
|
- spec/crop/model_additions_spec.rb
|
160
163
|
- spec/crop_spec.rb
|