enjoy_cms_gallery 0.4.0 → 0.4.0.1

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: 14d385e2e07eed29fe3e2b8dda8d9754e46fff02
4
- data.tar.gz: db924613c7e789eeba4a30007f6807c880fb5db3
3
+ metadata.gz: 00c0e1f36e556ece09d0d90a5493f4752679af22
4
+ data.tar.gz: c3b947cb8fd2ee714cd64831696ccd99c6863da9
5
5
  SHA512:
6
- metadata.gz: ca78fe4b6384b3d11de2b8ddb8518c1a354c227ba8888f78a9641a0f090d042ea8bab76f5173621f6340335d47d0c5c22baf7d4efe54b1c4cce970b689133490
7
- data.tar.gz: bda39d733b579c7b0b7ca3c1f80a90ac9e838fdffbe3cb0a9e3ac0871d95e155fd082aab9d5d441dfdf3ecab3a3a20528a0c1357c3af4b8bf6cfaa1d1f2a42d1
6
+ metadata.gz: 632ac29c44d5c842f8448a4b486aaacf16fb1a8a0ffc80b54f79f9210242bf1bd9e04027760749a4ed52f40bc5f457aa57a0a4a41e0b3dc54f85ae912a52ebc7
7
+ data.tar.gz: 11907bd019e601ad28aa0dcf3612420077803d34b14790bcb27566933705cbf3c865e72673a484484e404c2ccb2118e8303f886533d8fbf7278a73016b5da1bf
@@ -41,6 +41,18 @@ if Enjoy.active_record?
41
41
  self.#{name}.processors << p_o if p_o
42
42
  true
43
43
  end
44
+
45
+ def #{name}_svg?
46
+ #{name}_content_type =~ /svg/
47
+ end
48
+
49
+ def #{name}_url(opts)
50
+ if #{name}_svg?
51
+ #{name}.url
52
+ else
53
+ #{name}.url(opts)
54
+ end
55
+ end
44
56
  EVAL
45
57
  jcrop_options ||= {}
46
58
  if jcrop_options
@@ -42,6 +42,18 @@ if Enjoy.mongoid?
42
42
  self.#{name}.processors << p_o if p_o
43
43
  true
44
44
  end
45
+
46
+ def #{name}_svg?
47
+ #{name}_content_type =~ /svg/
48
+ end
49
+
50
+ def #{name}_url(opts)
51
+ if #{name}_svg?
52
+ #{name}.url
53
+ else
54
+ #{name}.url(opts)
55
+ end
56
+ end
45
57
  EVAL
46
58
  jcrop_options ||= {}
47
59
  if jcrop_options
@@ -2,13 +2,10 @@ module Enjoy::Gallery
2
2
  module Admin
3
3
  module EmbeddedImage
4
4
  def self.config(fields = {})
5
- jcrop_proc = Proc.new do
6
- jcrop_options :image_jcrop_options
7
- end
8
5
 
9
6
  if fields
10
7
  if fields.is_a?(Hash)
11
- fields.reverse_merge!({image: [:jcrop, jcrop_proc]})
8
+ fields.reverse_merge!({image: :enjoy_image})
12
9
  else
13
10
  finded = false
14
11
  fields.each { |g|
@@ -18,7 +15,7 @@ module Enjoy::Gallery
18
15
  fields << {
19
16
  name: :image,
20
17
  fields: {
21
- image: [:jcrop, jcrop_proc]
18
+ image: :enjoy_image
22
19
  }
23
20
  }
24
21
  end
@@ -13,24 +13,11 @@ module Enjoy::Gallery
13
13
  end
14
14
  group :URL do
15
15
  active false
16
- field :slugs, :enum do
17
- searchable true
18
- enum_method do
19
- :slugs
20
- end
21
- visible do
22
- bindings[:view].current_user.admin?
23
- end
24
- multiple do
25
- true
26
- end
27
- end
16
+ field :slugs, :enjoy_slugs
28
17
  field :text_slug
29
18
  end
30
19
 
31
- field :image, :jcrop do
32
- jcrop_options :image_jcrop_options
33
- end
20
+ field :image, :enjoy_image
34
21
 
35
22
  # field :gallery_objects do
36
23
  # read_only true
@@ -15,9 +15,7 @@ module Enjoy::Gallery
15
15
  field :name, :string do
16
16
  searchable true
17
17
  end
18
- field :image, :jcrop do
19
- jcrop_options :image_jcrop_options
20
- end
18
+ field :image, :enjoy_image
21
19
 
22
20
  nested_set({max_depth: 1, scopes: []})
23
21
 
@@ -0,0 +1,32 @@
1
+ require 'ack_rails_admin_jcrop'
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ class EnjoyImage < RailsAdmin::Config::Fields::Types::Jcrop
8
+ # Register field type for the type loader
9
+ RailsAdmin::Config::Fields::Types::register(self)
10
+
11
+ register_instance_option :help do
12
+ "SVG не изменяется."
13
+ end
14
+
15
+ register_instance_option :jcrop_options do
16
+ "#{name}_jcrop_options".to_sym
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
26
+ if (properties.respond_to?(:name) ? properties.name : properties[:name]) == :enjoy_image
27
+ fields << RailsAdmin::Config::Fields::Types::EnjoyImage.new(parent, :enjoy_image, properties)
28
+ true
29
+ else
30
+ false
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Enjoy
2
2
  module Gallery
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.0.1"
4
4
  end
5
5
  end
@@ -18,6 +18,8 @@ require "paperclip-optimizer"
18
18
 
19
19
  require "ack_rails_admin_jcrop"
20
20
 
21
+ require "enjoy/gallery/rails_admin_ext/enjoy_image"
22
+
21
23
  require 'enjoy/gallery/configuration'
22
24
  require 'enjoy/gallery/engine'
23
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms_gallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,6 +174,7 @@ files:
174
174
  - lib/enjoy/gallery/models/mongoid/embedded_image.rb
175
175
  - lib/enjoy/gallery/models/mongoid/gallery.rb
176
176
  - lib/enjoy/gallery/models/mongoid/image.rb
177
+ - lib/enjoy/gallery/rails_admin_ext/enjoy_image.rb
177
178
  - lib/enjoy/gallery/version.rb
178
179
  - lib/enjoy_cms_gallery.rb
179
180
  - lib/generators/enjoy/gallery/config/install_generator.rb