effective_pages 3.1.0 → 3.2.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 +4 -4
- data/app/controllers/effective/pages_controller.rb +4 -3
- data/app/datatables/effective_pages_datatable.rb +6 -4
- data/app/datatables/effective_pages_menu_datatable.rb +22 -6
- data/app/helpers/effective_menus_helper.rb +34 -2
- data/app/models/effective/page.rb +44 -8
- data/app/views/admin/menus/index.html.haml +3 -3
- data/app/views/admin/pages/_form.html.haml +1 -12
- data/app/views/admin/pages/_form_access.html.haml +2 -5
- data/app/views/admin/pages/_form_menu.html.haml +20 -9
- data/app/views/admin/pages/_form_page.html.haml +17 -4
- data/app/views/effective/pages/_menu.html.haml +13 -9
- data/app/views/effective/pages/_page_menu.html.haml +17 -0
- data/config/effective_pages.rb +6 -0
- data/db/migrate/01_create_effective_pages.rb.erb +4 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +7 -1
- metadata +3 -3
- data/app/views/admin/pages/_form_content.html.haml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06898ad2ffae38015ec40dbeeefb1a46e468a7df73e933c69c194d06415123cc'
|
4
|
+
data.tar.gz: 74916bd3ca8fe11dbac3b6ac6b6085cc73cc9fd381fdf96aacd46fed82a3ba72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27fc19935dabbad5e6710ad06a9ea883d04a983541ae5308d706c62bc5546c295a922a6143fb9778980fd80ec26817c1d68ea7025b32d6950558da8af09290de
|
7
|
+
data.tar.gz: 1789579e269f287c2b4db33748d3039f6bc0b152506a0c597ebcbbbd58c8064f38cb240c2de4f76740bd01b620ffcb64c2dbbbda8eee822a513de5d9ea46c322
|
@@ -8,6 +8,8 @@ module Effective
|
|
8
8
|
|
9
9
|
@page = @pages.find(params[:id])
|
10
10
|
|
11
|
+
raise ActionController::RoutingError.new('Not Found') if @page.menu_root_with_children?
|
12
|
+
|
11
13
|
if @page.authenticate_user? || @page.roles.present?
|
12
14
|
authenticate_user!
|
13
15
|
end
|
@@ -22,9 +24,8 @@ module Effective
|
|
22
24
|
if EffectiveResources.authorized?(self, :admin, :effective_pages)
|
23
25
|
flash.now[:warning] = [
|
24
26
|
'Hi Admin!',
|
25
|
-
('You are viewing a
|
26
|
-
'Click here to
|
27
|
-
("<a href='#{effective_pages.edit_admin_page_path(@page)}' class='alert-link'>edit page settings</a>.")
|
27
|
+
('You are viewing a draft page.' unless @page.published?),
|
28
|
+
("<a href='#{effective_pages.edit_admin_page_path(@page)}' class='alert-link'>Click here to edit this page</a>.")
|
28
29
|
].compact.join(' ')
|
29
30
|
end
|
30
31
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class EffectivePagesDatatable < Effective::Datatable
|
2
2
|
|
3
3
|
filters do
|
4
|
+
scope :all
|
4
5
|
scope :published
|
5
6
|
scope :draft
|
6
7
|
scope :on_menu
|
7
|
-
scope :all
|
8
8
|
end
|
9
9
|
|
10
10
|
datatable do
|
@@ -25,10 +25,12 @@ class EffectivePagesDatatable < Effective::Datatable
|
|
25
25
|
col :layout, visible: false
|
26
26
|
col :tempate, visible: false
|
27
27
|
|
28
|
-
col :
|
29
|
-
col :
|
28
|
+
col :menu_name
|
29
|
+
col :menu_title
|
30
|
+
col :menu_group
|
31
|
+
|
30
32
|
col :menu_url, visible: false
|
31
|
-
col :menu_parent,
|
33
|
+
col :menu_parent, search: { collection: admin_menu_parent_collection(), grouped: true }
|
32
34
|
col :menu_position, visible: false
|
33
35
|
|
34
36
|
col :authenticate_user, visible: false
|
@@ -13,18 +13,34 @@ class EffectivePagesMenuDatatable < Effective::Datatable
|
|
13
13
|
|
14
14
|
col :menu_url, label: 'Redirect Url'
|
15
15
|
col :menu_position, label: 'Position', visible: false
|
16
|
-
|
16
|
+
|
17
|
+
# We only support depth 2 and 3.
|
18
|
+
col :menu_children, label: 'Children' do |page|
|
19
|
+
page.menu_children.group_by(&:menu_group).values.flatten.map do |child|
|
20
|
+
content_tag(:div, class: 'col-resource_item') do
|
21
|
+
link = link_to(child.admin_menu_label, effective_pages.edit_admin_page_path(child))
|
22
|
+
|
23
|
+
list = child.menu_children.group_by(&:menu_group).values.flatten.map do |child|
|
24
|
+
content_tag(:li, link_to(child.admin_menu_label, effective_pages.edit_admin_page_path(child)))
|
25
|
+
end
|
26
|
+
|
27
|
+
link + (content_tag(:ul, list.join.html_safe) if list.present?).to_s
|
28
|
+
end
|
29
|
+
end.join.html_safe
|
30
|
+
end
|
17
31
|
|
18
32
|
actions_col(new: false, destroy: false)
|
19
33
|
end
|
20
34
|
|
21
35
|
collection(apply_belongs_to: false) do
|
22
|
-
scope = Effective::Page.deep.
|
36
|
+
scope = Effective::Page.deep.menuable
|
37
|
+
|
38
|
+
if attributes[:menu].present?
|
39
|
+
scope = scope.root_level.for_menu(menu)
|
40
|
+
end
|
23
41
|
|
24
|
-
|
25
|
-
scope.where(menu_parent_id: attributes[:
|
26
|
-
else
|
27
|
-
scope.where(menu_parent_id: nil)
|
42
|
+
if attributes[:page_id].present?
|
43
|
+
scope = scope.where(menu_parent_id: attributes[:page_id])
|
28
44
|
end
|
29
45
|
|
30
46
|
scope
|
@@ -12,18 +12,24 @@ module EffectiveMenusHelper
|
|
12
12
|
content_tag(:ul, options) { render('effective/pages/menu', menu: menu) }
|
13
13
|
end
|
14
14
|
|
15
|
+
def render_page_menu(page, options = {}, &block)
|
16
|
+
raise('expected a page with menu true') unless page.kind_of?(Effective::Page) && page.menu?
|
17
|
+
|
18
|
+
content_tag(:ul, options) { render('effective/pages/page_menu', page: page) }
|
19
|
+
end
|
20
|
+
|
15
21
|
def render_breadcrumbs(menu, page = @page, root: 'Home')
|
16
22
|
return breadcrumbs_root_url(page, root: root) if request.path == '/'
|
17
23
|
return breadcrumbs_fallback(page, root: root) unless page.kind_of?(Effective::Page)
|
18
24
|
|
19
|
-
parents = [page.menu_parent].compact
|
25
|
+
parents = [page.menu_parent&.menu_parent, page.menu_parent].compact
|
20
26
|
|
21
27
|
content_tag(:ol, class: 'breadcrumb') do
|
22
28
|
(
|
23
29
|
[content_tag(:li, link_to(root, root_path, title: root), class: 'breadcrumb-item')] +
|
24
30
|
parents.map do |page|
|
25
31
|
url = (page.menu_url.presence || effective_pages.page_path(page))
|
26
|
-
content_tag(:li, link_to(page, url, title: page.title), class: 'breadcrumb-item')
|
32
|
+
content_tag(:li, link_to(page, (page.menu_root_with_children? ? '#' : url), title: page.title), class: 'breadcrumb-item')
|
27
33
|
end +
|
28
34
|
[content_tag(:li, page, class: 'breadcrumb-item active', 'aria-current': 'page')]
|
29
35
|
).join.html_safe
|
@@ -49,4 +55,30 @@ module EffectiveMenusHelper
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
58
|
+
def admin_menu_parent_collection(page = nil)
|
59
|
+
raise('expected a page') if page.present? && !page.kind_of?(Effective::Page)
|
60
|
+
|
61
|
+
pages = Effective::Page.menuable.root_level.where.not(id: page)
|
62
|
+
|
63
|
+
if EffectivePages.max_menu_depth == 2
|
64
|
+
# You can only select root level pages
|
65
|
+
pages.group_by(&:menu_name)
|
66
|
+
elsif EffectivePages.max_menu_depth == 3
|
67
|
+
# You can only select root level pages and immediate children
|
68
|
+
pages.map do |page|
|
69
|
+
[[page.to_s, page.id, page.menu_name]] + page.menu_children.map do |child|
|
70
|
+
label = content_tag(:div) do
|
71
|
+
arrow = "→"
|
72
|
+
group = content_tag(:span, child.menu_group, class: 'badge badge-info') if child.menu_group.present?
|
73
|
+
title = child.menu_to_s
|
74
|
+
|
75
|
+
[arrow, group, title].compact.join(' ').html_safe
|
76
|
+
end
|
77
|
+
|
78
|
+
[child.to_s, child.to_param, { 'data-html': label }, child.menu_name]
|
79
|
+
end
|
80
|
+
end.flatten(1).group_by(&:last)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
52
84
|
end
|
@@ -29,12 +29,13 @@ module Effective
|
|
29
29
|
slug :string
|
30
30
|
|
31
31
|
# Menu stuff
|
32
|
-
menu :boolean
|
33
|
-
menu_name :string
|
32
|
+
menu :boolean # Should this be displayed on the menu at all?
|
33
|
+
menu_name :string # When I'm a root level item, this is the menu I render underneath
|
34
|
+
menu_group :string # Used for design. Group by menu_group to display full dropdowns.
|
34
35
|
|
35
|
-
menu_title :string
|
36
|
-
menu_url :string
|
37
|
-
menu_position :integer
|
36
|
+
menu_title :string # Displayed on the menu instead of title
|
37
|
+
menu_url :string # Redirect to this url instead of the page url
|
38
|
+
menu_position :integer # Position in the menu
|
38
39
|
|
39
40
|
# Access
|
40
41
|
roles_mask :integer
|
@@ -59,7 +60,10 @@ module Effective
|
|
59
60
|
validates :layout, presence: true
|
60
61
|
validates :template, presence: true
|
61
62
|
|
62
|
-
validates :menu_name, if: -> {
|
63
|
+
validates :menu_name, presence: true, if: -> { menu_root? && EffectivePages.menus.present? }
|
64
|
+
|
65
|
+
# Doesn't make sense for a top level item to have a menu group
|
66
|
+
validates :menu_group, absence: true, if: -> { menu_root? && EffectivePages.menus.present? }
|
63
67
|
|
64
68
|
# validates :menu_position, if: -> { menu? },
|
65
69
|
# presence: true, uniqueness: { scope: [:menu_name, :menu_parent_id] }
|
@@ -69,20 +73,34 @@ module Effective
|
|
69
73
|
scope :draft, -> { where(draft: true) }
|
70
74
|
scope :published, -> { where(draft: false) }
|
71
75
|
scope :sorted, -> { order(:title) }
|
76
|
+
|
72
77
|
scope :on_menu, -> { where(menu: true) }
|
73
78
|
scope :except_home, -> { where.not(title: 'Home') }
|
74
79
|
|
75
|
-
scope :menuable, -> { where(menu: true).order(:menu_position) }
|
80
|
+
scope :menuable, -> { published.where(menu: true).order(:menu_position) }
|
76
81
|
scope :menu_deep, -> { includes(:menu_parent, :menu_children) }
|
77
82
|
|
78
83
|
scope :for_menu, -> (name) { menuable.where(menu_name: name) }
|
79
84
|
scope :for_menu_root, -> (name) { for_menu(name).menu_deep.root_level }
|
80
85
|
scope :root_level, -> { where(menu_parent_id: nil) }
|
81
86
|
|
87
|
+
scope :menu_root_with_children, -> { menu_parents.where(menu_parent_id: nil) }
|
88
|
+
scope :menu_roots, -> { where(menu: true).where(menu_parent_id: nil) }
|
89
|
+
scope :menu_parents, -> { where(menu: true).where(id: Effective::Page.select('menu_parent_id')) }
|
90
|
+
scope :menu_children, -> { where(menu: true).where.not(menu_parent_id: nil) }
|
91
|
+
|
92
|
+
scope :for_sitemap, -> {
|
93
|
+
published.where(menu: false).or(published.where(menu: true).where.not(id: menu_root_with_children))
|
94
|
+
}
|
95
|
+
|
82
96
|
def to_s
|
83
97
|
title
|
84
98
|
end
|
85
99
|
|
100
|
+
def menu_to_s
|
101
|
+
(menu_title.presence || title)
|
102
|
+
end
|
103
|
+
|
86
104
|
# As per has_many_rich_texts
|
87
105
|
def body
|
88
106
|
rich_text_body
|
@@ -114,8 +132,26 @@ module Effective
|
|
114
132
|
duplicate.tap { |page| page.save! }
|
115
133
|
end
|
116
134
|
|
135
|
+
# When true, this should not appear in sitemap.xml and should return 404 if visited
|
136
|
+
def menu_root_with_children?
|
137
|
+
menu_root? && menu_parent?
|
138
|
+
end
|
139
|
+
|
140
|
+
# This is for the form
|
117
141
|
def menu_root_level
|
118
|
-
|
142
|
+
menu_root?
|
143
|
+
end
|
144
|
+
|
145
|
+
def menu_root?
|
146
|
+
menu? && menu_parent_id.blank?
|
147
|
+
end
|
148
|
+
|
149
|
+
def menu_parent?
|
150
|
+
menu? && menu_children.to_a.present?
|
151
|
+
end
|
152
|
+
|
153
|
+
def menu_child?
|
154
|
+
menu? && menu_parent_id.present?
|
119
155
|
end
|
120
156
|
|
121
157
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
%h1= @page_title
|
2
2
|
|
3
3
|
%p
|
4
|
-
Click Reorder to drag & drop reorder
|
4
|
+
Click Reorder to drag & drop reorder menu items.
|
5
5
|
Edit an item to reorder its children items.
|
6
6
|
|
7
7
|
- EffectivePages.menus.each do |menu|
|
8
|
-
%
|
8
|
+
%h3 #{menu.to_s.titleize} Menu
|
9
9
|
- datatable = EffectivePagesMenuDatatable.new(menu: menu)
|
10
10
|
= render_datatable(datatable, simple: true, inline: true)
|
11
|
-
%hr
|
11
|
+
%hr.my-5
|
@@ -1,13 +1,6 @@
|
|
1
|
-
- if inline_datatable?
|
2
|
-
- menu = inline_datatable.attributes[:menu]
|
3
|
-
- datatable = EffectivePagesMenuDatatable.new(menu: menu, menu_parent_id: page.id)
|
4
|
-
|
1
|
+
- if inline_datatable?
|
5
2
|
= render '/admin/pages/form_menu', page: page
|
6
3
|
|
7
|
-
- if datatable.present?(self)
|
8
|
-
%h3 Children
|
9
|
-
= render_datatable(datatable, simple: true, inline: true)
|
10
|
-
|
11
4
|
- else
|
12
5
|
= tabs do
|
13
6
|
= tab 'Page' do
|
@@ -18,10 +11,6 @@
|
|
18
11
|
= tab 'Menu' do
|
19
12
|
= render '/admin/pages/form_menu', page: page
|
20
13
|
|
21
|
-
- unless page.menu_root_level
|
22
|
-
= tab 'Content' do
|
23
|
-
= render '/admin/pages/form_content', page: page
|
24
|
-
|
25
14
|
= tab 'Access' do
|
26
15
|
= render '/admin/pages/form_access', page: page
|
27
16
|
|
@@ -1,10 +1,7 @@
|
|
1
1
|
= effective_form_with(model: page, url: page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path) do |f|
|
2
|
-
= f.check_box :authenticate_user, label: '
|
2
|
+
= f.check_box :authenticate_user, label: 'Restrict the page to any signed in user'
|
3
3
|
|
4
4
|
- if EffectivePages.use_effective_roles
|
5
|
-
= f.checks :roles, EffectiveRoles.roles_collection(f.object)
|
6
|
-
|
7
|
-
%p.text-hint
|
8
|
-
* leave blank for a regular public page that anyone can view
|
5
|
+
= f.checks :roles, EffectiveRoles.roles_collection(f.object), label: 'Restrict the page to any signed in user that has the role:'
|
9
6
|
|
10
7
|
= f.submit
|
@@ -1,24 +1,35 @@
|
|
1
1
|
= effective_form_with(model: page, url: page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path) do |f|
|
2
|
-
= f.check_box :menu, label: 'Yes, display this page
|
2
|
+
= f.check_box :menu, label: 'Yes, display this page in a menu'
|
3
3
|
|
4
4
|
= f.show_if :menu, true do
|
5
5
|
|
6
|
-
|
7
|
-
= f.select :menu_name, menus
|
8
|
-
- else
|
9
|
-
= f.hidden_field :menu_name, value: menus.first
|
10
|
-
|
11
|
-
= f.check_box :menu_root_level, label: "This is a top level menu item. Do not show page content."
|
6
|
+
= f.check_box :menu_root_level, label: "This is a top level menu item. It has no content and cannot be viewed, but can have children pages"
|
12
7
|
|
13
8
|
= f.show_if :menu_root_level, true do
|
14
9
|
= f.hidden_field :menu_parent_id, value: nil
|
15
10
|
|
11
|
+
- if (menus = EffectivePages.menus).length > 1
|
12
|
+
= f.select :menu_name, menus, label: 'Top level menu item in this menu'
|
13
|
+
- else
|
14
|
+
= f.hidden_field :menu_name, value: menus.first
|
15
|
+
|
16
16
|
= f.show_if :menu_root_level, false do
|
17
|
-
= f.select :menu_parent_id,
|
17
|
+
= f.select :menu_parent_id, admin_menu_parent_collection(f.object), required: true, grouped: true, hint: 'Displayed on the menu underneath this parent'
|
18
|
+
= f.text_field :menu_group, hint: 'Displayed on the menu in this group or column'
|
18
19
|
|
19
20
|
= f.text_field :menu_title, hint: "Display this title on menus instead of full page title"
|
20
21
|
|
21
22
|
= f.text_field :menu_url, label: "Redirect to path or url instead of displaying page",
|
22
23
|
hint: "Must start with http(s):// or /"
|
23
24
|
|
24
|
-
= f
|
25
|
+
= effective_submit(f)
|
26
|
+
|
27
|
+
- if page.menu_parent.present?
|
28
|
+
.mb-4
|
29
|
+
%h3 Parent
|
30
|
+
= link_to(page.menu_parent, effective_pages.edit_admin_page_path(page.menu_parent))
|
31
|
+
|
32
|
+
- if page.menu_children.present?
|
33
|
+
%h3 Children
|
34
|
+
- datatable = EffectivePagesMenuDatatable.new(page: page)
|
35
|
+
= render_datatable(datatable, simple: true, inline: true)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
= effective_form_with(model: page, url: page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path) do |f|
|
2
|
-
|
2
|
+
|
3
|
+
= f.text_field :title
|
3
4
|
|
4
5
|
= f.check_box :draft,
|
5
|
-
label: 'Save this page as a draft. It will not be
|
6
|
+
label: 'Save this page as a draft. It will not appear in a menu and can only be accessed by admin users.'
|
6
7
|
|
7
8
|
= f.text_field :meta_description,
|
8
|
-
hint: "
|
9
|
+
hint: "150 character summary. Appears on Google search results underneath the page title. ",
|
9
10
|
input_html: { maxlength: 150 }
|
10
11
|
|
11
12
|
- if (layouts = EffectivePages.layouts).length > 1
|
@@ -24,8 +25,20 @@
|
|
24
25
|
|
25
26
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
26
27
|
|
28
|
+
- if f.object.persisted? && f.object.menu_root_with_children?
|
29
|
+
.alert.alert-info.my-3.pl-0
|
30
|
+
%ul.mb-0
|
31
|
+
%li This page is a top level menu item with at least one child page
|
32
|
+
%li It will render on the menu as a dropdown link
|
33
|
+
%li Users will not be able to click access page via the menu
|
34
|
+
%li Visiting the page URL directly will return a 404 error
|
35
|
+
%li If you want this page to be accessible while also being a top level menu item, it needs to have no child pages
|
36
|
+
|
37
|
+
- if f.object.persisted? && !f.object.menu_root_with_children?
|
38
|
+
= render '/admin/pages/rich_text_areas', page: page, f: f
|
39
|
+
|
27
40
|
-# This is for duplicate
|
28
41
|
- if f.object.new_record? && f.object.rich_texts.present?
|
29
|
-
= render
|
42
|
+
= render '/admin/pages/rich_text_areas', page: page, f: f
|
30
43
|
|
31
44
|
= effective_submit(f)
|
@@ -1,20 +1,24 @@
|
|
1
1
|
- raise('expected a menu') unless menu.present?
|
2
2
|
- menu = menu.to_s
|
3
3
|
|
4
|
+
- # Renders menu_root? level pages and their immediate children
|
4
5
|
- Effective::Page.for_menu_root(menu).each do |page|
|
5
6
|
- next unless EffectiveResources.authorized?(self, :show, page)
|
6
7
|
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
7
8
|
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
8
9
|
|
9
|
-
- menu_children = page.menu_children
|
10
|
+
- menu_children = page.menu_children
|
10
11
|
|
11
12
|
- if menu_children.blank?
|
12
|
-
= nav_link_to(
|
13
|
-
- else
|
14
|
-
= nav_dropdown(page.to_s) do
|
15
|
-
- menu_children.each do |page|
|
16
|
-
- next unless EffectiveResources.authorized?(self, :show, page)
|
17
|
-
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
18
|
-
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
13
|
+
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
19
14
|
|
20
|
-
|
15
|
+
- if menu_children.present?
|
16
|
+
= nav_dropdown(page.menu_to_s, groups: true) do
|
17
|
+
- menu_children.group_by(&:menu_group).each do |menu_group, pages|
|
18
|
+
= nav_dropdown_group(menu_group) do
|
19
|
+
- pages.each do |page|
|
20
|
+
- next unless EffectiveResources.authorized?(self, :show, page)
|
21
|
+
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
22
|
+
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
23
|
+
|
24
|
+
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
@@ -0,0 +1,17 @@
|
|
1
|
+
- raise('expected a page') unless page.present?
|
2
|
+
|
3
|
+
- menu_children = page.menu_children
|
4
|
+
|
5
|
+
- if menu_children.blank? && page.menu_parent&.menu_children.present?
|
6
|
+
- menu_children = page.menu_parent&.menu_children
|
7
|
+
|
8
|
+
- menu_children.group_by(&:menu_group).each do |menu_group, pages|
|
9
|
+
- if menu_group.present?
|
10
|
+
%h6= menu_group
|
11
|
+
|
12
|
+
- pages.each do |page|
|
13
|
+
- next unless EffectiveResources.authorized?(self, :show, page)
|
14
|
+
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
15
|
+
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
16
|
+
|
17
|
+
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
data/config/effective_pages.rb
CHANGED
@@ -50,4 +50,10 @@ EffectivePages.setup do |config|
|
|
50
50
|
# Layout Settings
|
51
51
|
# config.layout = { admin: 'admin' }
|
52
52
|
|
53
|
+
# Menus
|
54
|
+
# Strict bootstrap only supports depth 2. A root level and one dropdown.
|
55
|
+
# Other sites can be configured such that the depth 3 menus are displayed on a sidebar.
|
56
|
+
# Only 2 or 3 are supported right now
|
57
|
+
config.max_menu_depth = 2
|
58
|
+
|
53
59
|
end
|
@@ -15,8 +15,12 @@ class CreateEffectivePages < ActiveRecord::Migration[4.2]
|
|
15
15
|
t.integer :roles_mask, default: 0
|
16
16
|
|
17
17
|
t.integer :menu_parent_id
|
18
|
+
|
18
19
|
t.boolean :menu, default: false
|
20
|
+
|
19
21
|
t.string :menu_name
|
22
|
+
t.string :menu_group
|
23
|
+
|
20
24
|
t.string :menu_title
|
21
25
|
t.string :menu_url
|
22
26
|
t.integer :menu_position
|
data/lib/effective_pages.rb
CHANGED
@@ -12,7 +12,7 @@ module EffectivePages
|
|
12
12
|
:site_og_image, :site_og_image_width, :site_og_image_height,
|
13
13
|
:site_title, :site_title_suffix, :fallback_meta_description,
|
14
14
|
:silence_missing_page_title_warnings, :silence_missing_meta_description_warnings, :silence_missing_canonical_url_warnings,
|
15
|
-
:use_effective_roles, :menus, :layout
|
15
|
+
:use_effective_roles, :menus, :layout, :max_menu_depth
|
16
16
|
]
|
17
17
|
end
|
18
18
|
|
@@ -43,4 +43,10 @@ module EffectivePages
|
|
43
43
|
end.compact.sort
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.max_menu_depth
|
47
|
+
depth = config[:max_menu_depth] || 2
|
48
|
+
raise('only depths 2 and 3 are supported') unless [2, 3].include?(depth)
|
49
|
+
depth
|
50
|
+
end
|
51
|
+
|
46
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -87,11 +87,11 @@ files:
|
|
87
87
|
- app/views/admin/pages/_additional_fields.html.haml
|
88
88
|
- app/views/admin/pages/_form.html.haml
|
89
89
|
- app/views/admin/pages/_form_access.html.haml
|
90
|
-
- app/views/admin/pages/_form_content.html.haml
|
91
90
|
- app/views/admin/pages/_form_menu.html.haml
|
92
91
|
- app/views/admin/pages/_form_page.html.haml
|
93
92
|
- app/views/admin/pages/_rich_text_areas.html.haml
|
94
93
|
- app/views/effective/pages/_menu.html.haml
|
94
|
+
- app/views/effective/pages/_page_menu.html.haml
|
95
95
|
- config/effective_pages.rb
|
96
96
|
- config/routes.rb
|
97
97
|
- db/migrate/01_create_effective_pages.rb.erb
|