ack_rails_admin_jcrop 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dda7fe91b561d2f47b8db348d74ac936201dfb1
|
4
|
+
data.tar.gz: 9cf0765f2b515a8111fe4a9721c77ff1cbb7dfae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03cfe60e3d081c9930584fd747f61fe244b4f3c72d367fc6bd255a4dc48d4c9dfcb8fffa661d6a3c3570869a3615bdfff152eb920c2c397719fa02f2d51d3c39
|
7
|
+
data.tar.gz: 336fa5f79efe08c07936cb60b61d07172af73d32ed8b65eb4c26b01c5f1d9a86ae09652de657639c9286046b4380abe3365941a363bba64788f9be2c6a77fe07
|
@@ -40,10 +40,12 @@ module Paperclip
|
|
40
40
|
ary.delete_at i+1
|
41
41
|
ary.delete_at i
|
42
42
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
|
44
|
+
process_before = [@attachment.instance.crop_process_before]
|
45
|
+
crop = ['-crop', crop_params]
|
46
|
+
process_after = [@attachment.instance.crop_process_after]
|
47
|
+
|
48
|
+
process_before + crop + process_after + ary
|
47
49
|
else
|
48
50
|
super
|
49
51
|
end
|
@@ -51,7 +53,17 @@ module Paperclip
|
|
51
53
|
|
52
54
|
def crop_params
|
53
55
|
target = @attachment.instance
|
54
|
-
|
56
|
+
|
57
|
+
w = target.crop_w.to_i
|
58
|
+
h = target.crop_h.to_i
|
59
|
+
x = target.crop_x.to_i
|
60
|
+
y = target.crop_y.to_i
|
61
|
+
|
62
|
+
x = "+#{x}" if x >= 0
|
63
|
+
y = "+#{y}" if y >= 0
|
64
|
+
geometry = "#{w}x#{h}#{x}#{y}"
|
65
|
+
|
66
|
+
geometry
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
@@ -2,12 +2,14 @@ module RailsAdminJcrop
|
|
2
2
|
module Orm
|
3
3
|
module Extension
|
4
4
|
|
5
|
-
CropFields = [:crop_x, :crop_y, :crop_w, :crop_h, :crop_field]
|
5
|
+
CropFields = [:crop_x, :crop_y, :crop_w, :crop_h, :crop_field, :crop_process_before, :crop_process_after]
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
base.send :attr_accessor, *CropFields
|
9
9
|
end
|
10
10
|
|
11
|
+
|
12
|
+
|
11
13
|
def rails_admin_cropping?
|
12
14
|
CropFields.all? {|f| send(f).present?}
|
13
15
|
end
|
@@ -17,6 +19,30 @@ module RailsAdminJcrop
|
|
17
19
|
::RailsAdminJcrop::AssetEngine.crop!(self, self.crop_field) if self.rails_admin_cropping?
|
18
20
|
end
|
19
21
|
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
def auto_rails_admin_jcrop(field)
|
26
|
+
if !rails_admin_cropping? and self.try("#{field}_default_crop_params") and self.try("#{field}_updated_at_changed?")
|
27
|
+
rails_admin_crop! self.send("#{field}_default_crop_params")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_crop_params_for_left_top(field, width, height, left_offset = 0, top_offset = 0)
|
32
|
+
{
|
33
|
+
crop_x: left_offset, crop_y: left_offset, crop_w: width, crop_h: height, crop_field: field,
|
34
|
+
crop_process_before: '+repage', crop_process_after: '+repage'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def default_crop_params_for_center(field, width, height, left_offset = 0, top_offset = 0)
|
40
|
+
{
|
41
|
+
crop_x: left_offset, crop_y: top_offset, crop_w: width, crop_h: height, crop_field: :image,
|
42
|
+
crop_process_before: '-gravity Center', crop_process_after: '+repage'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
20
46
|
end
|
21
47
|
end
|
22
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ack_rails_admin_jcrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kiseliev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails_admin
|