effective_pages 3.10.0 → 3.10.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: 27068cf38aee344c7a13bfca4c21f5c5076c65df506085efc3c51c7ed3ebb88c
4
- data.tar.gz: ccc55fbf35ace55fa7243f3236305e5a847287a8397874e737513f33fdde1f24
3
+ metadata.gz: 1fd5033b1c1e0aeb36a9d35216a9f47e7e5f68de94dbe8688f8a4cf6e606a690
4
+ data.tar.gz: 3512cfb9bba19e4a2c71c56c86f05efe574bc7dbe0e924f138f2873b4da20c7a
5
5
  SHA512:
6
- metadata.gz: e5cfd09bc93c3caa960614850e26e877db3a754d4136ef427d645f376108cf5a5797deb4b089694865b618769344705481b9451aa22e5b848eeb5bd55239326b
7
- data.tar.gz: 4a3b0af8da3d99f927a18322e7aefce5b080c4d22e2c8cd1633d1000093f3e0a4b6ecfc26c73e9aedfbb5789191902afa75ab4feb72aaefb8120abc0092512b3
6
+ metadata.gz: 3e8b8bba6f888898cc7e6ba2508b4d0cacd97881011c57e0dafe1ddb63f22b74c6da0db650f8e0bbd9b4b182f6f836c5167f6da95a764b31b1c5b590cb6e86b6
7
+ data.tar.gz: 01bba194d58a6d6faae7cd5cfa2773f92e165d13c2984015709905475328b019b5ec68b1072d6467ba5249e425ecc9a2d9f89c8276c550d5be2bb28feea7432a
@@ -1,23 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
  module EffectiveCarouselsHelper
3
3
 
4
- def render_carousel(name, options = {}, &block)
5
- name = name.to_s
6
- carousel = Array(EffectivePages.carousels).find { |carousel| carousel.to_s == name }
4
+ def render_carousel(name, carousel_options = {})
5
+ carousel = Array(EffectivePages.carousels).find { |carousel| carousel.to_s == name.to_s }
7
6
 
8
7
  if carousel.blank?
9
8
  raise("unable to find carousel #{name}. Please add it to config/initializers/effective_pages.rb")
10
9
  end
11
10
 
12
- carousel_items = Effective::CarouselItem.sorted.deep.where(carousel: carousel)
13
- return if carousel_items.blank?
14
-
15
- if block_given?
16
- yield(carousel_items); nil
17
- else
18
- render('effective/carousels/carousel', carousel: carousel, carousel_items: carousel_items, carousel_options: options)
19
- end
20
-
11
+ render('effective/carousels/carousel', carousel: carousel, carousel_options: carousel_options)
21
12
  end
22
13
 
23
14
  end
@@ -1,27 +1,27 @@
1
- - uid = "effective-carousel-#{carousel}-#{Time.zone.now.to_i}"
2
- - options = carousel_options
1
+ = cache([carousel, Effective::CarouselItem.all.cache_key]) do
2
+ - carousel_items = Effective::CarouselItem.sorted.deep.where(carousel: carousel).to_a
3
+ - uid = "effective-carousel-#{carousel}-#{Time.zone.now.to_i}"
3
4
 
4
- - raise('expected one or more carousel items') unless carousel_items.present?
5
+ - if carousel_items.present?
6
+ .carousel.slide{id: uid, 'data-ride': 'carousel', **carousel_options}
7
+ %ol.carousel-indicators
8
+ - carousel_items.each_with_index do |item, index|
9
+ %li{'data-target': '#' + uid, 'data-slide-to': index, class: ('active' if index == 0)}
5
10
 
6
- .carousel.slide{id: uid, 'data-ride': 'carousel', **options}
7
- %ol.carousel-indicators
8
- - carousel_items.each_with_index do |item, index|
9
- %li{'data-target': '#' + uid, 'data-slide-to': index, class: ('active' if index == 0)}
11
+ .carousel-inner
12
+ - carousel_items.each_with_index do |item, index|
13
+ .carousel-item{class: ('active' if index == 0)}
14
+ - if item.caption.blank?
15
+ = image_tag(item.file, class: 'd-block w-100', alt: "Slide #{index+1}")
16
+ - else
17
+ = image_tag(item.file, alt: item.caption)
18
+ .carousel-caption.d-none.d-md-block
19
+ %p= item.caption
10
20
 
11
- .carousel-inner
12
- - carousel_items.each_with_index do |item, index|
13
- .carousel-item{class: ('active' if index == 0)}
14
- - if item.caption.blank?
15
- = image_tag(item.file, class: 'd-block w-100', alt: "Slide #{index+1}")
16
- - else
17
- = image_tag(item.file, alt: item.caption)
18
- .carousel-caption.d-none.d-md-block
19
- %p= item.caption
21
+ %button.carousel-control-prev{'data-target': '#' + uid, type: 'button', 'data-slide': 'prev'}
22
+ %span.carousel-control-prev-icon{'aria-hidden': true}
23
+ %span.sr-only Previous
20
24
 
21
- %button.carousel-control-prev{'data-target': '#' + uid, type: 'button', 'data-slide': 'prev'}
22
- %span.carousel-control-prev-icon{'aria-hidden': true}
23
- %span.sr-only Previous
24
-
25
- %button.carousel-control-next{'data-target': '#' + uid, type: 'button', 'data-slide': 'next'}
26
- %span.carousel-control-next-icon{'aria-hidden': true}
27
- %span.sr-only Next
25
+ %button.carousel-control-next{'data-target': '#' + uid, type: 'button', 'data-slide': 'next'}
26
+ %span.carousel-control-next-icon{'aria-hidden': true}
27
+ %span.sr-only Next
@@ -1,7 +1,7 @@
1
1
  - raise('expected a menu') unless menu.present?
2
2
  - menu = menu.to_s
3
3
 
4
- = cache([menu, current_user, Effective::Page.for_menu(menu).maximum(:updated_at)]) do
4
+ = cache([menu, current_user, Effective::Page.all.cache_key]) do
5
5
  - # Renders menu_root? level pages and their immediate children
6
6
  - Effective::Page.for_menu_root(menu).each do |page|
7
7
  - next unless EffectiveResources.authorized?(self, :show, page)
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.10.0'.freeze
2
+ VERSION = '3.10.2'.freeze
3
3
  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.10.0
4
+ version: 3.10.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: 2024-01-05 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails