effective_pages 3.4.1 → 3.4.3
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_banners_helper.rb +6 -5
- data/app/helpers/effective_page_sections_helper.rb +1 -1
- data/app/models/effective/page.rb +1 -1
- data/app/views/admin/pages/_form_page.html.haml +15 -6
- data/config/effective_pages.rb +1 -0
- data/lib/effective_pages/version.rb +1 -1
- data/lib/effective_pages.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: f5f3b0de9a5ca3fe12873d09d559072e5f29eab0857753c9fa7a16d91a4bdeea
|
4
|
+
data.tar.gz: dd73a0fedf8b38bc4f26b08dbad06b0e47a6cc7f073fc56e2574a31d074a374f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564e7333cc97ad0810faa5ef6ceeda0ab36d83f80ad79856a89191e47a223d52d5be0068f0dc85705b1be27c8e6d54f3e3c409f6c6f4cd9b06756a32bdc688a0
|
7
|
+
data.tar.gz: 8c87830c81761b1449c4ff8e611d569edb12264d5caae05a213aa0c306638b8491d9f126f339dba6c96b0893976f89a297e1210a3d580e85bfc76dd23fd9a97b
|
@@ -5,13 +5,14 @@ module EffectivePageBannersHelper
|
|
5
5
|
def render_page_banner(page, opts = {}, &block)
|
6
6
|
raise('expected a page') unless page.kind_of?(Effective::Page)
|
7
7
|
|
8
|
-
|
9
|
-
return unless page.banner?
|
8
|
+
return unless page.banner? || EffectivePages.banners_force_randomize
|
10
9
|
|
11
|
-
|
12
|
-
page_banner
|
10
|
+
# Always return a random banner if config.banners_force_randomize
|
11
|
+
page_banner = Effective::PageBanner.random.first if EffectivePages.banners_force_randomize
|
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
14
|
|
14
|
-
|
15
|
+
return if page_banner.blank?
|
15
16
|
|
16
17
|
if block_given?
|
17
18
|
yield(page_banner); nil
|
@@ -12,7 +12,7 @@ module EffectivePageSectionsHelper
|
|
12
12
|
name = name.to_s
|
13
13
|
|
14
14
|
page_section = effective_page_sections.find { |ps| ps.name == name }
|
15
|
-
|
15
|
+
return if page_section.blank?
|
16
16
|
|
17
17
|
if block_given?
|
18
18
|
yield(page_section); nil
|
@@ -97,7 +97,7 @@ module Effective
|
|
97
97
|
validates :menu_group, absence: true, if: -> { menu_root? && EffectivePages.menus.present? }
|
98
98
|
|
99
99
|
validate(if: -> { banner? && EffectivePages.banners? }) do
|
100
|
-
unless (page_banner.present? ^ banner_random?) # xor
|
100
|
+
unless (page_banner.present? ^ banner_random? ^ EffectivePages.banners_force_randomize) # xor
|
101
101
|
self.errors.add(:page_banner_id, "please select a page banner or random")
|
102
102
|
self.errors.add(:banner_random, "please select a page banner or random")
|
103
103
|
end
|
@@ -24,15 +24,24 @@
|
|
24
24
|
= f.text_field :slug, hint: "The slug controls this page's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This page is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
|
25
25
|
|
26
26
|
- if EffectivePages.banners?
|
27
|
-
|
27
|
+
- if EffectivePages.banners_force_randomize
|
28
|
+
= f.check_box :banner, label: 'Choose a page banner'
|
29
|
+
- else
|
30
|
+
= f.check_box :banner, label: 'Display a page banner on this page'
|
28
31
|
|
29
32
|
= f.show_if(:banner, true) do
|
30
|
-
= card
|
31
|
-
%p.text-muted
|
33
|
+
= card do
|
34
|
+
%p.text-muted
|
35
|
+
- if EffectivePages.banners_force_randomize
|
36
|
+
A random banner will always be displayed, or you may choose a specific banner below.
|
37
|
+
|
38
|
+
Please visit #{link_to('Page Banners', effective_pages.admin_page_banners_path)} to add or update the page banners.
|
39
|
+
|
40
|
+
- if !EffectivePages.banners_force_randomize
|
41
|
+
= f.check_box :banner_random, label: 'Display a random page banner. Ignored if you choose a page banner below.'
|
42
|
+
|
43
|
+
= f.select :page_banner_id, Effective::PageBanner.sorted.all, label: 'Choose a page banner'
|
32
44
|
|
33
|
-
= f.select :page_banner_id, Effective::PageBanner.sorted.all, label: 'Display this page banner'
|
34
|
-
%p - or -
|
35
|
-
= f.check_box :banner_random, label: 'Display a random page banner each time the page is refreshed'
|
36
45
|
|
37
46
|
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
|
38
47
|
|
data/config/effective_pages.rb
CHANGED
@@ -63,6 +63,7 @@ EffectivePages.setup do |config|
|
|
63
63
|
# Allow a page banner to be selected on the Admin::Pages#edit screen
|
64
64
|
# Banners can be CRUD by the admin
|
65
65
|
config.banners = false
|
66
|
+
config.banners_force_randomize = false # at least return a random banner with render_page_banner()
|
66
67
|
config.banners_hint_text = 'Hint text that includes required image dimensions'
|
67
68
|
|
68
69
|
# Page Carousels
|
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, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text,
|
15
|
+
:use_effective_roles, :layout, :max_menu_depth, :banners_hint_text, :carousels_hint_text, :banners_force_randomize,
|
16
16
|
|
17
17
|
# Booleans
|
18
18
|
:banners,
|
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.
|
4
|
+
version: 3.4.3
|
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-10-
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|