hancock_cms_pages 1.0.0
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 +84 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/hancock/pages/init.coffee +2 -0
- data/app/assets/javascripts/hancock/pages/scrolling.coffee +55 -0
- data/app/assets/javascripts/hancock/pages.coffee +6 -0
- data/app/assets/stylesheets/hancock/pages.sass +1 -0
- data/app/controllers/concerns/hancock/pages/blocksetable.rb +104 -0
- data/app/controllers/concerns/hancock/pages/decorators/pages.rb +15 -0
- data/app/controllers/concerns/hancock/pages/localizeable.rb +66 -0
- data/app/controllers/concerns/hancock/pages/nav_menu.rb +91 -0
- data/app/controllers/concerns/hancock/pages/seo_pages.rb +99 -0
- data/app/controllers/hancock/pages/pages_controller.rb +7 -0
- data/app/helpers/hancock/pages/canonical_helper.rb +12 -0
- data/app/helpers/hancock/pages/pages_helpers.rb +2 -0
- data/app/models/concerns/hancock/pages/canonicalable.rb +22 -0
- data/app/models/concerns/hancock/pages/connectable.rb +36 -0
- data/app/models/concerns/hancock/pages/decorators/block.rb +39 -0
- data/app/models/concerns/hancock/pages/decorators/blockset.rb +39 -0
- data/app/models/concerns/hancock/pages/decorators/menu.rb +39 -0
- data/app/models/concerns/hancock/pages/decorators/page.rb +39 -0
- data/app/models/hancock/pages/block.rb +13 -0
- data/app/models/hancock/pages/blockset.rb +13 -0
- data/app/models/hancock/pages/menu.rb +16 -0
- data/app/models/hancock/pages/page.rb +16 -0
- data/app/views/blocks/_header.html.slim +4 -0
- data/app/views/hancock/pages/pages/show.html.slim +1 -0
- data/app/views/rails_admin/main/_hancock_connectable.html.slim +56 -0
- data/app/views/shared/_obj.html.slim +26 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/hancock_pages.rb +3 -0
- data/config/locales/hancock.pages.ru.yml +54 -0
- data/hancock_cms_pages.gemspec +37 -0
- data/lib/generators/hancock/pages/config/install_generator.rb +13 -0
- data/lib/generators/hancock/pages/config/templates/hancock_pages.erb +14 -0
- data/lib/generators/hancock/pages/migration_generator.rb +18 -0
- data/lib/generators/hancock/pages/models/block_generator.rb +39 -0
- data/lib/generators/hancock/pages/models/blockset_generator.rb +39 -0
- data/lib/generators/hancock/pages/models/decorators_generator.rb +24 -0
- data/lib/generators/hancock/pages/models/menu_generator.rb +39 -0
- data/lib/generators/hancock/pages/models/page_generator.rb +39 -0
- data/lib/generators/hancock/pages/models/templates/block.erb +37 -0
- data/lib/generators/hancock/pages/models/templates/blockset.erb +34 -0
- data/lib/generators/hancock/pages/models/templates/menu.erb +37 -0
- data/lib/generators/hancock/pages/models/templates/page.erb +43 -0
- data/lib/generators/hancock/pages/templates/migration_blocks.rb +42 -0
- data/lib/generators/hancock/pages/templates/migration_pages.rb +48 -0
- data/lib/hancock/pages/admin/block.rb +81 -0
- data/lib/hancock/pages/admin/blockset.rb +72 -0
- data/lib/hancock/pages/admin/menu.rb +48 -0
- data/lib/hancock/pages/admin/page.rb +105 -0
- data/lib/hancock/pages/admin.rb +45 -0
- data/lib/hancock/pages/configuration.rb +35 -0
- data/lib/hancock/pages/controllers/pages.rb +33 -0
- data/lib/hancock/pages/engine.rb +5 -0
- data/lib/hancock/pages/models/active_record/block.rb +16 -0
- data/lib/hancock/pages/models/active_record/blockset.rb +19 -0
- data/lib/hancock/pages/models/active_record/menu.rb +20 -0
- data/lib/hancock/pages/models/active_record/page.rb +22 -0
- data/lib/hancock/pages/models/block.rb +190 -0
- data/lib/hancock/pages/models/blockset.rb +69 -0
- data/lib/hancock/pages/models/menu.rb +48 -0
- data/lib/hancock/pages/models/mongoid/block.rb +34 -0
- data/lib/hancock/pages/models/mongoid/blockset.rb +22 -0
- data/lib/hancock/pages/models/mongoid/menu.rb +16 -0
- data/lib/hancock/pages/models/mongoid/page.rb +43 -0
- data/lib/hancock/pages/models/page.rb +159 -0
- data/lib/hancock/pages/rails_admin_ext/hancock_connectable.rb +33 -0
- data/lib/hancock/pages/rails_admin_ext/menu.rb +147 -0
- data/lib/hancock/pages/routes.rb +46 -0
- data/lib/hancock/pages/version.rb +5 -0
- data/lib/hancock_cms_pages.rb +54 -0
- data/release.sh +6 -0
- metadata +185 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Pages::Block
|
2
|
+
|
3
|
+
# embedded_in :blockset, inverse_of: :blocks, class_name: "Hancock::Pages::Blockset"
|
4
|
+
|
5
|
+
# def nav_options_additions
|
6
|
+
# {}
|
7
|
+
# end
|
8
|
+
|
9
|
+
############ rails_admin ##############
|
10
|
+
def self.rails_admin_add_fields
|
11
|
+
[] #super
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.rails_admin_add_config(config)
|
15
|
+
#super(config)
|
16
|
+
end
|
17
|
+
|
18
|
+
def admin_can_user_defined_actions
|
19
|
+
[].freeze
|
20
|
+
end
|
21
|
+
def admin_cannot_user_defined_actions
|
22
|
+
[].freeze
|
23
|
+
end
|
24
|
+
def manager_can_user_defined_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
def manager_cannot_user_defined_actions
|
28
|
+
[].freeze
|
29
|
+
end
|
30
|
+
def rails_admin_user_defined_visible_actions
|
31
|
+
[].freeze
|
32
|
+
end
|
33
|
+
|
34
|
+
rails_admin(&Hancock::Pages::Admin::Block.config(rails_admin_add_fields) { |config|
|
35
|
+
rails_admin_add_config(config)
|
36
|
+
})
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Pages::Blockset
|
2
|
+
|
3
|
+
# embeds_many :blocks, inverse_of: :blockset, class_name: "Hancock::Pages::Block"
|
4
|
+
# accepts_nested_attributes_for :blocks, allow_destroy: true
|
5
|
+
|
6
|
+
############ rails_admin ##############
|
7
|
+
def self.rails_admin_add_fields
|
8
|
+
[] #super
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.rails_admin_add_config(config)
|
12
|
+
#super(config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def admin_can_user_defined_actions
|
16
|
+
[].freeze
|
17
|
+
end
|
18
|
+
def admin_cannot_user_defined_actions
|
19
|
+
[].freeze
|
20
|
+
end
|
21
|
+
def manager_can_user_defined_actions
|
22
|
+
[].freeze
|
23
|
+
end
|
24
|
+
def manager_cannot_user_defined_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
def rails_admin_user_defined_visible_actions
|
28
|
+
[].freeze
|
29
|
+
end
|
30
|
+
|
31
|
+
rails_admin(&Hancock::Pages::Admin::Blockset.config(rails_admin_add_fields) { |config|
|
32
|
+
rails_admin_add_config(config)
|
33
|
+
})
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Pages::Menu
|
2
|
+
|
3
|
+
# has_and_belongs_to_many :pages, inverse_of: :menus, class_name: "Hancock::Pages::Page"
|
4
|
+
|
5
|
+
def self.default_cache_keys
|
6
|
+
['menus']
|
7
|
+
end
|
8
|
+
|
9
|
+
############ rails_admin ##############
|
10
|
+
def self.rails_admin_add_fields
|
11
|
+
[] #super
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.rails_admin_add_config(config)
|
15
|
+
#super(config)
|
16
|
+
end
|
17
|
+
|
18
|
+
def admin_can_user_defined_actions
|
19
|
+
[].freeze
|
20
|
+
end
|
21
|
+
def admin_cannot_user_defined_actions
|
22
|
+
[].freeze
|
23
|
+
end
|
24
|
+
def manager_can_user_defined_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
def manager_cannot_user_defined_actions
|
28
|
+
[].freeze
|
29
|
+
end
|
30
|
+
def rails_admin_user_defined_visible_actions
|
31
|
+
[].freeze
|
32
|
+
end
|
33
|
+
|
34
|
+
rails_admin(&Hancock::Pages::Admin::Menu.config(rails_admin_add_fields) { |config|
|
35
|
+
rails_admin_add_config(config)
|
36
|
+
})
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Pages::Page
|
2
|
+
|
3
|
+
# has_and_belongs_to_many :menus, inverse_of: :pages, class_name: "Hancock::Pages::Menu"
|
4
|
+
|
5
|
+
# if Hancock.rails4?
|
6
|
+
# belongs_to :connectable, polymorphic: true, overwrite: true
|
7
|
+
# else
|
8
|
+
# belongs_to :connectable, polymorphic: true, overwrite: true, optional: true
|
9
|
+
# end
|
10
|
+
|
11
|
+
# def nav_options_additions
|
12
|
+
# {}
|
13
|
+
# end
|
14
|
+
|
15
|
+
############ rails_admin ##############
|
16
|
+
def self.rails_admin_add_fields
|
17
|
+
[] #super
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.rails_admin_add_config(config)
|
21
|
+
#super(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
def admin_can_user_defined_actions
|
25
|
+
[].freeze
|
26
|
+
end
|
27
|
+
def admin_cannot_user_defined_actions
|
28
|
+
[].freeze
|
29
|
+
end
|
30
|
+
def manager_can_user_defined_actions
|
31
|
+
[].freeze
|
32
|
+
end
|
33
|
+
def manager_cannot_user_defined_actions
|
34
|
+
[].freeze
|
35
|
+
end
|
36
|
+
def rails_admin_user_defined_visible_actions
|
37
|
+
[].freeze
|
38
|
+
end
|
39
|
+
|
40
|
+
rails_admin(&Hancock::Pages::Admin::Page.config(rails_admin_add_fields) { |config|
|
41
|
+
rails_admin_add_config(config)
|
42
|
+
})
|
43
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class HancockPagesCreateBlocks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :hancock_pages_blocksets do |t|
|
4
|
+
|
5
|
+
if Hancock.config.localize
|
6
|
+
t.column :name_translations, 'hstore'
|
7
|
+
else
|
8
|
+
t.string :name, null: false
|
9
|
+
end
|
10
|
+
t.string :slug, null: false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
add_index :hancock_pages_blocksets, :slug, unique: true
|
14
|
+
|
15
|
+
create_table :hancock_pages_blocks do |t|
|
16
|
+
t.boolean :enabled, default: true, null: false
|
17
|
+
|
18
|
+
t.integer :parent_id
|
19
|
+
t.integer :lft
|
20
|
+
t.integer :rgt
|
21
|
+
t.integer :depth
|
22
|
+
|
23
|
+
if Hancock.config.localize
|
24
|
+
t.column :name_translations, 'hstore', default: {}
|
25
|
+
t.column :content_html_translations, 'hstore', default: {}
|
26
|
+
t.column :content_clear_translations, 'hstore', default: {}
|
27
|
+
else
|
28
|
+
t.string :name, null: false
|
29
|
+
t.text :content
|
30
|
+
end
|
31
|
+
|
32
|
+
t.string :slug, null: false
|
33
|
+
t.string :regexp
|
34
|
+
t.string :redirect
|
35
|
+
t.string :fullpath, null: false
|
36
|
+
t.timestamps
|
37
|
+
end
|
38
|
+
add_index :hancock_pages_pages, :slug, unique: true
|
39
|
+
add_index :hancock_pages_pages, [:enabled, :lft]
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class HancockPagesCreatePages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :hancock_pages_menus do |t|
|
4
|
+
|
5
|
+
if Hancock.config.localize
|
6
|
+
t.column :name_translations, 'hstore'
|
7
|
+
else
|
8
|
+
t.string :name, null: false
|
9
|
+
end
|
10
|
+
t.string :slug, null: false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
add_index :hancock_pages_menus, :slug, unique: true
|
14
|
+
|
15
|
+
create_table :hancock_pages_pages do |t|
|
16
|
+
t.boolean :enabled, default: true, null: false
|
17
|
+
t.integer :parent_id
|
18
|
+
t.integer :lft
|
19
|
+
t.integer :rgt
|
20
|
+
t.integer :depth
|
21
|
+
|
22
|
+
if Hancock.config.localize
|
23
|
+
t.column :name_translations, 'hstore', default: {}
|
24
|
+
t.column :content_html_translations, 'hstore', default: {}
|
25
|
+
t.column :content_clear_translations, 'hstore', default: {}
|
26
|
+
else
|
27
|
+
t.string :name, null: false
|
28
|
+
t.text :content
|
29
|
+
end
|
30
|
+
|
31
|
+
t.string :slug, null: false
|
32
|
+
t.string :regexp
|
33
|
+
t.string :redirect
|
34
|
+
t.string :fullpath, null: false
|
35
|
+
t.timestamps
|
36
|
+
end
|
37
|
+
add_index :hancock_pages_pages, :slug, unique: true
|
38
|
+
add_index :hancock_pages_pages, [:enabled, :lft]
|
39
|
+
|
40
|
+
|
41
|
+
######### pages <-> menus join table #############
|
42
|
+
|
43
|
+
create_join_table :hancock_pages_menus, :hancock_pages_pages, table_name: :hancock_pages_menu_pages
|
44
|
+
|
45
|
+
add_foreign_key(:hancock_pages_menu_pages, :hancock_pages_menus, dependent: :delete)
|
46
|
+
add_foreign_key(:hancock_pages_menu_pages, :hancock_pages_pages, dependent: :delete)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Admin
|
3
|
+
module Block
|
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
|
+
Proc.new {
|
11
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))
|
12
|
+
|
13
|
+
field :enabled, :toggle do
|
14
|
+
searchable false
|
15
|
+
end
|
16
|
+
field :show_in_menu, :toggle do
|
17
|
+
searchable false
|
18
|
+
end
|
19
|
+
field :render_file, :toggle do
|
20
|
+
searchable false
|
21
|
+
end
|
22
|
+
field :partial, :toggle do
|
23
|
+
searchable false
|
24
|
+
end
|
25
|
+
field :name do
|
26
|
+
searchable true
|
27
|
+
end
|
28
|
+
field :menu_link_content, :text do
|
29
|
+
searchable true
|
30
|
+
end
|
31
|
+
field :pageblock_selector, :string do
|
32
|
+
searchable true
|
33
|
+
end
|
34
|
+
|
35
|
+
field :file_path, :string do
|
36
|
+
searchable true
|
37
|
+
end
|
38
|
+
field :content, :hancock_html do
|
39
|
+
searchable true
|
40
|
+
end
|
41
|
+
|
42
|
+
group :wrapper, &Hancock::Pages::Admin.wrapper_block
|
43
|
+
# group :wrapper do
|
44
|
+
# active false
|
45
|
+
# field :use_wrapper, :toggle
|
46
|
+
# field :wrapper_tag, :string
|
47
|
+
# field :wrapper_class, :string
|
48
|
+
# field :wrapper_id, :string
|
49
|
+
# field :wrapper_attributes, :text do
|
50
|
+
# formatted_value do
|
51
|
+
# bindings[:object] and bindings[:object].wrapper_attributes ? bindings[:object].wrapper_attributes.to_json : "{}"
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
|
56
|
+
# field :content_html, :ck_editor
|
57
|
+
# field :content_clear, :toggle
|
58
|
+
|
59
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
60
|
+
|
61
|
+
# field :blocksets do
|
62
|
+
# read_only true
|
63
|
+
# help 'Список групп блоков'
|
64
|
+
#
|
65
|
+
# pretty_value do
|
66
|
+
# bindings[:object].blocksets.to_a.map { |bs|
|
67
|
+
# route = (bindings[:view] || bindings[:controller])
|
68
|
+
# model_name = bs.rails_admin_model
|
69
|
+
# route.link_to(bs.name, route.rails_admin.show_path(model_name: model_name, id: bs.id), title: bs.name)
|
70
|
+
# }.join("<br>").html_safe
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
|
74
|
+
if block_given?
|
75
|
+
yield self
|
76
|
+
end
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Admin
|
3
|
+
module Blockset
|
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
|
+
Proc.new {
|
11
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))
|
12
|
+
|
13
|
+
field :enabled, :toggle do
|
14
|
+
searchable false
|
15
|
+
end
|
16
|
+
field :text_slug do
|
17
|
+
searchable true
|
18
|
+
end
|
19
|
+
field :name do
|
20
|
+
searchable true
|
21
|
+
end
|
22
|
+
|
23
|
+
group :wrapper, &Hancock::Pages::Admin.wrapper_block
|
24
|
+
# group :wrapper do
|
25
|
+
# active false
|
26
|
+
# field :use_wrapper, :toggle
|
27
|
+
# field :wrapper_tag, :string
|
28
|
+
# field :wrapper_class, :string
|
29
|
+
# field :wrapper_id, :string
|
30
|
+
# field :wrapper_attributes, :text do
|
31
|
+
# formatted_value do
|
32
|
+
# bindings[:object] and bindings[:object].wrapper_attributes ? bindings[:object].wrapper_attributes.to_json : "{}"
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
group :blocks do
|
38
|
+
active false
|
39
|
+
field :blocks do
|
40
|
+
searchable :name
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
45
|
+
|
46
|
+
# field :blocks do
|
47
|
+
# read_only true
|
48
|
+
# help 'Список блоков'
|
49
|
+
#
|
50
|
+
# pretty_value do
|
51
|
+
# bindings[:object].blocks.to_a.map { |b|
|
52
|
+
# route = (bindings[:view] || bindings[:controller])
|
53
|
+
# model_name = b.rails_admin_model
|
54
|
+
# route.link_to(b.name, route.rails_admin.show_path(model_name: model_name, id: b.id), title: b.name)
|
55
|
+
# }.join("<br>").html_safe
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
|
59
|
+
sort_embedded(
|
60
|
+
{
|
61
|
+
fields: [:blocks]
|
62
|
+
}
|
63
|
+
)
|
64
|
+
|
65
|
+
if block_given?
|
66
|
+
yield self
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Admin
|
3
|
+
module Menu
|
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
|
+
Proc.new {
|
11
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))
|
12
|
+
|
13
|
+
field :enabled, :toggle do
|
14
|
+
searchable false
|
15
|
+
end
|
16
|
+
field :text_slug do
|
17
|
+
searchable true
|
18
|
+
end
|
19
|
+
field :name do
|
20
|
+
searchable true
|
21
|
+
end
|
22
|
+
field :add_page do
|
23
|
+
pretty_value do
|
24
|
+
_model = bindings[:object].page_class.rails_admin_model
|
25
|
+
bindings[:view].link_to(
|
26
|
+
'Добавить Страницу',
|
27
|
+
bindings[:view].new_path(model_name: _model, "#{_model}[menu_ids][]": bindings[:object]._id.to_s),
|
28
|
+
class: 'label label-info'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
visible do
|
32
|
+
bindings[:controller].action_name == 'index'
|
33
|
+
end
|
34
|
+
formatted_value {}
|
35
|
+
end
|
36
|
+
|
37
|
+
group :caching, &Hancock::Admin.caching_block
|
38
|
+
|
39
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
40
|
+
|
41
|
+
if block_given?
|
42
|
+
yield self
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Admin
|
3
|
+
module Page
|
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
|
+
Proc.new {
|
11
|
+
navigation_label(!nav_label.blank? ? nav_label : I18n.t('hancock.pages'))
|
12
|
+
|
13
|
+
list do
|
14
|
+
scopes [:sorted, :enabled, nil]
|
15
|
+
|
16
|
+
field :enabled, :toggle do
|
17
|
+
searchable false
|
18
|
+
end
|
19
|
+
field :menus, :menu do
|
20
|
+
searchable :name
|
21
|
+
end
|
22
|
+
field :name do
|
23
|
+
searchable true
|
24
|
+
end
|
25
|
+
field :connectable do
|
26
|
+
searchable :name
|
27
|
+
end
|
28
|
+
field :fullpath do
|
29
|
+
searchable true
|
30
|
+
pretty_value do
|
31
|
+
bindings[:view].content_tag(:a, bindings[:object].fullpath, href: bindings[:object].fullpath)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
field :redirect do
|
35
|
+
searchable true
|
36
|
+
end
|
37
|
+
field :slug do
|
38
|
+
searchable true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
edit do
|
43
|
+
field :enabled, :toggle
|
44
|
+
field :name
|
45
|
+
field :connectable do
|
46
|
+
read_only true
|
47
|
+
end
|
48
|
+
|
49
|
+
group :content, &Hancock::Admin.content_block(excluded_fields: [:excerpt])
|
50
|
+
# group :content do
|
51
|
+
# active false
|
52
|
+
# field :excerpt, :hancock_html
|
53
|
+
# # field :excerpt_html, :ck_editor
|
54
|
+
# # field :excerpt_clear, :toggle
|
55
|
+
# field :content, :hancock_html
|
56
|
+
# # field :content_html, :ck_editor
|
57
|
+
# # field :content_clear, :toggle
|
58
|
+
# end
|
59
|
+
|
60
|
+
|
61
|
+
group :menu, &Hancock::Pages::Admin.menu_block
|
62
|
+
# group :menu do
|
63
|
+
# active false
|
64
|
+
# label I18n.t('hancock.menu_title')
|
65
|
+
# field :menus
|
66
|
+
# field :fullpath, :string do
|
67
|
+
# help I18n.t('hancock.with_final_slash')
|
68
|
+
# end
|
69
|
+
# field :regexp, :string do
|
70
|
+
# help I18n.t('hancock.page_url_regex')
|
71
|
+
# end
|
72
|
+
# field :redirect, :string do
|
73
|
+
# help I18n.t('hancock.final_in_menu')
|
74
|
+
# end
|
75
|
+
# field :text_slug
|
76
|
+
# end
|
77
|
+
|
78
|
+
Hancock::RailsAdminGroupPatch::hancock_cms_group(self, fields)
|
79
|
+
|
80
|
+
group :seo_n_sitemap, &Hancock::Seo::Admin.seo_n_sitemap_block
|
81
|
+
# group :seo do
|
82
|
+
# active false
|
83
|
+
# field :seo
|
84
|
+
# end
|
85
|
+
# group :sitemap_data do
|
86
|
+
# active false
|
87
|
+
# field :sitemap_data
|
88
|
+
# end
|
89
|
+
|
90
|
+
# group :caching, &Hancock::Admin.caching_block
|
91
|
+
end
|
92
|
+
|
93
|
+
nested_set({
|
94
|
+
max_depth: Hancock::Pages.config.menu_max_depth,
|
95
|
+
scopes: []
|
96
|
+
})
|
97
|
+
|
98
|
+
if block_given?
|
99
|
+
yield self
|
100
|
+
end
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Admin
|
3
|
+
|
4
|
+
def self.menu_block(is_active = false)
|
5
|
+
Proc.new {
|
6
|
+
active false
|
7
|
+
label I18n.t('hancock.menu_title')
|
8
|
+
field :menus
|
9
|
+
field :fullpath, :string do
|
10
|
+
help I18n.t('hancock.with_final_slash')
|
11
|
+
end
|
12
|
+
field :regexp, :string do
|
13
|
+
help I18n.t('hancock.page_url_regex')
|
14
|
+
end
|
15
|
+
field :redirect, :string do
|
16
|
+
help I18n.t('hancock.final_in_menu')
|
17
|
+
end
|
18
|
+
field :text_slug
|
19
|
+
|
20
|
+
if block_given?
|
21
|
+
yield self
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.wrapper_block(is_active = false)
|
27
|
+
Proc.new {
|
28
|
+
active is_active
|
29
|
+
field :use_wrapper, :toggle
|
30
|
+
field :wrapper_tag, :string
|
31
|
+
field :wrapper_class, :string
|
32
|
+
field :wrapper_id, :string
|
33
|
+
field :wrapper_attributes, :text do
|
34
|
+
formatted_value do
|
35
|
+
bindings[:object] and bindings[:object].wrapper_attributes ? bindings[:object].wrapper_attributes.to_json : "{}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if block_given?
|
40
|
+
yield self
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
include Hancock::PluginConfiguration
|
3
|
+
|
4
|
+
def self.config_class
|
5
|
+
Configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
attr_accessor :menu_max_depth
|
10
|
+
|
11
|
+
attr_accessor :seo_support
|
12
|
+
|
13
|
+
attr_accessor :localize
|
14
|
+
|
15
|
+
attr_accessor :breadcrumbs_on_rails_support
|
16
|
+
|
17
|
+
attr_accessor :model_settings_support
|
18
|
+
attr_accessor :user_abilities_support
|
19
|
+
attr_accessor :ra_comments_support
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@menu_max_depth = 2
|
23
|
+
|
24
|
+
@seo_support = defined? Hancock::Seo
|
25
|
+
|
26
|
+
@localize = Hancock.config.localize
|
27
|
+
|
28
|
+
@breadcrumbs_on_rails_support = defined?(BreadcrumbsOnRails)
|
29
|
+
|
30
|
+
@model_settings_support = defined?(RailsAdminModelSettings)
|
31
|
+
@user_abilities_support = defined?(RailsAdminUserAbilities)
|
32
|
+
@ra_comments_support = defined?(RailsAdminComments)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Controllers
|
3
|
+
module Pages
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def show
|
7
|
+
if @seo_page.nil? || !@seo_page.persisted?
|
8
|
+
if !params[:id].blank? or !params[:slug].blank?
|
9
|
+
@seo_page = model.enabled.find(params[:id] || params[:slug])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
after_initialize
|
13
|
+
if @seo_page.nil?
|
14
|
+
render_404
|
15
|
+
return true
|
16
|
+
end
|
17
|
+
|
18
|
+
if Hancock::Pages.config.breadcrumbs_on_rails_support
|
19
|
+
add_breadcrumb @seo_page.name, @seo_page.slug
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def model
|
25
|
+
Hancock::Pages::Page
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_initialize
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Hancock::Pages
|
2
|
+
module Models
|
3
|
+
module ActiveRecord
|
4
|
+
module Block
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# include Hancock::HtmlField
|
8
|
+
|
9
|
+
included do
|
10
|
+
belongs_to :blockset, class_name: "Hancock::Pages::Block"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|