hancock_cms_pages 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
File without changes
|
@@ -2,13 +2,26 @@ Hancock::Pages.configure do |config|
|
|
2
2
|
##### defaults #####
|
3
3
|
# config.menu_max_depth = 2
|
4
4
|
#
|
5
|
-
# config.seo_support = defined? Hancock::Seo
|
5
|
+
# config.seo_support = !!defined? Hancock::Seo
|
6
|
+
# config.cache_support = !!defined?(Hancock::Cache)
|
7
|
+
# config.insertions_support = true
|
6
8
|
#
|
7
|
-
# config.localize
|
9
|
+
# config.localize = Hancock.config.localize
|
8
10
|
#
|
9
|
-
# config.breadcrumbs_on_rails_support = defined?(BreadcrumbsOnRails)
|
11
|
+
# config.breadcrumbs_on_rails_support = !!defined?(BreadcrumbsOnRails)
|
10
12
|
#
|
11
|
-
# config.model_settings_support = defined?(RailsAdminModelSettings)
|
12
|
-
# config.user_abilities_support = defined?(RailsAdminUserAbilities)
|
13
|
-
# config.ra_comments_support = defined?(RailsAdminComments)
|
13
|
+
# config.model_settings_support = !!defined?(RailsAdminModelSettings)
|
14
|
+
# config.user_abilities_support = !!defined?(RailsAdminUserAbilities)
|
15
|
+
# config.ra_comments_support = !!defined?(RailsAdminComments)
|
16
|
+
#
|
17
|
+
# config.renderer_lib_extends = [
|
18
|
+
# # ::ActionController::Base,
|
19
|
+
# ::ActionView::Helpers::TagHelper,
|
20
|
+
# ::ActionView::Context
|
21
|
+
# ]
|
22
|
+
#
|
23
|
+
# config.verbose_render = Rails.env.development? or Rails.env.test?
|
24
|
+
# config.raven_support = !!(Hancock.config.respond_to?(:raven_support) ? Hancock.config.raven_support : defined?(Raven))
|
25
|
+
#
|
26
|
+
# config.available_layouts = ["application"]
|
14
27
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Pages::Controllers
|
4
|
+
class DecoratorsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../../../../../../app/controllers/concerns/hancock/pages/decorators', __FILE__)
|
6
|
+
argument :controllers, type: :array, default: []
|
7
|
+
|
8
|
+
desc 'Hancock::Pages Controllers generator'
|
9
|
+
def decorators
|
10
|
+
copied = false
|
11
|
+
(controllers == ['all'] ? permitted_controllers : controllers & permitted_controllers).each do |c|
|
12
|
+
copied = true
|
13
|
+
copy_file "#{c}.rb", "app/controllers/concerns/hancock/pages/decorators/#{c}.rb"
|
14
|
+
end
|
15
|
+
puts "U need to set controllers`s name. One of this: #{permitted_controllers.join(", ")}." unless copied
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def permitted_controllers
|
20
|
+
['pages']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/generators/hancock/pages/{migration_generator.rb → migrations/migrations_generator.rb}
RENAMED
@@ -2,12 +2,12 @@ require 'rails/generators'
|
|
2
2
|
require 'rails/generators/active_record'
|
3
3
|
|
4
4
|
module Hancock::Pages
|
5
|
-
class
|
5
|
+
class MigrationsGenerator < Rails::Generators::Base
|
6
6
|
include ActiveRecord::Generators::Migration
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
|
-
desc 'Hancock Pages
|
10
|
-
def
|
9
|
+
desc 'Hancock Pages migrations generator'
|
10
|
+
def migrations
|
11
11
|
if Hancock.active_record?
|
12
12
|
%w(pages blocks).each do |table_name|
|
13
13
|
migration_template "migration_#{table_name}.rb", "db/migrate/hancock_create_#{table_name}.rb"
|
File without changes
|
File without changes
|
@@ -15,19 +15,19 @@ class <%= camelcased_class_name %> < Hancock::Pages::Block
|
|
15
15
|
#super(config)
|
16
16
|
end
|
17
17
|
|
18
|
-
def admin_can_user_defined_actions
|
18
|
+
def self.admin_can_user_defined_actions
|
19
19
|
[].freeze
|
20
20
|
end
|
21
|
-
def admin_cannot_user_defined_actions
|
21
|
+
def self.admin_cannot_user_defined_actions
|
22
22
|
[].freeze
|
23
23
|
end
|
24
|
-
def manager_can_user_defined_actions
|
24
|
+
def self.manager_can_user_defined_actions
|
25
25
|
[].freeze
|
26
26
|
end
|
27
|
-
def manager_cannot_user_defined_actions
|
27
|
+
def self.manager_cannot_user_defined_actions
|
28
28
|
[].freeze
|
29
29
|
end
|
30
|
-
def rails_admin_user_defined_visible_actions
|
30
|
+
def self.rails_admin_user_defined_visible_actions
|
31
31
|
[].freeze
|
32
32
|
end
|
33
33
|
|
@@ -12,19 +12,19 @@ class <%= camelcased_class_name %> < Hancock::Pages::Blockset
|
|
12
12
|
#super(config)
|
13
13
|
end
|
14
14
|
|
15
|
-
def admin_can_user_defined_actions
|
15
|
+
def self.admin_can_user_defined_actions
|
16
16
|
[].freeze
|
17
17
|
end
|
18
|
-
def admin_cannot_user_defined_actions
|
18
|
+
def self.admin_cannot_user_defined_actions
|
19
19
|
[].freeze
|
20
20
|
end
|
21
|
-
def manager_can_user_defined_actions
|
21
|
+
def self.manager_can_user_defined_actions
|
22
22
|
[].freeze
|
23
23
|
end
|
24
|
-
def manager_cannot_user_defined_actions
|
24
|
+
def self.manager_cannot_user_defined_actions
|
25
25
|
[].freeze
|
26
26
|
end
|
27
|
-
def rails_admin_user_defined_visible_actions
|
27
|
+
def self.rails_admin_user_defined_visible_actions
|
28
28
|
[].freeze
|
29
29
|
end
|
30
30
|
|
@@ -15,19 +15,19 @@ class <%= camelcased_class_name %> < Hancock::Pages::Menu
|
|
15
15
|
#super(config)
|
16
16
|
end
|
17
17
|
|
18
|
-
def admin_can_user_defined_actions
|
18
|
+
def self.admin_can_user_defined_actions
|
19
19
|
[].freeze
|
20
20
|
end
|
21
|
-
def admin_cannot_user_defined_actions
|
21
|
+
def self.admin_cannot_user_defined_actions
|
22
22
|
[].freeze
|
23
23
|
end
|
24
|
-
def manager_can_user_defined_actions
|
24
|
+
def self.manager_can_user_defined_actions
|
25
25
|
[].freeze
|
26
26
|
end
|
27
|
-
def manager_cannot_user_defined_actions
|
27
|
+
def self.manager_cannot_user_defined_actions
|
28
28
|
[].freeze
|
29
29
|
end
|
30
|
-
def rails_admin_user_defined_visible_actions
|
30
|
+
def self.rails_admin_user_defined_visible_actions
|
31
31
|
[].freeze
|
32
32
|
end
|
33
33
|
|
@@ -3,9 +3,9 @@ class <%= camelcased_class_name %> < Hancock::Pages::Page
|
|
3
3
|
# has_and_belongs_to_many :menus, inverse_of: :pages, class_name: "Hancock::Pages::Menu"
|
4
4
|
|
5
5
|
# if Hancock.rails4?
|
6
|
-
# belongs_to :
|
6
|
+
# belongs_to :hancock_connectable, polymorphic: true, overwrite: true
|
7
7
|
# else
|
8
|
-
# belongs_to :
|
8
|
+
# belongs_to :hancock_connectable, polymorphic: true, overwrite: true, optional: true
|
9
9
|
# end
|
10
10
|
|
11
11
|
# def nav_options_additions
|
@@ -21,19 +21,19 @@ class <%= camelcased_class_name %> < Hancock::Pages::Page
|
|
21
21
|
#super(config)
|
22
22
|
end
|
23
23
|
|
24
|
-
def admin_can_user_defined_actions
|
24
|
+
def self.admin_can_user_defined_actions
|
25
25
|
[].freeze
|
26
26
|
end
|
27
|
-
def admin_cannot_user_defined_actions
|
27
|
+
def self.admin_cannot_user_defined_actions
|
28
28
|
[].freeze
|
29
29
|
end
|
30
|
-
def manager_can_user_defined_actions
|
30
|
+
def self.manager_can_user_defined_actions
|
31
31
|
[].freeze
|
32
32
|
end
|
33
|
-
def manager_cannot_user_defined_actions
|
33
|
+
def self.manager_cannot_user_defined_actions
|
34
34
|
[].freeze
|
35
35
|
end
|
36
|
-
def rails_admin_user_defined_visible_actions
|
36
|
+
def self.rails_admin_user_defined_visible_actions
|
37
37
|
[].freeze
|
38
38
|
end
|
39
39
|
|
data/lib/hancock/pages/admin.rb
CHANGED
@@ -1,21 +1,34 @@
|
|
1
1
|
module Hancock::Pages
|
2
2
|
module Admin
|
3
3
|
|
4
|
-
def self.menu_block(is_active = false)
|
4
|
+
def self.menu_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
|
+
|
5
9
|
Proc.new {
|
6
10
|
active false
|
7
|
-
label I18n.t('hancock.menu_title')
|
8
|
-
field :menus
|
11
|
+
label options[:label] || I18n.t('hancock.menu_title')
|
12
|
+
field :menus, :hancock_multiselect do
|
13
|
+
searchable :name, :text_slug
|
14
|
+
end
|
9
15
|
field :fullpath, :string do
|
10
16
|
help I18n.t('hancock.with_final_slash')
|
17
|
+
searchable true
|
11
18
|
end
|
12
19
|
field :regexp, :string do
|
13
20
|
help I18n.t('hancock.page_url_regex')
|
21
|
+
searchable true
|
14
22
|
end
|
15
23
|
field :redirect, :string do
|
16
24
|
help I18n.t('hancock.final_in_menu')
|
25
|
+
searchable true
|
26
|
+
end
|
27
|
+
field :text_slug do
|
28
|
+
searchable true
|
17
29
|
end
|
18
|
-
|
30
|
+
|
31
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, options[:fields] || {})
|
19
32
|
|
20
33
|
if block_given?
|
21
34
|
yield self
|
@@ -23,19 +36,33 @@ module Hancock::Pages
|
|
23
36
|
}
|
24
37
|
end
|
25
38
|
|
26
|
-
def self.wrapper_block(is_active = false)
|
39
|
+
def self.wrapper_block(is_active = false, options = {})
|
40
|
+
if is_active.is_a?(Hash)
|
41
|
+
is_active, options = (is_active[:active] || false), is_active
|
42
|
+
end
|
43
|
+
|
27
44
|
Proc.new {
|
28
45
|
active is_active
|
46
|
+
options[:label] and label(options[:label])
|
29
47
|
field :use_wrapper, :toggle
|
30
|
-
field :wrapper_tag, :string
|
31
|
-
|
32
|
-
|
48
|
+
field :wrapper_tag, :string do
|
49
|
+
searchable true
|
50
|
+
end
|
51
|
+
field :wrapper_class, :string do
|
52
|
+
searchable true
|
53
|
+
end
|
54
|
+
field :wrapper_id, :string do
|
55
|
+
searchable true
|
56
|
+
end
|
33
57
|
field :wrapper_attributes, :text do
|
58
|
+
searchable true
|
34
59
|
formatted_value do
|
35
60
|
bindings[:object] and bindings[:object].wrapper_attributes ? bindings[:object].wrapper_attributes.to_json : "{}"
|
36
61
|
end
|
37
62
|
end
|
38
63
|
|
64
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, options[:fields] || {})
|
65
|
+
|
39
66
|
if block_given?
|
40
67
|
yield self
|
41
68
|
end
|
@@ -7,8 +7,10 @@ module Hancock::Pages
|
|
7
7
|
elsif nav_label.is_a?(Array)
|
8
8
|
nav_label, fields = nil, nav_label
|
9
9
|
end
|
10
|
+
|
10
11
|
Proc.new {
|
11
12
|
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))
|
13
|
+
object_label_method :rails_admin_label
|
12
14
|
|
13
15
|
field :enabled, :toggle do
|
14
16
|
searchable false
|
@@ -32,7 +34,14 @@ module Hancock::Pages
|
|
32
34
|
searchable true
|
33
35
|
end
|
34
36
|
|
35
|
-
field :file_path, :string do
|
37
|
+
# field :file_path, :string do
|
38
|
+
# searchable true
|
39
|
+
# end
|
40
|
+
field :file_path, :enum do
|
41
|
+
enum do
|
42
|
+
Hancock::Pages.whitelist_enum || []
|
43
|
+
end
|
44
|
+
multiple false
|
36
45
|
searchable true
|
37
46
|
end
|
38
47
|
field :content, :hancock_html do
|
@@ -56,6 +65,10 @@ module Hancock::Pages
|
|
56
65
|
# field :content_html, :ck_editor
|
57
66
|
# field :content_clear, :toggle
|
58
67
|
|
68
|
+
if Hancock::Pages.config.insertions_support
|
69
|
+
group :insertions, &Hancock::Admin.insertions_block
|
70
|
+
end
|
71
|
+
|
59
72
|
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
60
73
|
|
61
74
|
# field :blocksets do
|
@@ -20,7 +20,37 @@ module Hancock::Pages
|
|
20
20
|
searchable true
|
21
21
|
end
|
22
22
|
|
23
|
-
group :
|
23
|
+
group :blocks do
|
24
|
+
weight 10
|
25
|
+
active false
|
26
|
+
field :blocks do
|
27
|
+
eager_load(false) rescue nil
|
28
|
+
queryable true
|
29
|
+
searchable do
|
30
|
+
[
|
31
|
+
{blocks: :_id},
|
32
|
+
{blocks: :name},
|
33
|
+
{blocks: :menu_link_content},
|
34
|
+
{blocks: :pageblock_selector},
|
35
|
+
{blocks: :file_path},
|
36
|
+
{blocks: :content_html}
|
37
|
+
]
|
38
|
+
end
|
39
|
+
# searchable_columns do
|
40
|
+
# [
|
41
|
+
# { column: "#{abstract_model.table_name}.blocks.name", type: :string },
|
42
|
+
# { column: "#{abstract_model.table_name}.blocks.menu_link_content", type: :string },
|
43
|
+
# { column: "#{abstract_model.table_name}.blocks.pageblock_selector", type: :string },
|
44
|
+
# { column: "#{abstract_model.table_name}.blocks.file_path", type: :string },
|
45
|
+
# { column: "#{abstract_model.table_name}.blocks.content_html", type: :string }
|
46
|
+
# ]
|
47
|
+
# end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
group(:wrapper, &Hancock::Pages::Admin.wrapper_block do
|
52
|
+
weight 5
|
53
|
+
end)
|
24
54
|
# group :wrapper do
|
25
55
|
# active false
|
26
56
|
# field :use_wrapper, :toggle
|
@@ -34,13 +64,6 @@ module Hancock::Pages
|
|
34
64
|
# end
|
35
65
|
# end
|
36
66
|
|
37
|
-
group :blocks do
|
38
|
-
active false
|
39
|
-
field :blocks do
|
40
|
-
searchable :name
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
67
|
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
45
68
|
|
46
69
|
# field :blocks do
|
@@ -57,9 +80,9 @@ module Hancock::Pages
|
|
57
80
|
# end
|
58
81
|
|
59
82
|
sort_embedded(
|
60
|
-
|
61
|
-
|
62
|
-
|
83
|
+
{
|
84
|
+
fields: [:blocks]
|
85
|
+
}
|
63
86
|
)
|
64
87
|
|
65
88
|
if block_given?
|
@@ -34,7 +34,9 @@ module Hancock::Pages
|
|
34
34
|
formatted_value {}
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
if Hancock::Pages.config.cache_support
|
38
|
+
group :caching, &Hancock::Cache::Admin.caching_block
|
39
|
+
end
|
38
40
|
|
39
41
|
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
40
42
|
|
@@ -22,7 +22,7 @@ module Hancock::Pages
|
|
22
22
|
field :name do
|
23
23
|
searchable true
|
24
24
|
end
|
25
|
-
field :
|
25
|
+
field :hancock_connectable do
|
26
26
|
searchable :name
|
27
27
|
end
|
28
28
|
field :fullpath do
|
@@ -36,17 +36,33 @@ module Hancock::Pages
|
|
36
36
|
end
|
37
37
|
field :slug do
|
38
38
|
searchable true
|
39
|
+
searchable_columns do
|
40
|
+
[{column: "#{abstract_model.table_name}._slugs", type: :string}]
|
41
|
+
end
|
42
|
+
queryable true
|
43
|
+
end
|
44
|
+
|
45
|
+
# group :content, &Hancock::Admin.content_block(excluded_fields: [:excerpt])
|
46
|
+
group :content, &Hancock::Admin.content_block(excerpt: false)
|
47
|
+
if Hancock::Pages.config.cache_support
|
48
|
+
group :caching, &Hancock::Cache::Admin.caching_block
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
42
52
|
edit do
|
43
53
|
field :enabled, :toggle
|
44
54
|
field :name
|
45
|
-
field :
|
55
|
+
field :layout_name, :enum do
|
56
|
+
enum do
|
57
|
+
::Hancock::Pages.config.available_layouts
|
58
|
+
end
|
59
|
+
end
|
60
|
+
field :hancock_connectable do
|
46
61
|
read_only true
|
47
62
|
end
|
48
63
|
|
49
|
-
group :content, &Hancock::Admin.content_block(excluded_fields: [:excerpt])
|
64
|
+
# group :content, &Hancock::Admin.content_block(excluded_fields: [:excerpt])
|
65
|
+
group :content, &Hancock::Admin.content_block(excerpt: false)
|
50
66
|
# group :content do
|
51
67
|
# active false
|
52
68
|
# field :excerpt, :hancock_html
|
@@ -57,6 +73,8 @@ module Hancock::Pages
|
|
57
73
|
# # field :content_clear, :toggle
|
58
74
|
# end
|
59
75
|
|
76
|
+
group :wrapper, &Hancock::Pages::Admin.wrapper_block
|
77
|
+
|
60
78
|
|
61
79
|
group :menu, &Hancock::Pages::Admin.menu_block
|
62
80
|
# group :menu do
|
@@ -75,9 +93,15 @@ module Hancock::Pages
|
|
75
93
|
# field :text_slug
|
76
94
|
# end
|
77
95
|
|
96
|
+
if Hancock::Pages.config.cache_support
|
97
|
+
group :caching, &Hancock::Cache::Admin.caching_block
|
98
|
+
end
|
99
|
+
|
78
100
|
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
79
101
|
|
80
|
-
|
102
|
+
if Hancock::Pages.config.seo_support
|
103
|
+
group :seo_n_sitemap, &Hancock::Seo::Admin.seo_n_sitemap_block
|
104
|
+
end
|
81
105
|
# group :seo do
|
82
106
|
# active false
|
83
107
|
# field :seo
|
@@ -87,7 +111,13 @@ module Hancock::Pages
|
|
87
111
|
# field :sitemap_data
|
88
112
|
# end
|
89
113
|
|
90
|
-
|
114
|
+
if Hancock::Pages.config.cache_support
|
115
|
+
group :caching, &Hancock::Cache::Admin.caching_block
|
116
|
+
end
|
117
|
+
|
118
|
+
if Hancock::Pages.config.insertions_support
|
119
|
+
group :insertions, &Hancock::Admin.insertions_block
|
120
|
+
end
|
91
121
|
end
|
92
122
|
|
93
123
|
nested_set({
|