effective_posts 2.9.5 → 2.10.0

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: 776637da3a1153b09c0fc45d297ec37983ae2e774ea5c52f334eb2b3e5b33626
4
- data.tar.gz: 58b26ef64faba208c5e4d233b8df7c1af05465f528e783136f703ea3c58d53fd
3
+ metadata.gz: ac4e05cce1c65124d62fe558a99e3126b6b65a24062850ada6d0d9c0a8b926ad
4
+ data.tar.gz: 94990fdcec750ff87644840f9ffe4e5e88cd277e8281e81a738518a2bb032370
5
5
  SHA512:
6
- metadata.gz: bdce39fc8b3df2c20d27e4ee1d0e903bacd6c34564565512573ce06d41ca55dde9aa807284c178c7f1dc4163aab2951ce588f85d5c1644ee3babd8f7203baf03
7
- data.tar.gz: 93c9d6af7afe01b0ad44a42ee293e9fbf80b143334a2577c0f4649d5bc17cefe2179675b8bc852a3dfad5d78ab4d132ab4402a31604004901e19b64d1d58654a
6
+ metadata.gz: 49dbea147d32f61c7e263919165f968f6e02676e5eab13299fa0f1e2c51aa4ade64a12274e14ef2d6fc52b70c05fb213b2b814e236a03addea9303828636b49b
7
+ data.tar.gz: 4b6fc77c7b355ad8d981b25459f96e8d1d607f60ae9e944f0925a586bebfc92e0552b6f832cfa802a8d5ac4d3385f0b9b3182ec650b166f0883e3747e22c7cb2
@@ -16,8 +16,6 @@ module Effective
16
16
  unpublished: EffectiveResources.authorized?(self, :admin, :effective_posts)
17
17
  )
18
18
 
19
- @posts = @posts.paginate(page: params[:page])
20
-
21
19
  if EffectivePosts.event_categories.include?(@category)
22
20
  @posts = @posts.reorder(:start_at).where('start_at > ?', Time.zone.now)
23
21
  end
@@ -35,6 +33,16 @@ module Effective
35
33
 
36
34
  EffectiveResources.authorize!(self, :index, Effective::Post)
37
35
 
36
+ @posts_count = @posts.limit(nil).offset(nil).count
37
+
38
+ page = EffectiveResources.validate_page!(
39
+ params[:page],
40
+ collection_count: @posts_count,
41
+ per_page: EffectivePosts.per_page
42
+ )
43
+
44
+ @posts = @posts.paginate(page: page)
45
+
38
46
  @page_title ||= [(@category || view_context.posts_name_label).to_s.titleize, (" - Page #{params[:page]}" if params[:page])].compact.join
39
47
  @canonical_url ||= helpers.effective_post_category_url(params[:category], page: params[:page])
40
48
  end
@@ -49,7 +57,7 @@ module Effective
49
57
 
50
58
  EffectiveResources.authorize!(self, :show, @post)
51
59
 
52
- if admin
60
+ if admin
53
61
  flash.now[:warning] = [
54
62
  'Hi Admin!',
55
63
  ('You are viewing a hidden post.' unless @post.published?),
@@ -5,4 +5,4 @@
5
5
  = render @posts
6
6
 
7
7
  %nav.d-flex.justify-content-center
8
- = bootstrap_paginate(@posts, per_page: EffectivePosts.per_page)
8
+ = bootstrap_paginate(@posts, per_page: EffectivePosts.per_page, collection_count: @posts_count)
@@ -1,11 +1,13 @@
1
1
  EffectivePosts.setup do |config|
2
2
  # Every post must have a category
3
3
  # Each of these categories parameterized value will be a top level route
4
+ # Include 'Events' here to allow posts in an Events category
4
5
  config.categories = ['News', 'Events']
5
6
 
6
- # Which of the above categories will be considered post.event?
7
+ # Which of the above categories will be considered post.event?
7
8
  # Used to select the fields on the Admin form
8
9
  # Can't be unique. Must be subset of config.categories
10
+ # Use ['Events'] when config.categories includes 'Events'
9
11
  config.event_categories = ['Events']
10
12
 
11
13
  # Create top level routes for each category
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '2.9.5'.freeze
2
+ VERSION = '2.10.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.5
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect