effective_pages 3.11.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/datatables/effective_pages_datatable.rb +4 -1
- data/app/helpers/effective_page_segments_helper.rb +38 -0
- data/app/models/effective/alert.rb +1 -1
- data/app/models/effective/carousel_item.rb +1 -1
- data/app/models/effective/page.rb +15 -14
- data/app/models/effective/page_banner.rb +1 -1
- data/app/models/effective/page_section.rb +1 -3
- data/app/models/effective/page_segment.rb +43 -0
- data/app/views/admin/pages/_fields_page_segments.html.haml +10 -0
- data/app/views/admin/pages/_form_page.html.haml +13 -4
- data/app/views/admin/pages/_rich_text_areas.html.haml +4 -2
- data/app/views/effective/page_segments/_content.html.haml +5 -0
- data/app/views/effective/page_segments/_menu.html.haml +4 -0
- data/config/effective_pages.rb +3 -0
- data/db/migrate/101_create_effective_pages.rb +13 -1
- data/lib/effective_pages/engine.rb +1 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.rb +6 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77904dcc5dcbdb4b61099c85b7ca2e201796a74a5018251eeebe66f3fcdf1128
|
4
|
+
data.tar.gz: 39d9c4b11d21ebdc73b31ddbd8925791a2a3bba78e5e839f15880f8fa7af4477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57fccf986d7b3279e0dd3f5bacd365841fe4b45db2d828de068eb8504f2da54f07a3005ae63951ebb621aca623ade13ede050b22b62c7cbe86278a4262ffd015
|
7
|
+
data.tar.gz: e290da633e3cc9cf3b08081457ea7e5218cbab17364fc6906ddd4f63c16f58b8ee86232f2f27fc097038b61847a192cf531896c3a328e7c71f5b1bc7a350a584
|
@@ -20,7 +20,10 @@ class EffectivePagesDatatable < Effective::Datatable
|
|
20
20
|
link_to(page.slug, effective_pages.page_path(page), target: '_blank')
|
21
21
|
end
|
22
22
|
|
23
|
-
col :draft
|
23
|
+
col :draft?, as: :boolean, visible: false
|
24
|
+
col :published?, as: :boolean
|
25
|
+
col :published_start_at
|
26
|
+
col :published_end_at
|
24
27
|
|
25
28
|
col :layout, visible: false
|
26
29
|
col :tempate, visible: false
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EffectivePageSegmentsHelper
|
4
|
+
|
5
|
+
# This is a scrollspy navbar
|
6
|
+
# = render_page_segments_menu(class: 'navbar navbar-light bg-light')
|
7
|
+
def render_page_segments_menu(page = nil, options = {})
|
8
|
+
(options = page; page = nil) if page.kind_of?(Hash)
|
9
|
+
page ||= @page
|
10
|
+
|
11
|
+
raise('Expected an Effective::Page') if page && !page.kind_of?(Effective::Page)
|
12
|
+
raise('Expected a Hash of options') unless options.kind_of?(Hash)
|
13
|
+
|
14
|
+
return if page.blank?
|
15
|
+
return if page.page_segments.blank?
|
16
|
+
return unless page.template_page_segments?
|
17
|
+
|
18
|
+
# Default options
|
19
|
+
options[:class] ||= 'navbar navbar-light bg-light'
|
20
|
+
|
21
|
+
render('effective/page_segments/menu', page: page, html_options: options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Renders all page segments for one page
|
25
|
+
def render_page_segments(page = nil, options = {})
|
26
|
+
(options = page; page = nil) if page.kind_of?(Hash)
|
27
|
+
page ||= @page
|
28
|
+
|
29
|
+
raise('Expected an Effective::Page') if page && !page.kind_of?(Effective::Page)
|
30
|
+
raise('Expected a Hash of options') unless options.kind_of?(Hash)
|
31
|
+
|
32
|
+
return if page.blank?
|
33
|
+
return if page.page_segments.blank?
|
34
|
+
|
35
|
+
render('effective/page_segments/content', page: page, html_options: options)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -19,19 +19,24 @@ module Effective
|
|
19
19
|
has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page',
|
20
20
|
foreign_key: :menu_parent_id, inverse_of: :menu_parent
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
has_many :page_segments, -> { Effective::PageSegment.sorted }, class_name: 'Effective::PageSegment', inverse_of: :page, dependent: :destroy
|
23
|
+
accepts_nested_attributes_for :page_segments, allow_destroy: true
|
24
|
+
|
25
|
+
acts_as_role_restricted if respond_to?(:acts_as_role_restricted)
|
26
|
+
acts_as_paginable
|
27
|
+
acts_as_published
|
24
28
|
acts_as_slugged
|
25
29
|
acts_as_tagged
|
26
30
|
has_many_rich_texts
|
27
|
-
|
28
31
|
log_changes if respond_to?(:log_changes)
|
29
32
|
|
30
33
|
effective_resource do
|
31
34
|
title :string
|
32
35
|
meta_description :string
|
33
36
|
|
34
|
-
|
37
|
+
published_start_at :datetime
|
38
|
+
published_end_at :datetime
|
39
|
+
legacy_draft :boolean # No longer used. To be removed.
|
35
40
|
|
36
41
|
layout :string
|
37
42
|
template :string
|
@@ -68,9 +73,6 @@ module Effective
|
|
68
73
|
}
|
69
74
|
|
70
75
|
scope :deep_menuable, -> { includes(:menu_parent, menu_children: [:menu_parent, :menu_children]) }
|
71
|
-
|
72
|
-
scope :draft, -> { where(draft: true) }
|
73
|
-
scope :published, -> { where(draft: false) }
|
74
76
|
scope :sorted, -> { order(:title) }
|
75
77
|
|
76
78
|
scope :on_menu, -> { where(menu: true) }
|
@@ -138,7 +140,7 @@ module Effective
|
|
138
140
|
end
|
139
141
|
|
140
142
|
def to_s
|
141
|
-
title
|
143
|
+
title.presence || model_name.human
|
142
144
|
end
|
143
145
|
|
144
146
|
def menu_to_s
|
@@ -154,10 +156,6 @@ module Effective
|
|
154
156
|
rich_text_sidebar
|
155
157
|
end
|
156
158
|
|
157
|
-
def published?
|
158
|
-
!draft?
|
159
|
-
end
|
160
|
-
|
161
159
|
# Returns a duplicated post object, or throws an exception
|
162
160
|
def duplicate
|
163
161
|
Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
|
@@ -168,7 +166,7 @@ module Effective
|
|
168
166
|
page.send("rich_text_#{rt.name}=", rt.body)
|
169
167
|
end
|
170
168
|
|
171
|
-
page.
|
169
|
+
page.assign_attributes(published_start_at: nil, published_end_at: nil)
|
172
170
|
end
|
173
171
|
end
|
174
172
|
|
@@ -206,6 +204,9 @@ module Effective
|
|
206
204
|
menu_children_count <= 0
|
207
205
|
end
|
208
206
|
|
207
|
+
# Checked by render_page_segments_menu() to see if this page should render the page_segments menu
|
208
|
+
def template_page_segments?
|
209
|
+
template == 'page_segments'
|
210
|
+
end
|
209
211
|
end
|
210
|
-
|
211
212
|
end
|
@@ -35,14 +35,12 @@ module Effective
|
|
35
35
|
scope :sorted, -> { order(:name) }
|
36
36
|
|
37
37
|
def to_s
|
38
|
-
name.presence ||
|
38
|
+
name.presence || model_name.human
|
39
39
|
end
|
40
40
|
|
41
41
|
# As per has_many_rich_texts
|
42
42
|
def body
|
43
43
|
rich_text_body
|
44
44
|
end
|
45
|
-
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# For use with the the ScrollSpy pages
|
2
|
+
# Each PageSegment will be considered with the page_segments / scrollspy menu
|
3
|
+
|
4
|
+
module Effective
|
5
|
+
class PageSegment < ActiveRecord::Base
|
6
|
+
self.table_name = (EffectivePages.page_segments_table_name || :page_segments).to_s
|
7
|
+
|
8
|
+
belongs_to :page
|
9
|
+
|
10
|
+
has_many_rich_texts
|
11
|
+
log_changes(to: :page) if respond_to?(:log_changes)
|
12
|
+
|
13
|
+
effective_resource do
|
14
|
+
title :string
|
15
|
+
position :integer
|
16
|
+
|
17
|
+
timestamps
|
18
|
+
end
|
19
|
+
|
20
|
+
before_validation(if: -> { page.present? }) do
|
21
|
+
self.position ||= (page.page_segments.map(&:position).compact.max || -1) + 1
|
22
|
+
end
|
23
|
+
|
24
|
+
validates :title, presence: true, uniqueness: { scope: :page_id }
|
25
|
+
validates :position, presence: true
|
26
|
+
|
27
|
+
scope :deep, -> { includes(:page, :rich_texts) }
|
28
|
+
scope :sorted, -> { order(:position) }
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
title.presence || model_name.human
|
32
|
+
end
|
33
|
+
|
34
|
+
# As per has_many_rich_texts
|
35
|
+
def body
|
36
|
+
rich_text_body
|
37
|
+
end
|
38
|
+
|
39
|
+
def uid
|
40
|
+
title.parameterize
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%p Please add one or more page segments. Each segment will be displayed on the in-page menu.
|
2
|
+
|
3
|
+
= f.has_many :page_segments, f.object.page_segments do |fps|
|
4
|
+
= card do
|
5
|
+
= fps.text_field :title
|
6
|
+
|
7
|
+
- if defined?(EffectiveArticleEditor)
|
8
|
+
= fps.article_editor :rich_text_body, label: 'Body'
|
9
|
+
- else
|
10
|
+
= fps.rich_text_area :rich_text_body, label: 'Body'
|
@@ -1,9 +1,15 @@
|
|
1
1
|
= effective_form_with(model: [:admin, page], engine: true) do |f|
|
2
|
-
|
3
2
|
= f.text_field :title
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
-# acts_as_published
|
5
|
+
= f.hide_if(:save_as_draft, true) do
|
6
|
+
.row
|
7
|
+
.col-md-6
|
8
|
+
= f.datetime_field :published_start_at, hint: 'The page will be available starting on this date and time. Leave blank to publish immediately.'
|
9
|
+
.col-md-6
|
10
|
+
= f.datetime_field :published_end_at, hint: 'The page will no longer be available after this date and time. Leave blank for no end date.', date_linked: false
|
11
|
+
|
12
|
+
= f.check_box :save_as_draft, label: "Save as a draft. It will not appear in a menu and can only be accessed by admin users."
|
7
13
|
|
8
14
|
= f.text_field :meta_description,
|
9
15
|
hint: "150 character summary. Appears on Google search results underneath the page title. ",
|
@@ -42,7 +48,6 @@
|
|
42
48
|
|
43
49
|
= f.select :page_banner_id, Effective::PageBanner.sorted.all, label: 'Choose a page banner'
|
44
50
|
|
45
|
-
|
46
51
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
47
52
|
|
48
53
|
- if f.object.persisted? && f.object.menu_root_with_children?
|
@@ -61,4 +66,8 @@
|
|
61
66
|
- if f.object.new_record? && f.object.rich_texts.present?
|
62
67
|
= render '/admin/pages/rich_text_areas', page: page, f: f
|
63
68
|
|
69
|
+
-# For use with the render_page_segments_menu() helper. Used to render the page_segments / scrollspy menu.
|
70
|
+
= f.show_if(:template, :page_segments) do
|
71
|
+
= render '/admin/pages/fields_page_segments', page: page, f: f
|
72
|
+
|
64
73
|
= effective_submit(f)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
- if defined?(EffectiveArticleEditor)
|
2
2
|
= f.article_editor :rich_text_body, label: 'Body', hint: 'The main body of your page'
|
3
|
-
|
3
|
+
- if EffectivePages.sidebars?
|
4
|
+
= f.article_editor :rich_text_sidebar, label: 'Sidebar', hint: 'The sidebar content of your page'
|
4
5
|
- else
|
5
6
|
= f.rich_text_area :rich_text_body, label: 'Body', hint: 'The main body of your page'
|
6
|
-
|
7
|
+
- if EffectivePages.sidebars?
|
8
|
+
= f.rich_text_area :rich_text_sidebar, label: 'Sidebar', hint: 'The sidebar content of your page'
|
data/config/effective_pages.rb
CHANGED
@@ -70,4 +70,7 @@ EffectivePages.setup do |config|
|
|
70
70
|
# config.carousels = [:home, :secondary]
|
71
71
|
config.carousels_hint_text = 'Hint text that includes required image dimensions'
|
72
72
|
|
73
|
+
# Page Sidebars
|
74
|
+
# Set to true if your any of your pages use the sidebar content
|
75
|
+
config.sidebars = false
|
73
76
|
end
|
@@ -6,7 +6,9 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
|
|
6
6
|
t.string :title
|
7
7
|
t.string :meta_description
|
8
8
|
|
9
|
-
t.
|
9
|
+
t.datetime :published_start_at
|
10
|
+
t.datetime :published_end_at
|
11
|
+
t.boolean :legacy_draft, default: false
|
10
12
|
|
11
13
|
t.string :layout, default: 'application'
|
12
14
|
t.string :template
|
@@ -63,6 +65,16 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
|
|
63
65
|
|
64
66
|
add_index :page_sections, :name, :unique => true
|
65
67
|
|
68
|
+
create_table :page_segments do |t|
|
69
|
+
t.integer :page_id
|
70
|
+
|
71
|
+
t.string :title
|
72
|
+
t.integer :position
|
73
|
+
|
74
|
+
t.datetime :updated_at
|
75
|
+
t.datetime :created_at
|
76
|
+
end
|
77
|
+
|
66
78
|
create_table :carousel_items do |t|
|
67
79
|
t.string :carousel
|
68
80
|
|
@@ -18,6 +18,7 @@ module EffectivePages
|
|
18
18
|
helper EffectivePagesHelper
|
19
19
|
helper EffectiveCarouselsHelper
|
20
20
|
helper EffectivePageSectionsHelper
|
21
|
+
helper EffectivePageSegmentsHelper
|
21
22
|
helper EffectivePageBannersHelper
|
22
23
|
helper EffectiveMenusHelper
|
23
24
|
helper EffectiveAlertsHelper
|
data/lib/effective_pages.rb
CHANGED
@@ -7,7 +7,8 @@ require 'effective_pages/version'
|
|
7
7
|
module EffectivePages
|
8
8
|
def self.config_keys
|
9
9
|
[
|
10
|
-
:pages_table_name, :
|
10
|
+
:pages_table_name, :page_banners_table_name, :page_sections_table_name, :page_segments_table_name,
|
11
|
+
:alerts_table_name, :carousel_items_table_name, :permalinks_table_name, :tags_table_name, :taggings_table_name,
|
11
12
|
:pages_path, :excluded_pages, :layouts_path, :excluded_layouts,
|
12
13
|
:site_og_image, :site_og_image_width, :site_og_image_height,
|
13
14
|
:site_title, :site_title_suffix, :fallback_meta_description, :google_analytics_code,
|
@@ -15,7 +16,7 @@ module EffectivePages
|
|
15
16
|
:use_effective_roles, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,
|
16
17
|
|
17
18
|
# Booleans
|
18
|
-
:banners,
|
19
|
+
:banners, :sidebars,
|
19
20
|
|
20
21
|
# Hashes
|
21
22
|
:menus, :carousels
|
@@ -67,4 +68,7 @@ module EffectivePages
|
|
67
68
|
menus.kind_of?(Array) && menus.present?
|
68
69
|
end
|
69
70
|
|
71
|
+
def self.sidebars?
|
72
|
+
!!sidebars
|
73
|
+
end
|
70
74
|
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.13.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: 2024-
|
11
|
+
date: 2024-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- app/helpers/effective_menus_helper.rb
|
188
188
|
- app/helpers/effective_page_banners_helper.rb
|
189
189
|
- app/helpers/effective_page_sections_helper.rb
|
190
|
+
- app/helpers/effective_page_segments_helper.rb
|
190
191
|
- app/helpers/effective_pages_helper.rb
|
191
192
|
- app/helpers/effective_permalinks_helper.rb
|
192
193
|
- app/helpers/effective_tags_helper.rb
|
@@ -196,6 +197,7 @@ files:
|
|
196
197
|
- app/models/effective/page.rb
|
197
198
|
- app/models/effective/page_banner.rb
|
198
199
|
- app/models/effective/page_section.rb
|
200
|
+
- app/models/effective/page_segment.rb
|
199
201
|
- app/models/effective/permalink.rb
|
200
202
|
- app/models/effective/tag.rb
|
201
203
|
- app/models/effective/tagging.rb
|
@@ -210,6 +212,7 @@ files:
|
|
210
212
|
- app/views/admin/page_sections/_form.html.haml
|
211
213
|
- app/views/admin/page_sections/_form_page_section.html.haml
|
212
214
|
- app/views/admin/pages/_additional_fields.html.haml
|
215
|
+
- app/views/admin/pages/_fields_page_segments.html.haml
|
213
216
|
- app/views/admin/pages/_form.html.haml
|
214
217
|
- app/views/admin/pages/_form_access.html.haml
|
215
218
|
- app/views/admin/pages/_form_menu.html.haml
|
@@ -224,6 +227,8 @@ files:
|
|
224
227
|
- app/views/admin/tags/_form_tag.html.haml
|
225
228
|
- app/views/effective/alerts/_alert.html.haml
|
226
229
|
- app/views/effective/carousels/_carousel.html.haml
|
230
|
+
- app/views/effective/page_segments/_content.html.haml
|
231
|
+
- app/views/effective/page_segments/_menu.html.haml
|
227
232
|
- app/views/effective/pages/_menu.html.haml
|
228
233
|
- app/views/effective/pages/_page_menu.html.haml
|
229
234
|
- app/views/effective/tags/_fields.html.haml
|