effective_pages 3.4.1 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33c7720dd14a75e375dffed5ae8c21e7390cfd93727886785c72d574fbe23376
4
- data.tar.gz: 40ab7326b18be3a3a728461f604c4e2cfd827d75bacef55b2cd7bada79f5d513
3
+ metadata.gz: 9e671281634ffe553daa9e05de8737783dd3e75797e8f6cc8351c033195a3225
4
+ data.tar.gz: '03329baf24496ed2a2e1a6b2ec2a832ee6ca17b61be20f8ba22ce225d569262b'
5
5
  SHA512:
6
- metadata.gz: 4b9359a7b5c76c694ded55b524981df67e85f01e080c6ca2ae17c895762a52438d72d2c3b1ee508ff89d370eda0b921ea526af6b53800a353a8ad4ac5f79228e
7
- data.tar.gz: 5ccdeb32c10e7920fa017a4f6d0d5ca8ba6416290de99d202a4f972092e20b3e18cb53dc4c1d26d6e38aafbeae6135073382d0029a9717d6aae61c99112adf89
6
+ metadata.gz: e7c5fd0aed362d4734239243c1858c55be641c4bef6793d92ca629e78f60fc7a3f2db81c22f7a13f3c3e064a103e8ea93dc50a878879a7b3705227f5fc9c055e
7
+ data.tar.gz: 80995b8e52e82f1d6fb13942e8395e74ea523b351d116ecde7ccf96e6be100df79d6e39c9bf458a4b8d5591392e4c77b605b598e394b394f7364fc8ccc485af0
@@ -5,11 +5,12 @@ 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
- # Do nothing if page.banner is false
9
- return unless page.banner?
8
+ return unless page.banner? || EffectivePages.banners_force_randomize
10
9
 
11
- page_banner = page.page_banner
12
- page_banner ||= Effective::PageBanner.random.first if page.banner_random?
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
  raise("unable to find page banner for page #{page}") unless page_banner.present?
15
16
 
@@ -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
- = f.check_box :banner, label: 'Yes, display a page banner on this page'
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('Page Banner') do
31
- %p.text-muted Please visit #{link_to('Page Banners', effective_pages.admin_page_banners_path)} to add or update the page banners.
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.4.1'.freeze
2
+ VERSION = '3.4.2'.freeze
3
3
  end
@@ -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.1
4
+ version: 3.4.2
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-13 00:00:00.000000000 Z
11
+ date: 2022-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails