effective_pages 3.12.0 → 3.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +8 -2
- 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 +5 -3
- 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 +10 -0
- 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: 16a192b345e3f1e3b2d8dd56be2f185843e3a15d9853741c2ef9a9a28173cde1
|
4
|
+
data.tar.gz: a3e8fb8d856392c5f6bb9113addc693ab645d0dc04b7e033706ff67db6d2cb30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7adaf3d62e8774c7f6d83b37ce725a9e0d00886d13d467f860f0c724973e2c9e884bab54a80f7d3ce79d16402a5ec6c872b7cf963ac889e63843a75506d0e2
|
7
|
+
data.tar.gz: d1c93502f727d7225cf6b262c0b35fea80ccabeb7869c2d2fa2a0b67c30c37694b021b9e1ed140cbd9ee0dd281cc85a281bac765f70b5bb78da9cdb0720ad2a1
|
@@ -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,6 +19,9 @@ 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
|
+
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
|
+
|
22
25
|
acts_as_role_restricted if respond_to?(:acts_as_role_restricted)
|
23
26
|
acts_as_paginable
|
24
27
|
acts_as_published
|
@@ -137,7 +140,7 @@ module Effective
|
|
137
140
|
end
|
138
141
|
|
139
142
|
def to_s
|
140
|
-
title
|
143
|
+
title.presence || model_name.human
|
141
144
|
end
|
142
145
|
|
143
146
|
def menu_to_s
|
@@ -201,6 +204,9 @@ module Effective
|
|
201
204
|
menu_children_count <= 0
|
202
205
|
end
|
203
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
|
204
211
|
end
|
205
|
-
|
206
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, touch: true
|
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,12 +1,11 @@
|
|
1
1
|
= effective_form_with(model: [:admin, page], engine: true) do |f|
|
2
|
-
|
3
2
|
= f.text_field :title
|
4
3
|
|
5
4
|
-# acts_as_published
|
6
5
|
= f.hide_if(:save_as_draft, true) do
|
7
6
|
.row
|
8
7
|
.col-md-6
|
9
|
-
= f.datetime_field :published_start_at, hint: 'The page will be available starting on this date and time.'
|
8
|
+
= f.datetime_field :published_start_at, hint: 'The page will be available starting on this date and time. Leave blank to publish immediately.'
|
10
9
|
.col-md-6
|
11
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
|
12
11
|
|
@@ -49,7 +48,6 @@
|
|
49
48
|
|
50
49
|
= f.select :page_banner_id, Effective::PageBanner.sorted.all, label: 'Choose a page banner'
|
51
50
|
|
52
|
-
|
53
51
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
54
52
|
|
55
53
|
- if f.object.persisted? && f.object.menu_root_with_children?
|
@@ -68,4 +66,8 @@
|
|
68
66
|
- if f.object.new_record? && f.object.rich_texts.present?
|
69
67
|
= render '/admin/pages/rich_text_areas', page: page, f: f
|
70
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
|
+
|
71
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
|
@@ -65,6 +65,16 @@ class CreateEffectivePages < ActiveRecord::Migration[6.0]
|
|
65
65
|
|
66
66
|
add_index :page_sections, :name, :unique => true
|
67
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
|
+
|
68
78
|
create_table :carousel_items do |t|
|
69
79
|
t.string :carousel
|
70
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.1
|
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
|