enjoy_cms 0.3.2.1 → 0.3.3

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: 354d416d79c06e6aa4f9c6d253612da52463bb6e
4
- data.tar.gz: 7043ba2b10c631495778dcd34c393af32591ef30
3
+ metadata.gz: 8a343ff214ab5a895ad91cf3eb897a3692420bef
4
+ data.tar.gz: e0d4ebd8b92e5182325c8dc2c0373c8517f8dfc3
5
5
  SHA512:
6
- metadata.gz: ec5259f872d9eca07687544b85bf60ed5eceb53a0afc98b530f8c94d6978d64fdddf909420eb0c903b81b57bdffc628455bdc37d4ac063fab6cc3899889a5898
7
- data.tar.gz: 01b88b44db165280794b8fb991a382df8df0718ac067ddc76a11ffb92d5cb270ac04b6c4655f170232454098c468d699733cbe617d9bb55f58c07cda93b8af5e
6
+ metadata.gz: 9f444d9a1b1e6c99a0de9d94e6d826ceaa73d48ab658a22dc8b17d2e23a9895a690353fa6c8a36e958433c22f294177d3ad31198f7943b34588fe341e829dd8e
7
+ data.tar.gz: f53e6b513f7a9004ddda3fcbda789827ed922f67b1da1cc39e1083daf282986d69dbad1a92c5ebd2abdf00dce77ee73771d3c7e5621dc4a83667fc04bc6c9073
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enjoy_cms (0.3.2.1)
4
+ enjoy_cms (0.3.3)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -183,7 +183,7 @@ GEM
183
183
  mongoid (>= 3.0)
184
184
  rails (>= 3.0)
185
185
  rails_admin (>= 0.5)
186
- rails_admin_nested_set (0.4.5)
186
+ rails_admin_nested_set (0.5.0)
187
187
  rails_admin
188
188
  rails_admin_settings (1.1.3)
189
189
  rails_admin_sort_embedded (0.1.4)
@@ -220,7 +220,7 @@ GEM
220
220
  sprockets (3.5.2)
221
221
  concurrent-ruby (~> 1.0)
222
222
  rack (> 1, < 3)
223
- sprockets-rails (3.0.3)
223
+ sprockets-rails (3.0.4)
224
224
  actionpack (>= 4.0)
225
225
  activesupport (>= 4.0)
226
226
  sprockets (>= 3.0.0)
@@ -1,7 +1,7 @@
1
1
  module Enjoy::GzipHelper
2
2
  def gzip_javascript_include_tag(*sources)
3
3
  # Grab the asset html include tag
4
- tag = javascript_include_tag *sources
4
+ tag = javascript_include_tag(*sources)
5
5
 
6
6
  # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
7
7
  if Rails.env.production? && request.accept_encoding =~ /gzip/i
@@ -14,7 +14,7 @@ module Enjoy::GzipHelper
14
14
 
15
15
  def gzip_stylesheet_link_tag(*sources)
16
16
  # Grab the asset html include tag
17
- tag = stylesheet_link_tag *sources
17
+ tag = stylesheet_link_tag(*sources)
18
18
 
19
19
  # If we are in production and the requesting client accepts gzip encoding, swap for the gzip asset
20
20
  if Rails.env.production? && request.accept_encoding =~ /gzip/i
