pagy 5.2.3 → 5.5.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 +4 -4
- data/lib/config/pagy.rb +25 -12
- data/lib/javascripts/pagy.js +15 -10
- data/lib/pagy/calendar/day.rb +29 -0
- data/lib/pagy/calendar/month.rb +44 -0
- data/lib/pagy/calendar/week.rb +39 -0
- data/lib/pagy/calendar/year.rb +29 -0
- data/lib/pagy/calendar.rb +44 -102
- data/lib/pagy/countless.rb +2 -1
- data/lib/pagy/extras/bootstrap.rb +6 -6
- data/lib/pagy/extras/bulma.rb +10 -11
- data/lib/pagy/extras/calendar.rb +54 -24
- data/lib/pagy/extras/foundation.rb +8 -8
- data/lib/pagy/extras/{shared.rb → frontend_helpers.rb} +21 -6
- data/lib/pagy/extras/i18n.rb +14 -3
- data/lib/pagy/extras/items.rb +1 -1
- data/lib/pagy/extras/materialize.rb +6 -6
- data/lib/pagy/extras/navs.rb +5 -5
- data/lib/pagy/extras/overflow.rb +5 -5
- data/lib/pagy/extras/semantic.rb +8 -8
- data/lib/pagy/extras/standalone.rb +11 -8
- data/lib/pagy/extras/trim.rb +3 -3
- data/lib/pagy/extras/uikit.rb +8 -8
- data/lib/pagy/frontend.rb +11 -15
- data/lib/pagy/url_helpers.rb +23 -9
- data/lib/pagy.rb +19 -3
- data/lib/templates/foundation_nav.html.erb +1 -1
- data/lib/templates/foundation_nav.html.haml +1 -1
- data/lib/templates/foundation_nav.html.slim +1 -1
- data/lib/templates/uikit_nav.html.erb +1 -1
- data/lib/templates/uikit_nav.html.haml +1 -1
- data/lib/templates/uikit_nav.html.slim +1 -1
- metadata +9 -4
data/lib/pagy.rb
CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
|
|
5
5
|
|
6
6
|
# Core class
|
7
7
|
class Pagy
|
8
|
-
VERSION = '5.
|
8
|
+
VERSION = '5.5.0'
|
9
9
|
|
10
10
|
# Root pathname to get the path of Pagy files like templates or dictionaries
|
11
11
|
def self.root
|
@@ -24,7 +24,7 @@ class Pagy
|
|
24
24
|
i18n_key: 'pagy.item_name',
|
25
25
|
cycle: false }
|
26
26
|
|
27
|
-
attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :in, :from, :to, :prev, :next
|
27
|
+
attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :in, :from, :to, :prev, :next, :params
|
28
28
|
|
29
29
|
# Merge and validate the options, do some simple arithmetic and set the instance variables
|
30
30
|
def initialize(vars)
|
@@ -32,6 +32,7 @@ class Pagy
|
|
32
32
|
setup_vars(count: 0, page: 1, outset: 0)
|
33
33
|
setup_items_var
|
34
34
|
setup_pages_var
|
35
|
+
setup_params_var
|
35
36
|
raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
|
36
37
|
|
37
38
|
@offset = (@items * (@page - 1)) + @outset
|
@@ -43,7 +44,7 @@ class Pagy
|
|
43
44
|
end
|
44
45
|
|
45
46
|
# Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
46
|
-
def series(size
|
47
|
+
def series(size: @vars[:size])
|
47
48
|
return [] if size.empty?
|
48
49
|
raise VariableError.new(self, :size, 'to contain 4 items >= 0', size) \
|
49
50
|
unless size.is_a?(Array) && size.size == 4 && size.all? { |num| !num.negative? rescue false } # rubocop:disable Style/RescueModifier
|
@@ -70,6 +71,15 @@ class Pagy
|
|
70
71
|
series
|
71
72
|
end
|
72
73
|
|
74
|
+
# Allow the customization of the output (overridden by the calendar extra)
|
75
|
+
def label_for(page)
|
76
|
+
page.to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
def label
|
80
|
+
@page.to_s
|
81
|
+
end
|
82
|
+
|
73
83
|
protected
|
74
84
|
|
75
85
|
# Apply defaults, cleanup blanks and set @vars
|
@@ -94,6 +104,12 @@ class Pagy
|
|
94
104
|
def setup_pages_var
|
95
105
|
@pages = @last = [(@count.to_f / @items).ceil, 1].max
|
96
106
|
end
|
107
|
+
|
108
|
+
# Setup and validates the params
|
109
|
+
def setup_params_var
|
110
|
+
raise VariableError.new(self, :params, 'must be a Hash or a Proc', @params) \
|
111
|
+
unless (@params = @vars[:params]).is_a?(Hash) || @params.is_a?(Proc)
|
112
|
+
end
|
97
113
|
end
|
98
114
|
|
99
115
|
require 'pagy/backend'
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<% end -%>
|
14
14
|
<% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
|
15
15
|
<% if item.is_a?(Integer) -%> <li><%== link.call(item) %></li>
|
16
|
-
<% elsif item.is_a?(String) -%> <li class="current"><%=
|
16
|
+
<% elsif item.is_a?(String) -%> <li class="current"><%= pagy.label_for(item) %></li>
|
17
17
|
<% elsif item == :gap -%> <li class="ellipsis gap" aria-hidden="true"></li>
|
18
18
|
<% end -%>
|
19
19
|
<% end -%>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<% end -%>
|
6
6
|
<% pagy.series.each do |item| -%>
|
7
7
|
<% if item.is_a?(Integer) -%> <li><%== link.call(item) %></li>
|
8
|
-
<% elsif item.is_a?(String) -%> <li class="uk-active"><span><%==
|
8
|
+
<% elsif item.is_a?(String) -%> <li class="uk-active"><span><%== pagy.label_for(item) %></span></li>
|
9
9
|
<% elsif item == :gap -%> <li class="uk-disabled"><span><%== pagy_t('pagy.nav.gap') %></span></li>
|
10
10
|
<% end -%>
|
11
11
|
<% end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|
@@ -54,6 +54,10 @@ files:
|
|
54
54
|
- lib/pagy.rb
|
55
55
|
- lib/pagy/backend.rb
|
56
56
|
- lib/pagy/calendar.rb
|
57
|
+
- lib/pagy/calendar/day.rb
|
58
|
+
- lib/pagy/calendar/month.rb
|
59
|
+
- lib/pagy/calendar/week.rb
|
60
|
+
- lib/pagy/calendar/year.rb
|
57
61
|
- lib/pagy/console.rb
|
58
62
|
- lib/pagy/countless.rb
|
59
63
|
- lib/pagy/exceptions.rb
|
@@ -65,6 +69,7 @@ files:
|
|
65
69
|
- lib/pagy/extras/countless.rb
|
66
70
|
- lib/pagy/extras/elasticsearch_rails.rb
|
67
71
|
- lib/pagy/extras/foundation.rb
|
72
|
+
- lib/pagy/extras/frontend_helpers.rb
|
68
73
|
- lib/pagy/extras/gearbox.rb
|
69
74
|
- lib/pagy/extras/headers.rb
|
70
75
|
- lib/pagy/extras/i18n.rb
|
@@ -76,7 +81,6 @@ files:
|
|
76
81
|
- lib/pagy/extras/overflow.rb
|
77
82
|
- lib/pagy/extras/searchkick.rb
|
78
83
|
- lib/pagy/extras/semantic.rb
|
79
|
-
- lib/pagy/extras/shared.rb
|
80
84
|
- lib/pagy/extras/standalone.rb
|
81
85
|
- lib/pagy/extras/support.rb
|
82
86
|
- lib/pagy/extras/trim.rb
|
@@ -102,7 +106,8 @@ files:
|
|
102
106
|
homepage: https://github.com/ddnexus/pagy
|
103
107
|
licenses:
|
104
108
|
- MIT
|
105
|
-
metadata:
|
109
|
+
metadata:
|
110
|
+
rubygems_mfa_required: 'true'
|
106
111
|
post_install_message:
|
107
112
|
rdoc_options: []
|
108
113
|
require_paths:
|