hancock_cms_seo 1.0.2
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 +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/hancock/rails_admin/plugins/seo.coffee +4 -0
- data/app/assets/javascripts/hancock/rails_admin/plugins/seo/custom/ui.coffee +0 -0
- data/app/assets/stylesheets/hancock/rails_admin/plugins/seo.sass +3 -0
- data/app/assets/stylesheets/hancock/rails_admin/plugins/seo/custom/theming.sass +0 -0
- data/app/assets/stylesheets/hancock/rails_admin/plugins/seo/footer_nav_links.sass +16 -0
- data/app/controllers/concerns/hancock/seo/x_frame_options.rb +42 -0
- data/app/helpers/hancock/seo/seo_helper.rb +60 -0
- data/app/models/concerns/hancock/seo/decorators/seo.rb +60 -0
- data/app/models/concerns/hancock/seo/decorators/sitemap_data.rb +35 -0
- data/app/models/concerns/hancock/seo/seoable.rb +71 -0
- data/app/models/concerns/hancock/seo/sitemap_data_field.rb +37 -0
- data/app/models/concerns/hancock/seo/sitemapable.rb +7 -0
- data/app/models/hancock/seo/seo.rb +16 -0
- data/app/models/hancock/seo/sitemap_data.rb +16 -0
- data/app/views/blocks/_seo_block.html.slim +25 -0
- data/app/views/blocks/_seo_block_with_obj.html.slim +18 -0
- data/app/views/hancock/seo/blocks/_ga.html.slim +8 -0
- data/app/views/hancock/seo/blocks/_ym.html.slim +31 -0
- data/app/views/shared/_meta.html.slim +28 -0
- data/app/views/shared/_obj_with_seo.html.slim +38 -0
- data/app/views/shared/_og.html.slim +4 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/hancock_seo.rb +7 -0
- data/config/locales/ru.hancock.seo.yml +37 -0
- data/hancock_cms_seo.gemspec +40 -0
- data/lib/generators/hancock/seo/config/config_generator.rb +13 -0
- data/lib/generators/hancock/seo/config/templates/hancock_seo.erb +10 -0
- data/lib/generators/hancock/seo/migrations/migrations_generator.rb +18 -0
- data/lib/generators/hancock/seo/migrations/templates/migration_seos.rb +48 -0
- data/lib/generators/hancock/seo/models/decorators_generator.rb +24 -0
- data/lib/generators/hancock/seo/models/seo_generator.rb +39 -0
- data/lib/generators/hancock/seo/models/sitemap_data_generator.rb +39 -0
- data/lib/generators/hancock/seo/models/templates/seo.erb +57 -0
- data/lib/generators/hancock/seo/models/templates/sitemap_data.erb +31 -0
- data/lib/generators/hancock/seo/sitemap/sitemap_generator.rb +27 -0
- data/lib/generators/hancock/seo/sitemap/templates/sitemap.erb +31 -0
- data/lib/hancock/seo/admin.rb +24 -0
- data/lib/hancock/seo/admin/seo.rb +69 -0
- data/lib/hancock/seo/admin/sitemap_data.rb +47 -0
- data/lib/hancock/seo/configuration.rb +29 -0
- data/lib/hancock/seo/engine.rb +44 -0
- data/lib/hancock/seo/models/active_record/seo.rb +14 -0
- data/lib/hancock/seo/models/active_record/sitemap_data.rb +11 -0
- data/lib/hancock/seo/models/mongoid/seo.rb +25 -0
- data/lib/hancock/seo/models/mongoid/sitemap_data.rb +24 -0
- data/lib/hancock/seo/models/seo.rb +114 -0
- data/lib/hancock/seo/models/sitemap_data.rb +79 -0
- data/lib/hancock/seo/version.rb +5 -0
- data/lib/hancock_cms_seo.rb +43 -0
- data/release.sh +6 -0
- metadata +193 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Seo::Models
|
4
|
+
class DecoratorsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../../../../../../app/models/concerns/hancock/seo/decorators', __FILE__)
|
6
|
+
argument :models, type: :array, default: []
|
7
|
+
|
8
|
+
desc 'Hancock::Seo Models decorators generator'
|
9
|
+
def decorators
|
10
|
+
copied = false
|
11
|
+
(models == ['all'] ? permitted_models : models & permitted_models).each do |m|
|
12
|
+
copied = true
|
13
|
+
copy_file "#{m}.rb", "app/models/concerns/hancock/seo/decorators/#{m}.rb"
|
14
|
+
end
|
15
|
+
puts "U need to set model`s name. One of this: #{permitted_models.join(", ")}." unless copied
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def permitted_models
|
20
|
+
['seo', 'sitemap_data']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Seo::Models
|
4
|
+
class SeoGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
|
8
|
+
desc 'Hancock::Seo Seo Model generator'
|
9
|
+
def seo
|
10
|
+
template 'seo.erb', "app/models/#{file_name}.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def class_name
|
15
|
+
class_name_arg.blank? ? "SetClassForSeo" : class_name_arg
|
16
|
+
end
|
17
|
+
|
18
|
+
def capitalized_class_name
|
19
|
+
class_name.capitalize
|
20
|
+
end
|
21
|
+
|
22
|
+
def camelcased_class_name
|
23
|
+
class_name.camelcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_name
|
27
|
+
underscored_class_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def underscored_class_name
|
31
|
+
camelcased_class_name.underscore
|
32
|
+
end
|
33
|
+
|
34
|
+
def underscored_pluralized_class_name
|
35
|
+
underscored_class_name.pluralize
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Seo::Models
|
4
|
+
class SitemapDataGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
|
8
|
+
desc 'Hancock::Seo SitemapData Model generator'
|
9
|
+
def sitemap_data
|
10
|
+
template 'sitemap_data.erb', "app/models/#{file_name}.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def class_name
|
15
|
+
class_name_arg.blank? ? "SetClassForSitemapData" : class_name_arg
|
16
|
+
end
|
17
|
+
|
18
|
+
def capitalized_class_name
|
19
|
+
class_name.capitalize
|
20
|
+
end
|
21
|
+
|
22
|
+
def camelcased_class_name
|
23
|
+
class_name.camelcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_name
|
27
|
+
underscored_class_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def underscored_class_name
|
31
|
+
camelcased_class_name.underscore
|
32
|
+
end
|
33
|
+
|
34
|
+
def underscored_pluralized_class_name
|
35
|
+
underscored_class_name.pluralize
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Seo::Seo
|
2
|
+
|
3
|
+
# # after_save :og_image_auto_rails_admin_jcrop
|
4
|
+
# def og_image_auto_rails_admin_jcrop
|
5
|
+
# auto_rails_admin_jcrop(:og_image) # or nil for cancel autocrop
|
6
|
+
# end
|
7
|
+
|
8
|
+
# # hancock_cms_attached_file(:og_image)
|
9
|
+
# def og_image_styles
|
10
|
+
# {thumb: "160x120>", standard: "800x600>"}
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# def og_image_jcrop_options
|
14
|
+
# {}
|
15
|
+
# end
|
16
|
+
|
17
|
+
|
18
|
+
def set_default_seo
|
19
|
+
_obj = self.seoable
|
20
|
+
if _obj and _obj.set_default_seo?
|
21
|
+
self.h1 = _obj.default_seo_h1 if self.h1.blank?
|
22
|
+
self.title = _obj.default_seo_title if self.title.blank?
|
23
|
+
self.keywords = _obj.default_seo_keywords if self.keywords.blank?
|
24
|
+
self.description = _obj.default_seo_description if self.description.blank?
|
25
|
+
self.title = _obj.default_seo_og_title if self.title.blank?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
############ rails_admin ##############
|
30
|
+
def self.rails_admin_add_fields
|
31
|
+
[] #super
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.rails_admin_add_config(config)
|
35
|
+
#super(config)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.admin_can_user_defined_actions
|
39
|
+
[].freeze
|
40
|
+
end
|
41
|
+
def self.admin_cannot_user_defined_actions
|
42
|
+
[].freeze
|
43
|
+
end
|
44
|
+
def self.manager_can_user_defined_actions
|
45
|
+
[].freeze
|
46
|
+
end
|
47
|
+
def self.manager_cannot_user_defined_actions
|
48
|
+
[].freeze
|
49
|
+
end
|
50
|
+
def self.rails_admin_user_defined_visible_actions
|
51
|
+
[].freeze
|
52
|
+
end
|
53
|
+
|
54
|
+
rails_admin(&Hancock::Seo::Admin::Seo.config(rails_admin_add_fields) { |config|
|
55
|
+
rails_admin_add_config(config)
|
56
|
+
})
|
57
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Seo::SitemapData
|
2
|
+
|
3
|
+
############ rails_admin ##############
|
4
|
+
def self.rails_admin_add_fields
|
5
|
+
[] #super
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.rails_admin_add_config(config)
|
9
|
+
#super(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.admin_can_user_defined_actions
|
13
|
+
[].freeze
|
14
|
+
end
|
15
|
+
def self.admin_cannot_user_defined_actions
|
16
|
+
[].freeze
|
17
|
+
end
|
18
|
+
def self.manager_can_user_defined_actions
|
19
|
+
[].freeze
|
20
|
+
end
|
21
|
+
def self.manager_cannot_user_defined_actions
|
22
|
+
[].freeze
|
23
|
+
end
|
24
|
+
def self.rails_admin_user_defined_visible_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
|
28
|
+
rails_admin(&Hancock::Seo::Admin::SitemapData.config(rails_admin_add_fields) { |config|
|
29
|
+
rails_admin_add_config(config)
|
30
|
+
})
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Seo
|
4
|
+
class SitemapGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :host_arg, type: :string
|
7
|
+
|
8
|
+
desc 'Hancock::Seo Sitemap config generator'
|
9
|
+
def sitemap
|
10
|
+
template 'sitemap.erb', "config/sitemap.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
def host
|
14
|
+
_host = host_arg.blank? ? "http://host.domain" : host_arg
|
15
|
+
if defined?(Addressable)
|
16
|
+
Addressable::URI.heuristic_parse(_host).to_s
|
17
|
+
else
|
18
|
+
if _host =~ /^https?\:\/\//
|
19
|
+
_host
|
20
|
+
else
|
21
|
+
_host = "http://#{_host}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sitemap_generator'
|
3
|
+
|
4
|
+
# saved_default_url_options_host = default_url_options[:host]
|
5
|
+
saved_default_url_options_only_path = default_url_options[:only_path]
|
6
|
+
default_url_options[:only_path] = true
|
7
|
+
# default_url_options[:host] = ""
|
8
|
+
SitemapGenerator::Sitemap.default_host = '<%= host %>'
|
9
|
+
SitemapGenerator::Sitemap.create do
|
10
|
+
|
11
|
+
Hancock::Seo::SitemapData.enabled.for_sitemap.all.to_a.each do |sd|
|
12
|
+
obj = sd.sitemap_data_field
|
13
|
+
next if(!obj or (defined?(Hancock::Pages::Page) and obj.is_a?(Hancock::Pages::Page) and obj.fullpath == "/"))
|
14
|
+
|
15
|
+
begin
|
16
|
+
_lastmod = sd.sitemap_lastmod.to_date unless sd.sitemap_lastmod.nil?
|
17
|
+
_lastmod = sd.updated_at.to_date unless sd.updated_at.nil? if _lastmod.nil?
|
18
|
+
_lastmod = sd.created_at.to_date unless sd.created_at.nil? if _lastmod.nil?
|
19
|
+
_url = obj.is_a?(Hancock::Pages::Page) ? obj.fullpath : url_for(obj)
|
20
|
+
|
21
|
+
add _url,
|
22
|
+
:lastmod => _lastmod,
|
23
|
+
:changefreq => "#{sd.sitemap_changefreq.blank? ? 'daily' : sd.sitemap_changefreq}",
|
24
|
+
:priority => (sd.sitemap_priority.nil? ? 0.9 : sd.sitemap_priority)
|
25
|
+
rescue
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
# default_url_options[:host] = saved_default_url_options_host
|
31
|
+
default_url_options[:only_path] = saved_default_url_options_only_path
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Hancock::Seo
|
2
|
+
module Admin
|
3
|
+
|
4
|
+
def self.seo_n_sitemap_block(is_active = false, options = {})
|
5
|
+
if is_active.is_a?(Hash)
|
6
|
+
is_active, options = (is_active[:active] || false), is_active
|
7
|
+
end
|
8
|
+
|
9
|
+
Proc.new {
|
10
|
+
active is_active
|
11
|
+
label options[:label] || I18n.t('hancock.seo_n_sitemap')
|
12
|
+
field :seo
|
13
|
+
field :sitemap_data
|
14
|
+
|
15
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, options[:fields] || {})
|
16
|
+
|
17
|
+
if block_given?
|
18
|
+
yield self
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Hancock::Seo
|
2
|
+
module Admin
|
3
|
+
module Seo
|
4
|
+
def self.config(nav_label = nil, fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, fields = nav_label[:nav_label], nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, fields = nil, nav_label
|
9
|
+
end
|
10
|
+
|
11
|
+
Proc.new {
|
12
|
+
navigation_label(!nav_label.blank? ? nav_label : 'SEO')
|
13
|
+
|
14
|
+
label I18n.t('hancock.seo.seo')
|
15
|
+
field :seoable do
|
16
|
+
read_only true
|
17
|
+
pretty_value do
|
18
|
+
v = bindings[:view]
|
19
|
+
[value].flatten.select(&:present?).collect do |associated|
|
20
|
+
amc = polymorphic? ? RailsAdmin.config(associated) : associated_model_config # perf optimization for non-polymorphic associations
|
21
|
+
am = amc.abstract_model
|
22
|
+
wording = associated.send(amc.object_label_method)
|
23
|
+
wording = "#{wording} (#{am.model.model_name.human})"
|
24
|
+
can_see = !am.embedded? && (show_action = v.action(:show, am, associated))
|
25
|
+
can_see ? v.link_to(wording, v.url_for(action: show_action.action_name, model_name: am.to_param, id: associated.id), class: 'pjax') : ERB::Util.html_escape(wording)
|
26
|
+
end.to_sentence.html_safe
|
27
|
+
end
|
28
|
+
end
|
29
|
+
field :h1, :string do
|
30
|
+
searchable true
|
31
|
+
end
|
32
|
+
field :title, :string do
|
33
|
+
searchable true
|
34
|
+
end
|
35
|
+
field :author, :string do
|
36
|
+
searchable true
|
37
|
+
end
|
38
|
+
field :keywords, :text do
|
39
|
+
searchable true
|
40
|
+
end
|
41
|
+
field :description, :text do
|
42
|
+
searchable true
|
43
|
+
end
|
44
|
+
field :robots, :string do
|
45
|
+
searchable true
|
46
|
+
end
|
47
|
+
|
48
|
+
field :og_title, :string do
|
49
|
+
searchable true
|
50
|
+
end
|
51
|
+
|
52
|
+
if Hancock::Seo.config.gallery_support
|
53
|
+
field :og_image, :hancock_image
|
54
|
+
end
|
55
|
+
|
56
|
+
if Hancock::Seo.config.cache_support
|
57
|
+
group :caching, &Hancock::Cache::Admin.caching_block
|
58
|
+
end
|
59
|
+
|
60
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
61
|
+
|
62
|
+
if block_given?
|
63
|
+
yield self
|
64
|
+
end
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Hancock::Seo
|
2
|
+
module Admin
|
3
|
+
module SitemapData
|
4
|
+
def self.config(nav_label = nil, fields = {})
|
5
|
+
if nav_label.is_a?(Hash)
|
6
|
+
nav_label, fields = nav_label[:nav_label], nav_label
|
7
|
+
elsif nav_label.is_a?(Array)
|
8
|
+
nav_label, fields = nil, nav_label
|
9
|
+
end
|
10
|
+
|
11
|
+
Proc.new {
|
12
|
+
navigation_label(!nav_label.blank? ? nav_label : 'SEO')
|
13
|
+
|
14
|
+
label I18n.t('hancock.seo.sitemap_data')
|
15
|
+
field :sitemap_data_field do
|
16
|
+
read_only true
|
17
|
+
pretty_value do
|
18
|
+
v = bindings[:view]
|
19
|
+
[value].flatten.select(&:present?).collect do |associated|
|
20
|
+
amc = polymorphic? ? RailsAdmin.config(associated) : associated_model_config # perf optimization for non-polymorphic associations
|
21
|
+
am = amc.abstract_model
|
22
|
+
wording = associated.send(amc.object_label_method)
|
23
|
+
wording = "#{wording} (#{am.model.model_name.human})"
|
24
|
+
can_see = !am.embedded? && (show_action = v.action(:show, am, associated))
|
25
|
+
can_see ? v.link_to(wording, v.url_for(action: show_action.action_name, model_name: am.to_param, id: associated.id), class: 'pjax') : ERB::Util.html_escape(wording)
|
26
|
+
end.to_sentence.html_safe
|
27
|
+
end
|
28
|
+
end
|
29
|
+
field :sitemap_show, :toggle
|
30
|
+
field :sitemap_lastmod
|
31
|
+
field :sitemap_changefreq, :enum do
|
32
|
+
enum do
|
33
|
+
Hancock::Seo::SitemapData::SITEMAP_CHANGEFREQ_ARRAY
|
34
|
+
end
|
35
|
+
end
|
36
|
+
field :sitemap_priority
|
37
|
+
|
38
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
39
|
+
|
40
|
+
if block_given?
|
41
|
+
yield self
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Hancock::Seo
|
2
|
+
include Hancock::PluginConfiguration
|
3
|
+
|
4
|
+
def self.config_class
|
5
|
+
Configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
attr_accessor :localize
|
10
|
+
|
11
|
+
attr_accessor :gallery_support
|
12
|
+
attr_accessor :cache_support
|
13
|
+
|
14
|
+
attr_accessor :model_settings_support
|
15
|
+
attr_accessor :user_abilities_support
|
16
|
+
attr_accessor :ra_comments_support
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@localize = Hancock.config.localize
|
20
|
+
|
21
|
+
@gallery_support = !!defined?(Hancock::Gallery)
|
22
|
+
@cache_support = !!defined?(Hancock::Cache)
|
23
|
+
|
24
|
+
@model_settings_support = !!defined?(RailsAdminModelSettings)
|
25
|
+
@user_abilities_support = !!defined?(RailsAdminUserAbilities)
|
26
|
+
@ra_comments_support = !!defined?(RailsAdminComments)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Hancock::Seo
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
# isolate_namespace Hancock::Seo
|
4
|
+
|
5
|
+
# rake_tasks do
|
6
|
+
# require File.expand_path('../tasks', __FILE__)
|
7
|
+
# end
|
8
|
+
|
9
|
+
# initializer "hancock_cms_seo.counters_defaults" do
|
10
|
+
# # Write default email settings to DB so they can be changed.
|
11
|
+
#
|
12
|
+
# #temp
|
13
|
+
# begin
|
14
|
+
# if Settings and Settings.table_exists?
|
15
|
+
# _cache_key = "ym_counter".freeze
|
16
|
+
# Settings.ym_counter_id(default: '', kind: :string, label: 'Yandex Метрика ID'.freeze, cache_keys: _cache_key)
|
17
|
+
# Settings.ym_counter_html(default: '', kind: :html, label: 'Yandex Метрика HTML-код'.freeze, cache_keys: _cache_key)
|
18
|
+
#
|
19
|
+
# _cache_key = "ga_counter".freeze
|
20
|
+
# Settings.ga_counter_id(default: '', kind: :string, label: 'Google Analitics ID'.freeze, cache_keys: _cache_key)
|
21
|
+
# Settings.ga_counter_html(default: '', kind: :html, label: 'Google Analitics HTML-код'.freeze, cache_keys: _cache_key)
|
22
|
+
# end
|
23
|
+
# rescue
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
config.after_initialize do
|
28
|
+
# Write default email settings to DB so they can be changed.
|
29
|
+
begin
|
30
|
+
if Settings and Settings.table_exists?
|
31
|
+
_cache_key = "ym_counter".freeze
|
32
|
+
Settings.ym_counter_id(default: '', kind: :string, label: 'Yandex Метрика ID'.freeze, cache_keys: _cache_key) unless RailsAdminSettings::Setting.ns("main").where(key: "ym_counter_id").exists?
|
33
|
+
Settings.ym_counter_html(default: '', kind: :html, label: 'Yandex Метрика HTML-код'.freeze, cache_keys: _cache_key) unless RailsAdminSettings::Setting.ns("main").where(key: "ym_counter_html").exists?
|
34
|
+
|
35
|
+
_cache_key = "ga_counter".freeze
|
36
|
+
Settings.ga_counter_id(default: '', kind: :string, label: 'Google Analitics ID'.freeze, cache_keys: _cache_key) unless RailsAdminSettings::Setting.ns("main").where(key: "ga_counter_id").exists?
|
37
|
+
Settings.ga_counter_html(default: '', kind: :html, label: 'Google Analitics HTML-код'.freeze, cache_keys: _cache_key) unless RailsAdminSettings::Setting.ns("main").where(key: "ga_counter_html").exists?
|
38
|
+
end
|
39
|
+
rescue
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|