@@ -0,0 +1,36 @@
1
+ if Enjoy.mongoid?
2
+ module Enjoy::HashField
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def enjoy_cms_hash_field(name, opts = {})
7
+ field "#{name}_hash", opts
8
+
9
+ class_eval <<-EVAL
10
+ def #{name}_str=(val)
11
+ begin
12
+ self.#{name}_hash = JSON.parse(val)
13
+ rescue
14
+ self[:#{name}_str] = val
15
+ end
16
+ end
17
+ def #{name}_str
18
+ self[:#{name}_str] ||= self.#{name}.to_json
19
+ end
20
+ def #{name}
21
+ self.#{name}_hash
22
+ end
23
+
24
+ validate do
25
+ if self.#{name}_str != self.#{name}.to_json
26
+ self.errors.add(:#{name}, "Неверный формат данных")
27
+ else
28
+ self.remove_attribute :#{name}_str
29
+ end
30
+ true
31
+ end
32
+ EVAL
33
+ end
34
+ end
35
+ end
36
+ end
@@ -4,7 +4,7 @@ module Enjoy::Mappable
4
4
  included do
5
5
 
6
6
  if Enjoy.mongoid?
7
- include Geocoder::Model::Mongoid
7
+ include ::Geocoder::Model::Mongoid
8
8
  field :coordinates, type: Array
9
9
  field :address, type: String
10
10
 
@@ -8,10 +8,10 @@ html lang="ru"
8
8
  = csrf_meta_tags
9
9
  = render partial: "blocks/favicon"
10
10
 
11
- = stylesheet_link_tag "application", media: "all", async: true
12
- = javascript_include_tag "application", async: true
11
+ = stylesheet_link_tag "application", media: "all", async: Rails.env == "production"
12
+ = javascript_include_tag "application", async: Rails.env == "production"
13
13
  /[if lt IE 9]
14
- = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js", async: true
14
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js", async: Rails.env == "production"
15
15
 
16
16
  body
17
17
  #root
@@ -0,0 +1 @@
1
+ = form.text_area field.string_method, rows: 10, cols: 80, class: 'form-control'
@@ -21,17 +21,8 @@ module Enjoy
21
21
  end
22
22
  end
23
23
 
24
- fields.each_pair do |name, type|
25
- if type.nil?
26
- field name
27
- else
28
- if type.is_a?(Array)
29
- field name, type[0], &type[1]
30
- else
31
- field name, type
32
- end
33
- end
34
- end
24
+
25
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
35
26
 
36
27
  if block_given?
37
28
  yield self
@@ -7,17 +7,7 @@ module Enjoy
7
7
  field :enabled, :toggle
8
8
  field :name, :string
9
9
 
10
- fields.each_pair do |name, type|
11
- if type.nil?
12
- field name
13
- else
14
- if type.is_a?(Array)
15
- field name, type[0], &type[1]
16
- else
17
- field name, type
18
- end
19
- end
20
- end
10
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
21
11
 
22
12
  if block_given?
23
13
  yield self
@@ -6,7 +6,25 @@ module Enjoy
6
6
  jcrop_options :image_jcrop_options
7
7
  end
8
8
 
9
- fields.reverse_merge!({image: [:jcrop, jcrop_proc]})
9
+ if fields
10
+ if fields.is_a?(Hash)
11
+ fields.reverse_merge!({image: [:jcrop, jcrop_proc]})
12
+ else
13
+ finded = false
14
+ fields.each { |g|
15
+ finded = !!g[:fields][:image] unless finded
16
+ }
17
+ unless finded
18
+ fields << {
19
+ name: :image,
20
+ fields: {
21
+ image: [:jcrop, jcrop_proc]
22
+ }
23
+ }
24
+ end
25
+ end
26
+ end
27
+
10
28
  if block_given?
11
29
  Enjoy::Admin::EmbeddedElement.config(nil, fields) do |config|
12
30
  yield config
@@ -27,17 +27,7 @@ module Enjoy
27
27
  jcrop_options :image_jcrop_options
28
28
  end
29
29
 
30
- fields.each_pair do |name, type|
31
- if type.nil?
32
- field name
33
- else
34
- if type.is_a?(Array)
35
- field name, type[0], &type[1]
36
- else
37
- field name, type
38
- end
39
- end
40
- end
30
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
41
31
 
42
32
  if block_given?
43
33
  yield self
@@ -12,14 +12,8 @@ module Enjoy
12
12
  field :image, :jcrop do
13
13
  jcrop_options :image_jcrop_options
14
14
  end
15
-
16
- fields.each_pair do |name, type|
17
- if type.nil?
18
- field name
19
- else
20
- field name, type
21
- end
22
- end
15
+
16
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
23
17
 
24
18
  if block_given?
25
19
  yield self
@@ -9,17 +9,7 @@ module Enjoy
9
9
  field :text_slug
10
10
  field :name
11
11
 
12
- fields.each_pair do |name, type|
13
- if type.nil?
14
- field name
15
- else
16
- if type.is_a?(Array)
17
- field name, type[0], &type[1]
18
- else
19
- field name, type
20
- end
21
- end
22
- end
12
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
23
13
 
24
14
  if block_given?
25
15
  yield self
@@ -51,17 +51,8 @@ module Enjoy
51
51
  # field :content_html, :ck_editor
52
52
  # field :content_clear, :toggle
53
53
  end
54
- fields.each_pair do |name, type|
55
- if type.nil?
56
- field name
57
- else
58
- if type.is_a?(Array)
59
- field name, type[0], &type[1]
60
- else
61
- field name, type
62
- end
63
- end
64
- end
54
+
55
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
65
56
 
66
57
  group :seo do
67
58
  active false
@@ -47,17 +47,9 @@ module Enjoy
47
47
  end
48
48
  field :text_slug
49
49
  end
50
- fields.each_pair do |name, type|
51
- if type.nil?
52
- field name
53
- else
54
- if type.is_a?(Array)
55
- field name, type[0], &type[1]
56
- else
57
- field name, type
58
- end
59
- end
60
- end
50
+
51
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
52
+
61
53
  group :seo do
62
54
  active false
63
55
  field :seo do
@@ -14,17 +14,7 @@ module Enjoy
14
14
  # field :content_html, :ck_editor
15
15
  # field :content_clear, :toggle
16
16
 
17
- fields.each_pair do |name, type|
18
- if type.nil?
19
- field name
20
- else
21
- if type.is_a?(Array)
22
- field name, type[0], &type[1]
23
- else
24
- field name, type
25
- end
26
- end
27
- end
17
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
28
18
 
29
19
  # field :blocksets do
30
20
  # read_only true
@@ -11,17 +11,7 @@ module Enjoy
11
11
 
12
12
  field :blocks
13
13
 
14
- fields.each_pair do |name, type|
15
- if type.nil?
16
- field name
17
- else
18
- if type.is_a?(Array)
19
- field name, type[0], &type[1]
20
- else
21
- field name, type
22
- end
23
- end
24
- end
14
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
25
15
 
26
16
  # field :blocks do
27
17
  # read_only true
@@ -19,17 +19,7 @@ module Enjoy
19
19
  jcrop_options :og_image_jcrop_options
20
20
  end
21
21
 
22
- fields.each_pair do |name, type|
23
- if type.nil?
24
- field name
25
- else
26
- if type.is_a?(Array)
27
- field name, type[0], &type[1]
28
- else
29
- field name, type
30
- end
31
- end
32
- end
22
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
33
23
 
34
24
  if block_given?
35
25
  yield self
@@ -17,17 +17,7 @@ module Enjoy
17
17
  end
18
18
  field :sitemap_priority
19
19
 
20
- fields.each_pair do |name, type|
21
- if type.nil?
22
- field name
23
- else
24
- if type.is_a?(Array)
25
- field name, type[0], &type[1]
26
- else
27
- field name, type
28
- end
29
- end
30
- end
20
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
31
21
 
32
22
  if block_given?
33
23
  yield self
@@ -28,8 +28,6 @@ module Enjoy
28
28
  attr_accessor :contacts_message_required
29
29
  attr_accessor :contacts_captcha_error_message
30
30
 
31
- attr_accessor :separate_seo_table
32
-
33
31
  attr_accessor :localize
34
32
 
35
33
  attr_accessor :recreate_contact_message_action
@@ -61,8 +59,6 @@ module Enjoy
61
59
 
62
60
  @localize = false
63
61
 
64
- @separate_seo_table = false
65
-
66
62
  @routes_config = {
67
63
  use_contacts_path: true,
68
64
  use_search_path: true,
@@ -0,0 +1,25 @@
1
+ module RailsAdmin
2
+ module Config
3
+ module Fields
4
+ module Types
5
+ class EnjoyHash < RailsAdmin::Config::Fields::Types::Text
6
+ # Register field type for the type loader
7
+ RailsAdmin::Config::Fields::Types::register(self)
8
+ include RailsAdmin::Engine.routes.url_helpers
9
+
10
+ register_instance_option :string_method do
11
+ "#{name}_str"
12
+ end
13
+
14
+ register_instance_option :allowed_methods do
15
+ [string_method]
16
+ end
17
+
18
+ register_instance_option :partial do
19
+ :enjoy_hash
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ module Enjoy::RailsAdminGroupPatch
2
+ class << self
3
+ def enjoy_cms_group(config, fields = {})
4
+ return unless fields
5
+
6
+ if fields.is_a?(Array)
7
+ fields.each do |_group|
8
+ config.group _group[:name] do
9
+ active (_group[:active] || false)
10
+ _group[:fields].each_pair do |name, type|
11
+ if type.nil?
12
+ field name
13
+ else
14
+ if type.is_a?(Array)
15
+ field name, type[0], &type[1]
16
+ else
17
+ field name, type
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ else
24
+ fields.each_pair do |name, type|
25
+ if type.nil?
26
+ config.field name
27
+ else
28
+ if type.is_a?(Array)
29
+ config.field name, type[0], &type[1]
30
+ else
31
+ config.field name, type
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.3.2.1"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -9,6 +9,8 @@ require 'devise'
9
9
  require 'simple_form'
10
10
  require 'enjoy/simple_form_patch'
11
11
 
12
+ require 'geocoder'
13
+
12
14
  require 'glebtv-simple_captcha'
13
15
  require 'validates_email_format_of'
14
16
  require 'smart_excerpt'
@@ -35,6 +37,8 @@ require 'enjoy/elastic_search'
35
37
  require 'enjoy/model'
36
38
  require 'enjoy/rails_admin_menu'
37
39
  require 'enjoy/rails_admin_enjoy_html'
40
+ require 'enjoy/rails_admin_enjoy_hash'
41
+ require 'enjoy/rails_admin_group_patch'
38
42
  require 'enjoy/engine'
39
43
  require 'enjoy/controller'
40
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -448,6 +448,7 @@ files:
448
448
  - app/models/concerns/enjoy/decorators/sitemap_data.rb
449
449
  - app/models/concerns/enjoy/enableable.rb
450
450
  - app/models/concerns/enjoy/geocodeable.rb
451
+ - app/models/concerns/enjoy/hash_field.rb
451
452
  - app/models/concerns/enjoy/html_field.rb
452
453
  - app/models/concerns/enjoy/mappable.rb
453
454
  - app/models/concerns/enjoy/model_localizeable.rb
@@ -492,6 +493,7 @@ files:
492
493
  - app/views/errors/error_500.html.slim
493
494
  - app/views/layouts/application.html.slim
494
495
  - app/views/rails_admin/main/_check_boxes.html.slim
496
+ - app/views/rails_admin/main/_enjoy_hash.html.slim
495
497
  - app/views/rails_admin/main/_enjoy_html.html.slim
496
498
  - app/views/rails_admin/main/_enum_check_boxes.html.slim
497
499
  - app/views/rails_admin/main/_enum_radio_buttons.html.slim
@@ -572,7 +574,9 @@ files:
572
574
  - lib/enjoy/models/page_blockset.rb
573
575
  - lib/enjoy/models/seo.rb
574
576
  - lib/enjoy/models/sitemap_data.rb
577
+ - lib/enjoy/rails_admin_enjoy_hash.rb
575
578
  - lib/enjoy/rails_admin_enjoy_html.rb
579
+ - lib/enjoy/rails_admin_group_patch.rb
576
580
  - lib/enjoy/rails_admin_menu.rb
577
581
  - lib/enjoy/simple_form_patch.rb
578
582
  - lib/enjoy/tasks.rb