hancock_cms_pages 1.0.0 → 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 +4 -4
- data/app/controllers/concerns/hancock/pages/blocksetable.rb +48 -14
- data/app/controllers/concerns/hancock/pages/localizeable.rb +5 -5
- data/app/controllers/concerns/hancock/pages/nav_menu.rb +10 -5
- data/app/controllers/concerns/hancock/pages/seo_pages.rb +3 -3
- data/app/helpers/hancock/pages/blocksets_helper.rb +26 -0
- data/app/helpers/hancock/pages/pages_helper.rb +11 -0
- data/app/models/concerns/hancock/pages/connectable.rb +1 -1
- data/app/views/blocks/_cached_blockset_navigation.html.slim +26 -0
- data/app/views/blocks/_cached_navigation.html.slim +26 -0
- data/app/views/blocks/_header.html.slim +9 -1
- data/app/views/hancock/pages/pages/show.html.slim +14 -1
- data/app/views/shared/_obj.html.slim +21 -25
- data/config/locales/hancock.pages.ru.yml +5 -0
- data/hancock_cms_pages.gemspec +3 -3
- data/lib/generators/hancock/pages/config/{install_generator.rb → config_generator.rb} +0 -0
- data/lib/generators/hancock/pages/config/templates/hancock_pages.erb +19 -6
- data/lib/generators/hancock/pages/controllers/decorators_generator.rb +24 -0
- data/lib/generators/hancock/pages/{migration_generator.rb → migrations/migrations_generator.rb} +3 -3
- data/lib/generators/hancock/pages/{templates → migrations/templates}/migration_blocks.rb +0 -0
- data/lib/generators/hancock/pages/{templates → migrations/templates}/migration_pages.rb +0 -0
- data/lib/generators/hancock/pages/models/templates/block.erb +5 -5
- data/lib/generators/hancock/pages/models/templates/blockset.erb +5 -5
- data/lib/generators/hancock/pages/models/templates/menu.erb +5 -5
- data/lib/generators/hancock/pages/models/templates/page.erb +7 -7
- data/lib/hancock/pages/admin.rb +35 -8
- data/lib/hancock/pages/admin/block.rb +14 -1
- data/lib/hancock/pages/admin/blockset.rb +34 -11
- data/lib/hancock/pages/admin/menu.rb +3 -1
- data/lib/hancock/pages/admin/page.rb +35 -5
- data/lib/hancock/pages/configuration.rb +28 -5
- data/lib/hancock/pages/controllers/pages.rb +10 -1
- data/lib/hancock/pages/engine.rb +59 -0
- data/lib/hancock/pages/models/active_record/blockset.rb +2 -1
- data/lib/hancock/pages/models/block.rb +234 -55
- data/lib/hancock/pages/models/blockset.rb +50 -38
- data/lib/hancock/pages/models/menu.rb +24 -15
- data/lib/hancock/pages/models/mongoid/block.rb +13 -0
- data/lib/hancock/pages/models/mongoid/blockset.rb +3 -0
- data/lib/hancock/pages/models/mongoid/menu.rb +4 -1
- data/lib/hancock/pages/models/mongoid/page.rb +19 -6
- data/lib/hancock/pages/models/page.rb +196 -90
- data/lib/hancock/pages/rails_admin_ext/hancock_connectable.rb +2 -0
- data/lib/hancock/pages/rails_admin_ext/menu.rb +11 -7
- data/lib/hancock/pages/version.rb +1 -1
- data/lib/hancock/pages/views_whitelist.rb +103 -0
- data/lib/hancock_cms_pages.rb +4 -6
- data/release.sh +1 -1
- metadata +19 -14
- data/app/helpers/hancock/pages/pages_helpers.rb +0 -2
@@ -11,15 +11,62 @@ module Hancock::Pages
|
|
11
11
|
included do
|
12
12
|
manual_slug :name
|
13
13
|
|
14
|
-
def
|
14
|
+
def render(view = Hancock::Pages::PagesController.new, content = "")
|
15
|
+
if view.is_a?(Hash)
|
16
|
+
view, content = view[:view] || Hancock::Pages::PagesController.new, view[:content]
|
17
|
+
end
|
18
|
+
Hancock::Pages.config.renderer_lib_extends.each do |lib_extends|
|
19
|
+
unless view.class < lib_extends
|
20
|
+
if view.respond_to?(:prepend)
|
21
|
+
view.prepend lib_extends
|
22
|
+
else
|
23
|
+
view.extend lib_extends
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ret = content
|
29
|
+
if use_wrapper
|
30
|
+
_attrs = {
|
31
|
+
class: wrapper_class,
|
32
|
+
id: wrapper_id
|
33
|
+
}.merge(wrapper_attributes)
|
34
|
+
ret = view.content_tag wrapper_tag, ret, _attrs
|
35
|
+
end
|
36
|
+
ret = yield ret if block_given?
|
37
|
+
return ret
|
38
|
+
end
|
39
|
+
|
40
|
+
def wrapper_attributes=(val)
|
41
|
+
if val.is_a? (String)
|
42
|
+
begin
|
43
|
+
begin
|
44
|
+
self[:wrapper_attributes] = JSON.parse(val)
|
45
|
+
rescue
|
46
|
+
self[:wrapper_attributes] = YAML.load(val)
|
47
|
+
end
|
48
|
+
rescue
|
49
|
+
end
|
50
|
+
elsif val.is_a?(Hash)
|
51
|
+
self[:wrapper_attributes] = val
|
52
|
+
else
|
53
|
+
self[:wrapper_attributes] = wrapper_attributes
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
class_methods do
|
61
|
+
def manager_can_add_actions
|
15
62
|
ret = [:sort_embedded]
|
16
63
|
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
17
64
|
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
18
|
-
ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
65
|
+
# ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
19
66
|
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
20
67
|
ret.freeze
|
21
68
|
end
|
22
|
-
def
|
69
|
+
def rails_admin_add_visible_actions
|
23
70
|
ret = [:sort_embedded]
|
24
71
|
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
25
72
|
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
@@ -29,41 +76,6 @@ module Hancock::Pages
|
|
29
76
|
end
|
30
77
|
end
|
31
78
|
|
32
|
-
|
33
|
-
def render(view, content = "")
|
34
|
-
if view.is_a?(Hash)
|
35
|
-
view, content = view[:view], view[:content]
|
36
|
-
end
|
37
|
-
ret = content
|
38
|
-
if use_wrapper
|
39
|
-
_attrs = {
|
40
|
-
class: wrapper_class,
|
41
|
-
id: wrapper_id
|
42
|
-
}.merge(wrapper_attributes)
|
43
|
-
ret = view.content_tag wrapper_tag, ret, _attrs
|
44
|
-
end
|
45
|
-
ret = yield ret if block_given?
|
46
|
-
return ret
|
47
|
-
end
|
48
|
-
|
49
|
-
def wrapper_attributes=(val)
|
50
|
-
if val.is_a? (String)
|
51
|
-
begin
|
52
|
-
begin
|
53
|
-
self[:wrapper_attributes] = JSON.parse(val)
|
54
|
-
rescue
|
55
|
-
self[:wrapper_attributes] = YAML.load(val)
|
56
|
-
end
|
57
|
-
rescue
|
58
|
-
end
|
59
|
-
elsif val.is_a?(Hash)
|
60
|
-
self[:wrapper_attributes] = val
|
61
|
-
else
|
62
|
-
self[:wrapper_attributes] = wrapper_attributes
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
@@ -6,41 +6,50 @@ module Hancock::Pages
|
|
6
6
|
include Hancock::Enableable
|
7
7
|
include ManualSlug
|
8
8
|
|
9
|
-
|
9
|
+
if Hancock::Pages.config.cache_support
|
10
|
+
include Hancock::Cache::Cacheable
|
11
|
+
end
|
10
12
|
|
11
13
|
include Hancock::Pages.orm_specific('Menu')
|
12
14
|
|
13
15
|
included do
|
14
|
-
def self.default_cache_keys
|
15
|
-
['menus']
|
16
|
-
end
|
17
16
|
|
18
17
|
manual_slug :name
|
19
18
|
|
20
|
-
def
|
19
|
+
def page_class
|
20
|
+
self.class.page_class
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class_methods do
|
25
|
+
if Hancock::Pages.config.cache_support
|
26
|
+
def default_cache_keys
|
27
|
+
['menus']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def page_class
|
32
|
+
Hancock::Pages::Page
|
33
|
+
end
|
34
|
+
|
35
|
+
def manager_can_add_actions
|
21
36
|
ret = []
|
22
37
|
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
23
38
|
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
24
|
-
ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
39
|
+
# ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
40
|
+
ret << :hancock_touch if Hancock::Pages.config.cache_support
|
25
41
|
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
26
42
|
ret.freeze
|
27
43
|
end
|
28
|
-
def
|
44
|
+
def rails_admin_add_visible_actions
|
29
45
|
ret = []
|
30
46
|
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
31
47
|
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
32
48
|
ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
49
|
+
ret << :hancock_touch if Hancock::Pages.config.cache_support
|
33
50
|
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
34
51
|
ret.freeze
|
35
52
|
end
|
36
|
-
|
37
|
-
def self.page_class
|
38
|
-
Hancock::Pages::Page
|
39
|
-
end
|
40
|
-
|
41
|
-
def page_class
|
42
|
-
self.class.page_class
|
43
|
-
end
|
44
53
|
end
|
45
54
|
|
46
55
|
end
|
@@ -15,6 +15,19 @@ module Hancock::Pages
|
|
15
15
|
field :render_file, type: Boolean, default: true
|
16
16
|
embedded_in :blockset, inverse_of: :blocks, class_name: "Hancock::Pages::Blockset"
|
17
17
|
|
18
|
+
validates_inclusion_of :file_path, in: proc {
|
19
|
+
# Settings.hancock_pages_blocks_whitelist.lines.map(&:strip).compact
|
20
|
+
# Hancock::Pages.whitelist_as_array.compact
|
21
|
+
(Hancock::Pages.whitelist_as_array - Hancock::Pages.blacklist_as_array).compact
|
22
|
+
}, allow_blank: true
|
23
|
+
# validates_inclusion_of :file_path, in: proc {
|
24
|
+
# Hancock::Pages::Blockset.settings.blocks_whitelist.lines.map(&:strip).compact
|
25
|
+
# }, allow_blank: true
|
26
|
+
|
27
|
+
def self.find(id)
|
28
|
+
find_through(Hancock::Pages::Blockset, 'blocks', id)
|
29
|
+
end
|
30
|
+
|
18
31
|
hancock_cms_html_field :content, type: String, localize: Hancock::Pages.config.localize, default: ""
|
19
32
|
|
20
33
|
field :use_wrapper, type: Boolean, default: false
|
@@ -5,6 +5,8 @@ module Hancock::Pages
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
+
index({enabled: 1, name: 1}, {background: true})
|
9
|
+
|
8
10
|
field :name, type: String, default: "", overwrite: true
|
9
11
|
|
10
12
|
embeds_many :blocks, inverse_of: :blockset, class_name: "Hancock::Pages::Block"
|
@@ -16,6 +18,7 @@ module Hancock::Pages
|
|
16
18
|
field :wrapper_id, type: String, default: ""
|
17
19
|
field :wrapper_attributes, type: Hash, default: {}
|
18
20
|
end
|
21
|
+
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -5,11 +5,14 @@ module Hancock::Pages
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
8
|
+
index({enabled: 1, name: 1}, {background: true})
|
9
|
+
|
10
|
+
has_and_belongs_to_many :pages, inverse_of: :menus, class_name: "Hancock::Pages::Page", index: true
|
9
11
|
alias_method :items, :pages
|
10
12
|
|
11
13
|
field :name, type: String, default: "", overwrite: true
|
12
14
|
end
|
15
|
+
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -7,24 +7,30 @@ module Hancock::Pages
|
|
7
7
|
include Hancock::HtmlField
|
8
8
|
|
9
9
|
included do
|
10
|
+
index({enabled: 1, lft: 1, menu_ids: 1}, {background: true})
|
11
|
+
index({parent_id: 1}, {background: true})
|
12
|
+
index({hancock_connectable_id: 1, hancock_connectable_type: 1}, {background: true})
|
13
|
+
index({enabled: 1, fullpath: 1}, {background: true})
|
14
|
+
|
10
15
|
scope :connected, -> {
|
11
|
-
where(:
|
16
|
+
where(:hancock_connectable_id.ne => nil)
|
12
17
|
}
|
13
18
|
scope :unconnected, -> (except_this = nil) {
|
14
19
|
if except_this
|
15
20
|
where({"$or" =>[
|
16
|
-
{:
|
21
|
+
{:hancock_connectable_id => nil},
|
17
22
|
{"$and" => [
|
18
|
-
{
|
19
|
-
{
|
23
|
+
{hancock_connectable_type: except_this.class.to_param},
|
24
|
+
{hancock_connectable_id: except_this._id}
|
20
25
|
]}
|
21
26
|
]})
|
22
27
|
else
|
23
|
-
where(:
|
28
|
+
where(:hancock_connectable_id => nil)
|
24
29
|
end
|
25
30
|
}
|
26
31
|
|
27
32
|
field :name, type: String, localize: Hancock::Pages.config.localize, default: ""
|
33
|
+
field :layout_name, type: String, default: "application"
|
28
34
|
|
29
35
|
field :regexp, type: String, default: ""
|
30
36
|
field :redirect, type: String, default: ""
|
@@ -32,11 +38,18 @@ module Hancock::Pages
|
|
32
38
|
hancock_cms_html_field :content, type: String, localize: Hancock::Pages.config.localize, default: ""
|
33
39
|
field :fullpath, type: String, default: ""
|
34
40
|
|
35
|
-
|
41
|
+
field :use_wrapper, type: Boolean, default: false
|
42
|
+
field :wrapper_tag, type: String, default: ""
|
43
|
+
field :wrapper_class, type: String, default: ""
|
44
|
+
field :wrapper_id, type: String, default: ""
|
45
|
+
field :wrapper_attributes, type: Hash, default: {}
|
46
|
+
|
47
|
+
has_and_belongs_to_many :menus, inverse_of: :pages, class_name: "Hancock::Pages::Menu", index: true
|
36
48
|
|
37
49
|
scope :sorted, -> { order_by([:lft, :asc]) }
|
38
50
|
scope :menu, ->(menu_id) { enabled.sorted.where(menu_ids: menu_id) }
|
39
51
|
end
|
52
|
+
|
40
53
|
end
|
41
54
|
end
|
42
55
|
end
|
@@ -10,6 +10,13 @@ module Hancock::Pages
|
|
10
10
|
include Hancock::Seo::SitemapDataField
|
11
11
|
end
|
12
12
|
|
13
|
+
if Hancock::Pages.config.cache_support
|
14
|
+
include Hancock::Cache::Cacheable
|
15
|
+
end
|
16
|
+
if Hancock::Pages.config.insertions_support
|
17
|
+
include Hancock::InsertionField
|
18
|
+
end
|
19
|
+
|
13
20
|
include Hancock::Pages.orm_specific('Page')
|
14
21
|
|
15
22
|
# if Hancock.config.search_enabled
|
@@ -28,130 +35,229 @@ module Hancock::Pages
|
|
28
35
|
|
29
36
|
|
30
37
|
if Hancock.rails4?
|
31
|
-
belongs_to :
|
38
|
+
belongs_to :hancock_connectable, polymorphic: true
|
32
39
|
else
|
33
|
-
belongs_to :
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.goto_hancock
|
37
|
-
self.where(connectable_type: /^Enjoy/).all.map { |s|
|
38
|
-
s.connectable_type = s.connectable_type.sub("Enjoy", "Hancock");
|
39
|
-
s.save
|
40
|
-
}
|
40
|
+
belongs_to :hancock_connectable, polymorphic: true, optional: true
|
41
41
|
end
|
42
42
|
|
43
43
|
before_save do
|
44
|
-
self.
|
45
|
-
self.
|
44
|
+
self.hancock_connectable_id = nil if self.hancock_connectable_id.nil?
|
45
|
+
self.hancock_connectable_type = nil if self.hancock_connectable_type.nil?
|
46
46
|
self
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
53
|
-
ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
54
|
-
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
55
|
-
ret.freeze
|
49
|
+
if Hancock::Pages.config.insertions_support
|
50
|
+
insertions_for(:excerpt_html)
|
51
|
+
insertions_for(:content_html)
|
56
52
|
end
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
def page_excerpt(view = Hancock::Pages::PagesController.new)
|
54
|
+
if @excerpt_used.nil?
|
55
|
+
if excerpt.nil?
|
56
|
+
@excerpt_used = true
|
57
|
+
''
|
58
|
+
else
|
59
|
+
view.extend ActionView::Helpers::TagHelper
|
60
|
+
view.extend ActionView::Context
|
61
|
+
# {{BS|%blockset_name%}}
|
62
|
+
# excerpt.gsub(/\{\{(.*?)\}\}/) do
|
63
|
+
_excerpt = excerpt.gsub(/\{\{BS\|(.*?)\}\}/) do
|
64
|
+
bs = Hancock::Pages::Blockset.enabled.where(name: $1).first
|
65
|
+
if bs
|
66
|
+
begin
|
67
|
+
view.render_blockset(bs, called_from: {object: self, method: :page_excerpt})
|
68
|
+
rescue Exception => exception
|
69
|
+
if Hancock::Pages.config.verbose_render
|
70
|
+
Rails.logger.error exception.message
|
71
|
+
Rails.logger.error exception.backtrace.join("\n")
|
72
|
+
puts exception.message
|
73
|
+
puts exception.backtrace.join("\n")
|
74
|
+
end
|
75
|
+
Raven.capture_exception(exception) if Hancock::Pages.config.raven_support
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# {{self.%insertion%}}
|
80
|
+
end.gsub(/(\{\{self\.(.*?)\}\})/) do
|
81
|
+
if Hancock::Pages.config.insertions_support
|
82
|
+
get_insertion($2)
|
83
|
+
else
|
84
|
+
$1
|
85
|
+
end
|
86
|
+
|
87
|
+
# {{"some_text"}} #temporary disabled - need tests
|
88
|
+
# {{"some_text"}}
|
89
|
+
# end.gsub(/\{\{(\'|\"|"|')(.*?)(\1)\}\}/) do
|
90
|
+
# $2
|
91
|
+
|
92
|
+
# {{%ns%.%key%}}
|
93
|
+
end.gsub(/\{\{(([^\.]*?)\.)?(.*?)\}\}/) do
|
94
|
+
(Settings and !$3.nil? and $2 != "self") ? Settings.ns($2).get($3).val : "" #temp
|
95
|
+
end
|
96
|
+
@excerpt_used = true
|
97
|
+
_excerpt
|
98
|
+
end
|
99
|
+
else
|
100
|
+
''
|
101
|
+
end
|
64
102
|
end
|
65
|
-
end
|
66
103
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
104
|
+
def page_content(view = Hancock::Pages::PagesController.new)
|
105
|
+
if @content_used.nil?
|
106
|
+
if content.nil?
|
107
|
+
@content_used = true
|
108
|
+
''
|
109
|
+
else
|
110
|
+
view.extend ActionView::Helpers::TagHelper
|
111
|
+
view.extend ActionView::Context
|
73
112
|
|
74
|
-
|
75
|
-
|
76
|
-
|
113
|
+
# {{BS|%blockset_name%}}
|
114
|
+
# content.gsub(/\{\{(.*?)\}\}/) do
|
115
|
+
_content = content.gsub(/\{\{BS\|(.*?)\}\}/) do
|
116
|
+
bs = Hancock::Pages::Blockset.enabled.where(name: $1).first
|
117
|
+
if bs
|
118
|
+
begin
|
119
|
+
view.render_blockset(bs, called_from: {object: self, method: :page_content})
|
120
|
+
rescue Exception => exception
|
121
|
+
if Hancock::Pages.config.verbose_render
|
122
|
+
Rails.logger.error exception.message
|
123
|
+
Rails.logger.error exception.backtrace.join("\n")
|
124
|
+
puts exception.message
|
125
|
+
puts exception.backtrace.join("\n")
|
126
|
+
end
|
127
|
+
Raven.capture_exception(exception) if Hancock::Pages.config.raven_support
|
128
|
+
end
|
129
|
+
end
|
77
130
|
|
131
|
+
# {{self.%insertion%}}
|
132
|
+
end.gsub(/(\{\{self\.(.*?)\}\})/) do
|
133
|
+
if Hancock::Pages.config.insertions_support
|
134
|
+
get_insertion($2)
|
135
|
+
else
|
136
|
+
$1
|
137
|
+
end
|
78
138
|
|
79
|
-
|
80
|
-
|
81
|
-
|
139
|
+
# {{"some_text"}} #temporary disabled - need tests
|
140
|
+
# end.gsub(/\{\{(['"])(.*?)(\1)\}\}/) do
|
141
|
+
# end.gsub(/\{\{(\'|\"|"|')(.*?)(\1)\}\}/) do
|
142
|
+
# $2
|
82
143
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
''
|
88
|
-
else
|
89
|
-
# excerpt.gsub(/\{\{(.*?)\}\}/) do
|
90
|
-
excerpt.gsub(/\{\{(([^\.]*?)\.)?(.*?)\}\}/) do
|
91
|
-
(Settings and !$3.nil?) ? Settings.ns($2).get($3).val : "" #temp
|
144
|
+
# {{%ns%.%key%}}
|
145
|
+
end.gsub(/\{\{(([^\.]*?)\.)?(.*?)\}\}/) do
|
146
|
+
((Settings and !$3.nil? and $2 != "self") ? Settings.ns($2).get($3).val : "") rescue "" #temp
|
147
|
+
end
|
92
148
|
end
|
149
|
+
@content_used = true
|
150
|
+
_content
|
151
|
+
else
|
152
|
+
''
|
93
153
|
end
|
94
|
-
else
|
95
|
-
''
|
96
154
|
end
|
97
|
-
end
|
98
155
|
|
156
|
+
def page_h1
|
157
|
+
_ret = seo ? seo.h1 : nil
|
158
|
+
_ret = name if _ret.blank?
|
159
|
+
_ret = title if _ret.blank?
|
160
|
+
_ret
|
161
|
+
end
|
162
|
+
|
163
|
+
def get_fullpath
|
164
|
+
redirect.blank? ? fullpath : redirect
|
165
|
+
end
|
99
166
|
|
100
|
-
|
101
|
-
|
102
|
-
|
167
|
+
def has_excerpt?
|
168
|
+
@excerpt_used.nil? && !excerpt.blank?
|
169
|
+
end
|
103
170
|
|
104
|
-
|
105
|
-
|
106
|
-
@content_used
|
107
|
-
|
108
|
-
|
171
|
+
|
172
|
+
def has_content?
|
173
|
+
@content_used.nil? && !content.blank?
|
174
|
+
end
|
175
|
+
|
176
|
+
def is_current?(url)
|
177
|
+
if fullpath == '/'
|
178
|
+
url == '/'
|
109
179
|
else
|
110
|
-
|
111
|
-
|
112
|
-
|
180
|
+
url.match(clean_regexp)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def regexp_prefix
|
185
|
+
Hancock::Pages.config.localize ? "(?:#{I18n.available_locales.map { |l| "\\/#{l}"}.join("|")})?" : ""
|
186
|
+
end
|
187
|
+
|
188
|
+
def clean_regexp
|
189
|
+
if regexp.blank?
|
190
|
+
/^#{regexp_prefix}#{Regexp.escape(fullpath)}$/
|
191
|
+
else
|
192
|
+
begin
|
193
|
+
/#{regexp}/
|
194
|
+
rescue
|
195
|
+
# not a valid regexp - treat as literal search string
|
196
|
+
/#{Regexp.escape(regexp)}/
|
113
197
|
end
|
114
198
|
end
|
115
|
-
else
|
116
|
-
''
|
117
199
|
end
|
118
|
-
end
|
119
200
|
|
120
|
-
|
121
|
-
|
122
|
-
url == '/'
|
123
|
-
else
|
124
|
-
url.match(clean_regexp)
|
201
|
+
def nav_options
|
202
|
+
nav_options_default.merge(nav_options_additions)
|
125
203
|
end
|
126
|
-
end
|
127
204
|
|
128
|
-
|
129
|
-
|
130
|
-
|
205
|
+
def nav_options_default
|
206
|
+
{highlights_on: clean_regexp}
|
207
|
+
end
|
131
208
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
209
|
+
def nav_options_additions
|
210
|
+
{}
|
211
|
+
end
|
212
|
+
|
213
|
+
def wrapper_attributes=(val)
|
214
|
+
if val.is_a? (String)
|
215
|
+
begin
|
216
|
+
begin
|
217
|
+
self[:wrapper_attributes] = JSON.parse(val)
|
218
|
+
rescue
|
219
|
+
self[:wrapper_attributes] = YAML.load(val)
|
220
|
+
end
|
221
|
+
rescue
|
222
|
+
end
|
223
|
+
elsif val.is_a?(Hash)
|
224
|
+
self[:wrapper_attributes] = val
|
225
|
+
else
|
226
|
+
self[:wrapper_attributes] = wrapper_attributes
|
141
227
|
end
|
142
228
|
end
|
143
|
-
end
|
144
229
|
|
145
|
-
def nav_options
|
146
|
-
nav_options_default.merge(nav_options_additions)
|
147
230
|
end
|
148
231
|
|
149
|
-
def nav_options_default
|
150
|
-
{highlights_on: clean_regexp}
|
151
|
-
end
|
152
232
|
|
153
|
-
|
154
|
-
|
233
|
+
class_methods do
|
234
|
+
|
235
|
+
def goto_hancock
|
236
|
+
self.where(hancock_connectable_type: /^Enjoy/).all.map { |s|
|
237
|
+
s.hancock_connectable_type = s.hancock_connectable_type.sub("Enjoy", "Hancock");
|
238
|
+
s.save
|
239
|
+
}
|
240
|
+
end
|
241
|
+
|
242
|
+
def manager_can_add_actions
|
243
|
+
ret = [:nested_set]
|
244
|
+
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
245
|
+
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
246
|
+
# ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
247
|
+
ret << :hancock_touch if Hancock::Pages.config.cache_support
|
248
|
+
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
249
|
+
ret.freeze
|
250
|
+
end
|
251
|
+
def rails_admin_add_visible_actions
|
252
|
+
ret = [:nested_set]
|
253
|
+
# ret += [:multiple_file_upload, :sort_embedded] if Hancock::Pages.mongoid?
|
254
|
+
ret << :model_settings if Hancock::Pages.config.model_settings_support
|
255
|
+
ret << :model_accesses if Hancock::Pages.config.user_abilities_support
|
256
|
+
ret << :hancock_touch if Hancock::Pages.config.cache_support
|
257
|
+
ret += [:comments, :model_comments] if Hancock::Pages.config.ra_comments_support
|
258
|
+
ret.freeze
|
259
|
+
end
|
260
|
+
|
155
261
|
end
|
156
262
|
|
157
263
|
end
|