ack_rails_admin_jcrop 0.1.0 → 0.2.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: 3dda7fe91b561d2f47b8db348d74ac936201dfb1
4
- data.tar.gz: 9cf0765f2b515a8111fe4a9721c77ff1cbb7dfae
3
+ metadata.gz: 480d79fca9fce84dfe089209e3c3db69641e8fb9
4
+ data.tar.gz: 75aa8bc7d96a71a7003dc3dac908c77fc8248e01
5
5
  SHA512:
6
- metadata.gz: 03cfe60e3d081c9930584fd747f61fe244b4f3c72d367fc6bd255a4dc48d4c9dfcb8fffa661d6a3c3570869a3615bdfff152eb920c2c397719fa02f2d51d3c39
7
- data.tar.gz: 336fa5f79efe08c07936cb60b61d07172af73d32ed8b65eb4c26b01c5f1d9a86ae09652de657639c9286046b4380abe3365941a363bba64788f9be2c6a77fe07
6
+ metadata.gz: 34478a1aed642baa8398205be298c45269287cbbfbff5575e805a395ad0d0ae9572cb0b4b4a982ee186f209cb7b29c0c3193d4da884f2a88ad589af1421262b2
7
+ data.tar.gz: 72685f588f1d23fee353e57a1f544a06aa1d540852ec19efe01972867cd131921a3d1def3a9c6a53d65abb1a57e7c5700e306d1bd7931273290e8aab89d8acf7
@@ -172,5 +172,6 @@
172
172
  })(jQuery);
173
173
 
174
174
  $(function() {
175
- $('div.jcrop_type, div.enjoy_image_type').jcropForm();
175
+ // EnjoyCMS and HancockCMS support - temporary
176
+ $('div.jcrop_type, div.enjoy_image_type, div.hancock_image_type').jcropForm();
176
177
  });
@@ -6,7 +6,15 @@ module RailsAdminJcrop
6
6
  end
7
7
 
8
8
  def crop!(obj, field)
9
- obj.send(field).reprocess!
9
+ _field = obj.send(field)
10
+ _field.reprocess!(*(_field.styles.keys - [:original]))
11
+ # _field.reprocess_without_saving_instance(*(_field.styles.keys - [:original]))
12
+ end
13
+
14
+ def crop(obj, field)
15
+ _field = obj.send(field)
16
+ # _field.reprocess!(*(_field.styles.keys - [:original]))
17
+ _field.reprocess_without_saving_instance(*(_field.styles.keys - [:original]))
10
18
  end
11
19
  end
12
20
  end
@@ -14,6 +22,25 @@ end
14
22
 
15
23
  module Paperclip
16
24
 
25
+ class Attachment
26
+ # remaded from reprocess!
27
+ def reprocess_without_saving_instance(*style_args)
28
+ saved_only_process, @options[:only_process] = @options[:only_process], style_args
29
+ saved_preserve_files, @options[:preserve_files] = @options[:preserve_files], true
30
+ begin
31
+ assign(self)
32
+ save
33
+ # instance.save
34
+ rescue Errno::EACCES => e
35
+ warn "#{e} - skipping file."
36
+ false
37
+ ensure
38
+ @options[:only_process] = saved_only_process
39
+ @options[:preserve_files] = saved_preserve_files
40
+ end
41
+ end
42
+ end
43
+
17
44
  module RailsAdminJcropperMethods
18
45
  def has_attached_file(*args)
19
46
  super
@@ -34,7 +61,7 @@ module Paperclip
34
61
 
35
62
  class RailsAdminJcropper < Thumbnail
36
63
  def transformation_command
37
- if @attachment.instance.rails_admin_cropping?
64
+ if @attachment.instance.rails_admin_cropping? and @options[:style] != :original
38
65
  ary = super
39
66
  if i = ary.index('-crop')
40
67
  ary.delete_at i+1
@@ -19,26 +19,38 @@ module RailsAdminJcrop
19
19
  ::RailsAdminJcrop::AssetEngine.crop!(self, self.crop_field) if self.rails_admin_cropping?
20
20
  end
21
21
 
22
+ def rails_admin_crop(params)
23
+ CropFields.each {|f| self.send "#{f}=", params[f] }
24
+ ::RailsAdminJcrop::AssetEngine.crop(self, self.crop_field) if self.rails_admin_cropping?
25
+ end
22
26
 
23
27
 
24
28
 
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")
29
+ # use it like this:
30
+ # after_save do
31
+ # auto_rails_admin_jcrop(:image)
32
+ # end
33
+ # def image_default_crop_params
34
+ # if image and !image_file_name.blank?
35
+ # default_crop_params_for_center(:image, 40, 40)
36
+ # end
37
+ # end
38
+ def auto_rails_admin_jcrop(_field_name)
39
+ if !rails_admin_cropping? and self.try("#{_field_name}_updated_at_changed?") and (_crop_params = self.try("#{_field_name}_default_crop_params"))
40
+ rails_admin_crop _crop_params
28
41
  end
29
42
  end
30
43
 
31
- def default_crop_params_for_left_top(field, width, height, left_offset = 0, top_offset = 0)
44
+ def default_crop_params_for_left_top(_field_name, width, height, left_offset = 0, top_offset = 0)
32
45
  {
33
- crop_x: left_offset, crop_y: left_offset, crop_w: width, crop_h: height, crop_field: field,
46
+ crop_x: left_offset, crop_y: left_offset, crop_w: width, crop_h: height, crop_field: _field_name,
34
47
  crop_process_before: '+repage', crop_process_after: '+repage'
35
48
  }
36
49
  end
37
50
 
38
-
39
- def default_crop_params_for_center(field, width, height, left_offset = 0, top_offset = 0)
51
+ def default_crop_params_for_center(_field_name, width, height, left_offset = 0, top_offset = 0)
40
52
  {
41
- crop_x: left_offset, crop_y: top_offset, crop_w: width, crop_h: height, crop_field: :image,
53
+ crop_x: left_offset, crop_y: top_offset, crop_w: width, crop_h: height, crop_field: _field_name,
42
54
  crop_process_before: '-gravity Center', crop_process_after: '+repage'
43
55
  }
44
56
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminJcrop
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-09 00:00:00.000000000 Z
12
+ date: 2016-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails_admin
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.8.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.8.1
28
28
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  description: Jcrop plugin for rails admin. Forked from https://github.com/janx/rails_admin_jcrop
43
43
  Image cropping made easy!
44
44
  email:
45
- - dev@enjoycreate.ru
45
+ - dev@redrocks.pro
46
46
  - jan.h.xie@gmail.com
47
47
  executables: []
48
48
  extensions: []
@@ -79,7 +79,7 @@ files:
79
79
  - vendor/assets/stylesheets/rails_admin/Jcrop.gif
80
80
  - vendor/assets/stylesheets/rails_admin/jquery.Jcrop.css
81
81
  - vendor/assets/stylesheets/rails_admin/jquery.Jcrop.min.css
82
- homepage: https://github.com/enjoycreative/rails_admin_jcrop
82
+ homepage: https://github.com/red-rocks/rails_admin_jcrop
83
83
  licenses: []
84
84
  metadata: {}
85
85
  post_install_message:
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.4.7
101
+ rubygems_version: 2.4.8
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Jcrop plugin for rails admin. Forked from https://github.com/janx/rails_admin_jcrop