effective_pages 3.8.3 → 3.9.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/README.md +27 -0
- data/app/controllers/effective/pages_controller.rb +1 -1
- data/app/datatables/effective_pages_menu_datatable.rb +2 -0
- data/app/helpers/effective_menus_helper.rb +2 -2
- data/app/helpers/effective_page_banners_helper.rb +2 -2
- data/app/models/effective/page.rb +20 -3
- data/app/models/effective/permalink.rb +5 -1
- data/app/views/effective/pages/_menu.html.haml +3 -6
- data/app/views/effective/pages/_page_menu.html.haml +8 -5
- data/db/migrate/101_create_effective_pages.rb +2 -0
- data/lib/effective_pages/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de13a6ce9afb0cee9e8401e076c3416a159f9a64f4a5fb7cf70c890de442263f
|
4
|
+
data.tar.gz: dfa2b67769948a6e25c5c20e3b1520260f494d0722165cfd5a78eeff1aeb3ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11295b2af4904ad5469948123e4e910302fa4e3d7c29a79b55bd4500b7456f458e31f5f389c587725a7d534a21c4e138daff27b525fae74d874c8344948cd1d7
|
7
|
+
data.tar.gz: 5e2bbcef490e3b25c6ba565fd64fab7ee4a7091377fef64ca664a4be1edfa54d64b0810c2b5005a7e33e63c04e54ff65f2955c5e705f5ec9e03bb39ff513c654
|
data/README.md
CHANGED
@@ -6,6 +6,33 @@ Create content pages ontop of one or more templates -- just regular Rails views
|
|
6
6
|
|
7
7
|
Use this gem to create a fully-functional CMS that provides full or restricted editing for your end users.
|
8
8
|
|
9
|
+
## Upgrading to 3.9.0
|
10
|
+
|
11
|
+
Add a migration
|
12
|
+
|
13
|
+
```
|
14
|
+
class UpgradeEffectivePagesThreeNine < ActiveRecord::Migration[7.0]
|
15
|
+
def change
|
16
|
+
# Add a counter cache
|
17
|
+
add_column :pages, :menu_children_count, :integer, default: 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
Run a one time script
|
23
|
+
|
24
|
+
```
|
25
|
+
# rake upgrade_effective_pages_to_three_nine
|
26
|
+
task upgrade_effective_pages_to_three_nine: :environment do
|
27
|
+
puts "Starting effective pages 3.9.0 upgrade"
|
28
|
+
|
29
|
+
Effective::Page.where(menu_children_count: 0).find_each do |page|
|
30
|
+
Effective::Page.reset_counters(page.slug, :menu_children)
|
31
|
+
end
|
32
|
+
|
33
|
+
puts 'All done'
|
34
|
+
end
|
35
|
+
```
|
9
36
|
|
10
37
|
## effective_pages 3.0
|
11
38
|
|
@@ -14,6 +14,8 @@ class EffectivePagesMenuDatatable < Effective::Datatable
|
|
14
14
|
col :menu_url, label: 'Redirect Url'
|
15
15
|
col :menu_position, label: 'Position', visible: false
|
16
16
|
|
17
|
+
col :menu_children_count, label: 'Children Count', visible: false
|
18
|
+
|
17
19
|
# We only support depth 2 and 3.
|
18
20
|
col :menu_children, label: 'Children' do |page|
|
19
21
|
page.menu_children.group_by { |child| child.menu_group.presence }.values.flatten.map do |child|
|
@@ -28,7 +28,7 @@ module EffectiveMenusHelper
|
|
28
28
|
(
|
29
29
|
[content_tag(:li, link_to(root, root_path, title: root), class: 'breadcrumb-item')] +
|
30
30
|
parents.map do |page|
|
31
|
-
next if page.menu_root_with_children? # Don't show root pages
|
31
|
+
next if page.menu_root_with_children? # Don't show root pages because they have no content
|
32
32
|
|
33
33
|
url = (page.menu_url.presence || effective_pages.page_path(page))
|
34
34
|
content_tag(:li, link_to(page, url, title: page.title), class: 'breadcrumb-item')
|
@@ -60,7 +60,7 @@ module EffectiveMenusHelper
|
|
60
60
|
def admin_menu_parent_collection(page = nil)
|
61
61
|
raise('expected a page') if page.present? && !page.kind_of?(Effective::Page)
|
62
62
|
|
63
|
-
pages = Effective::Page.menuable.root_level.where.not(id: page)
|
63
|
+
pages = Effective::Page.deep_menuable.menuable.root_level.where.not(id: page)
|
64
64
|
|
65
65
|
if EffectivePages.max_menu_depth == 2
|
66
66
|
# You can only select root level pages
|
@@ -8,9 +8,9 @@ module EffectivePageBannersHelper
|
|
8
8
|
return unless page.banner? || EffectivePages.banners_force_randomize
|
9
9
|
|
10
10
|
# Always return a random banner if config.banners_force_randomize
|
11
|
-
page_banner = Effective::PageBanner.random.first if EffectivePages.banners_force_randomize
|
11
|
+
page_banner = Effective::PageBanner.deep.random.first if EffectivePages.banners_force_randomize
|
12
12
|
page_banner ||= page.page_banner if page.banner? && page.page_banner.present?
|
13
|
-
page_banner ||= Effective::PageBanner.random.first if page.banner? && page.banner_random?
|
13
|
+
page_banner ||= Effective::PageBanner.deep.random.first if page.banner? && page.banner_random?
|
14
14
|
|
15
15
|
return if page_banner.blank?
|
16
16
|
|
@@ -14,7 +14,7 @@ module Effective
|
|
14
14
|
belongs_to :page_banner, optional: true
|
15
15
|
|
16
16
|
# These parent / children are for the menu as well
|
17
|
-
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true
|
17
|
+
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true, touch: true, counter_cache: :menu_children_count
|
18
18
|
|
19
19
|
has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page',
|
20
20
|
foreign_key: :menu_parent_id, inverse_of: :menu_parent
|
@@ -47,6 +47,8 @@ module Effective
|
|
47
47
|
menu_url :string # Redirect to this url instead of the page url
|
48
48
|
menu_position :integer # Position in the menu
|
49
49
|
|
50
|
+
menu_children_count :integer # Counter cache
|
51
|
+
|
50
52
|
# Banners
|
51
53
|
banner :boolean # Should we display a banner?
|
52
54
|
banner_random :boolean # Display a random banner
|
@@ -58,7 +60,14 @@ module Effective
|
|
58
60
|
timestamps
|
59
61
|
end
|
60
62
|
|
61
|
-
scope :deep, -> {
|
63
|
+
scope :deep, -> {
|
64
|
+
base = includes(:page_banner, :tags, :rich_texts)
|
65
|
+
base = base.deep_menuable
|
66
|
+
base = base.includes(:pg_search_document) if defined?(PgSearch)
|
67
|
+
base
|
68
|
+
}
|
69
|
+
|
70
|
+
scope :deep_menuable, -> { includes(:menu_parent, menu_children: [:menu_parent, :menu_children]) }
|
62
71
|
|
63
72
|
scope :draft, -> { where(draft: true) }
|
64
73
|
scope :published, -> { where(draft: false) }
|
@@ -182,13 +191,21 @@ module Effective
|
|
182
191
|
end
|
183
192
|
|
184
193
|
def menu_parent?
|
185
|
-
menu? &&
|
194
|
+
menu? && menu_children_present?
|
186
195
|
end
|
187
196
|
|
188
197
|
def menu_child?
|
189
198
|
menu? && menu_parent_id.present?
|
190
199
|
end
|
191
200
|
|
201
|
+
def menu_children_present?
|
202
|
+
menu_children_count > 0
|
203
|
+
end
|
204
|
+
|
205
|
+
def menu_children_blank?
|
206
|
+
menu_children_count <= 0
|
207
|
+
end
|
208
|
+
|
192
209
|
end
|
193
210
|
|
194
211
|
end
|
@@ -16,7 +16,11 @@ module Effective
|
|
16
16
|
|
17
17
|
log_changes if respond_to?(:log_changes)
|
18
18
|
|
19
|
-
scope :deep, -> {
|
19
|
+
scope :deep, -> {
|
20
|
+
base = with_attached_attachment
|
21
|
+
base = base.includes(:pg_search_document) if defined?(PgSearch)
|
22
|
+
base
|
23
|
+
}
|
20
24
|
|
21
25
|
effective_resource do
|
22
26
|
title :string
|
@@ -7,14 +7,11 @@
|
|
7
7
|
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
8
8
|
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
9
9
|
|
10
|
-
-
|
11
|
-
|
12
|
-
- if menu_children.blank?
|
10
|
+
- if page.menu_children_blank?
|
13
11
|
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
14
|
-
|
15
|
-
- if menu_children.present?
|
12
|
+
- else
|
16
13
|
= nav_dropdown(page.menu_to_s, groups: true) do
|
17
|
-
- menu_children.group_by { |menu| menu.menu_group.presence }.each do |menu_group, pages|
|
14
|
+
- page.menu_children.group_by { |menu| menu.menu_group.presence }.each do |menu_group, pages|
|
18
15
|
= nav_dropdown_group(menu_group || '') do
|
19
16
|
- pages.each do |page|
|
20
17
|
- next unless EffectiveResources.authorized?(self, :show, page)
|
@@ -1,14 +1,17 @@
|
|
1
1
|
- raise('expected a page') unless page.present?
|
2
2
|
|
3
|
-
- children =
|
3
|
+
- children = []
|
4
4
|
|
5
|
-
- if page.
|
5
|
+
- if page.menu_children_present?
|
6
|
+
- children = page.menu_children
|
6
7
|
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
7
8
|
|
8
9
|
- # if this is a third depth page, show the parent and siblings
|
9
|
-
- if
|
10
|
-
-
|
11
|
-
|
10
|
+
- if page.menu_children_blank? && page.menu_parent.try(:menu_parent_id).present?
|
11
|
+
- if page.menu_parent.menu_children_present?
|
12
|
+
- page.menu_parent.try(:strict_loading!, false)
|
13
|
+
- children = page.menu_parent.menu_children
|
14
|
+
= nav_link_to(page.menu_parent.menu_to_s, (page.menu_parent.menu_url.presence || effective_pages.page_path(page.menu_parent)))
|
12
15
|
|
13
16
|
- children.each do |page|
|
14
17
|
- next unless EffectiveResources.authorized?(self, :show, page)
|
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.9.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: 2023-
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|