effective_pages 3.4.0 → 3.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87905a09b84f0b8cf820024a81ea1066e5f213cd8e6b445f7cafc2d24eb86398
4
- data.tar.gz: 7bcd83be6059d46ee284e80420683eeb273df7d2f3788b1b84e0b5c6bb06d1c5
3
+ metadata.gz: 9e671281634ffe553daa9e05de8737783dd3e75797e8f6cc8351c033195a3225
4
+ data.tar.gz: '03329baf24496ed2a2e1a6b2ec2a832ee6ca17b61be20f8ba22ce225d569262b'
5
5
  SHA512:
6
- metadata.gz: b3ec4c9bb169cba79542e2d7d5d6db7d2e04bd3cc69b6e46848542e78cbd7cae0d57b8976e812be8309bb6116cfc6b9745e85f960bc8a8b95876c48b72f87430
7
- data.tar.gz: be88b345621ea1f0ee7f31e07a08a44392be1a34706463551b9548be2730bcf6fa77a698ace3ac0237af76290a310639a5521cce745bd8d602c8b715c4c1476f
6
+ metadata.gz: e7c5fd0aed362d4734239243c1858c55be641c4bef6793d92ca629e78f60fc7a3f2db81c22f7a13f3c3e064a103e8ea93dc50a878879a7b3705227f5fc9c055e
7
+ data.tar.gz: 80995b8e52e82f1d6fb13942e8395e74ea523b351d116ecde7ccf96e6be100df79d6e39c9bf458a4b8d5591392e4c77b605b598e394b394f7364fc8ccc485af0
@@ -5,6 +5,8 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
+ page_title 'Carousels'
9
+
8
10
  def permitted_params
9
11
  params.require(:effective_carousel_item).permit!
10
12
  end
@@ -3,8 +3,11 @@ module Admin
3
3
  before_action(:authenticate_user!) if defined?(Devise)
4
4
  before_action { EffectiveResources.authorize!(self, :admin, :effective_pages) }
5
5
 
6
+
6
7
  include Effective::CrudController
7
8
 
9
+ page_title 'Menus'
10
+
8
11
  resource_scope -> { Effective::Page.all }
9
12
 
10
13
  if (config = EffectivePages.layout)
@@ -8,13 +8,13 @@ class EffectivePageSectionsDatatable < Effective::Datatable
8
8
  col :updated_at, visible: false
9
9
 
10
10
  col :name
11
- col :hint
12
11
 
13
12
  col :title
14
13
  col :rich_text_body
15
14
 
16
15
  col :file
17
16
 
17
+ col :hint, visible: false
18
18
  col :link_label, visible: false
19
19
  col :link_url, visible: false
20
20
  col :caption, visible: false
@@ -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
@@ -7,15 +7,15 @@
7
7
  = f.text_field :title
8
8
 
9
9
  - if defined?(EffectiveArticleEditor)
10
- = f.article_editor :rich_text_body, label: 'Body', hint: 'The main content'
10
+ = f.article_editor :rich_text_body, label: 'Body'
11
11
  - else
12
- = f.rich_text_area :rich_text_body, label: 'Body', hint: 'The main content'
12
+ = f.rich_text_area :rich_text_body, label: 'Body'
13
13
 
14
14
  .row
15
15
  .col= f.text_field :link_label
16
16
  .col= f.url_field :link_url
17
17
 
18
- = f.file_field :file, label: 'Image Attachment', hint: 'The image to display on this carousel item'
19
- = f.text_field :caption, hint: 'Displayed alongside the image'
18
+ = f.file_field :file, label: 'Image attachment', hint: EffectivePages.carousels_hint_text
19
+ = f.text_field :caption, hint: 'Optional'
20
20
 
21
21
  = effective_submit(f)
@@ -1,11 +1,5 @@
1
- %h1= @page_title
2
-
3
- %p
4
- Click Reorder to drag & drop reorder carousel items.
5
- Edit an item to change its content.
6
-
7
1
  - EffectivePages.carousels.each do |carousel|
8
- %h3 #{carousel.to_s.titleize} Carousel
9
- - datatable = EffectiveCarouselItemsDatatable.new(carousel: carousel)
10
- = render_datatable(datatable, simple: true, inline: true)
11
- %hr.my-5
2
+ .bg-white.my-5.p-3.rounded
3
+ %h3.mb-0 #{carousel.to_s.titleize} Carousel
4
+ - datatable = EffectiveCarouselItemsDatatable.new(carousel: carousel)
5
+ = render_datatable(datatable, simple: true, inline: true)
@@ -1,11 +1,5 @@
1
- %h1= @page_title
2
-
3
- %p
4
- Click Reorder to drag & drop reorder menu items.
5
- Edit an item to reorder its children items.
6
-
7
1
  - EffectivePages.menus.each do |menu|
8
- %h3 #{menu.to_s.titleize} Menu
9
- - datatable = EffectivePagesMenuDatatable.new(menu: menu)
10
- = render_datatable(datatable, simple: true, inline: true)
11
- %hr.my-5
2
+ .bg-white.my-5.p-3.rounded
3
+ %h3.mb-0 #{menu.to_s.titleize} Menu
4
+ - datatable = EffectivePagesMenuDatatable.new(menu: menu)
5
+ = render_datatable(datatable, simple: true, inline: true)
@@ -1,8 +1,7 @@
1
1
  = effective_form_with(model: [:admin, page_banner], engine: true) do |f|
2
- = f.text_field :name, hint: 'The name of this banner. Used for reference only'
3
-
4
- = f.file_field :file, label: 'Image Attachment', hint: 'Upload an image to display on this banner'
5
- = f.text_field :caption, hint: 'Displayed alongside the image'
2
+ = f.text_field :name, hint: 'The name of this banner, used only for reference'
3
+ = f.file_field :file, label: 'Image attachment', hint: EffectivePages.banners_hint_text
4
+ = f.text_field :caption, hint: 'Optional. Displayed alongside the image'
6
5
 
7
6
  -# - if defined?(EffectiveArticleEditor)
8
7
  -# = f.article_editor :rich_text_body, label: 'Body', hint: 'The main content'
@@ -5,7 +5,8 @@
5
5
  = f.static_field :name
6
6
 
7
7
  - if f.object.hint.present?
8
- .mb-4= f.object.hint.html_safe
8
+ %h4.mt-0 Instructions
9
+ %p= f.object.hint.html_safe
9
10
 
10
11
  = f.text_field :title
11
12
 
@@ -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,10 +63,13 @@ 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()
67
+ config.banners_hint_text = 'Hint text that includes required image dimensions'
66
68
 
67
69
  # Page Carousels
68
70
  # The menu names a page can belong to
69
71
  config.carousels = false
70
72
  # config.carousels = [:home, :secondary]
73
+ config.carousels_hint_text = 'Hint text that includes required image dimensions'
71
74
 
72
75
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.4.0'.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,
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.0
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-11 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