pagy 5.10.1 → 6.0.4

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/lib/config/pagy.rb +36 -31
  4. data/lib/javascripts/pagy-dev.js +2 -2
  5. data/lib/javascripts/pagy-module.js +1 -1
  6. data/lib/javascripts/pagy.js +1 -1
  7. data/lib/locales/da.yml +2 -2
  8. data/lib/locales/de.yml +1 -1
  9. data/lib/locales/ko.yml +1 -1
  10. data/lib/locales/nn.yml +22 -0
  11. data/lib/pagy/backend.rb +1 -1
  12. data/lib/pagy/calendar/day.rb +13 -3
  13. data/lib/pagy/calendar/helper.rb +61 -0
  14. data/lib/pagy/calendar/month.rb +6 -2
  15. data/lib/pagy/calendar/quarter.rb +6 -2
  16. data/lib/pagy/calendar/week.rb +13 -8
  17. data/lib/pagy/calendar/year.rb +6 -2
  18. data/lib/pagy/calendar.rb +18 -8
  19. data/lib/pagy/console.rb +1 -1
  20. data/lib/pagy/countless.rb +2 -2
  21. data/lib/pagy/extras/arel.rb +1 -1
  22. data/lib/pagy/extras/array.rb +1 -1
  23. data/lib/pagy/extras/bootstrap.rb +6 -6
  24. data/lib/pagy/extras/bulma.rb +1 -1
  25. data/lib/pagy/extras/calendar.rb +12 -29
  26. data/lib/pagy/extras/countless.rb +1 -1
  27. data/lib/pagy/extras/elasticsearch_rails.rb +2 -11
  28. data/lib/pagy/extras/foundation.rb +4 -2
  29. data/lib/pagy/extras/gearbox.rb +1 -1
  30. data/lib/pagy/extras/headers.rb +1 -1
  31. data/lib/pagy/extras/i18n.rb +1 -1
  32. data/lib/pagy/extras/items.rb +1 -1
  33. data/lib/pagy/extras/materialize.rb +4 -4
  34. data/lib/pagy/extras/meilisearch.rb +15 -20
  35. data/lib/pagy/extras/metadata.rb +1 -1
  36. data/lib/pagy/extras/navs.rb +3 -3
  37. data/lib/pagy/extras/overflow.rb +2 -2
  38. data/lib/pagy/extras/searchkick.rb +3 -11
  39. data/lib/pagy/extras/semantic.rb +1 -1
  40. data/lib/pagy/extras/standalone.rb +5 -4
  41. data/lib/pagy/extras/support.rb +1 -1
  42. data/lib/pagy/extras/trim.rb +2 -2
  43. data/lib/pagy/extras/uikit.rb +1 -1
  44. data/lib/pagy/frontend.rb +2 -2
  45. data/lib/pagy/i18n.rb +1 -1
  46. data/lib/pagy/url_helpers.rb +4 -19
  47. data/lib/pagy.rb +17 -5
  48. data/lib/templates/bootstrap_nav.html.erb +1 -1
  49. data/lib/templates/bootstrap_nav.html.haml +1 -1
  50. data/lib/templates/bootstrap_nav.html.slim +1 -1
  51. data/lib/templates/nav.html.erb +1 -1
  52. data/lib/templates/nav.html.haml +1 -1
  53. data/lib/templates/nav.html.slim +1 -1
  54. metadata +7 -19
data/lib/pagy.rb CHANGED
@@ -1,11 +1,11 @@
1
- # See Pagy API documentation: https://ddnexus.github.io/pagy/api/pagy
1
+ # See Pagy API documentation: https://ddnexus.github.io/pagy/docs/api/pagy
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.10.1'
8
+ VERSION = '6.0.4'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -22,9 +22,10 @@ class Pagy
22
22
  fragment: '',
23
23
  link_extra: '',
24
24
  i18n_key: 'pagy.item_name',
25
- cycle: false }
25
+ cycle: false,
26
+ request_path: '' }
26
27
 
27
- attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :in, :from, :to, :prev, :next, :params
28
+ attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :in, :from, :to, :prev, :next, :params, :request_path
28
29
 
29
30
  # Merge and validate the options, do some simple arithmetic and set the instance variables
30
31
  def initialize(vars)
@@ -34,6 +35,7 @@ class Pagy
34
35
  setup_pages_var
35
36
  setup_offset_var
36
37
  setup_params_var
38
+ setup_request_path_var
37
39
  raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
38
40
 
39
41
  @from = [@offset - @outset + 1, @count].min
@@ -92,7 +94,7 @@ class Pagy
92
94
  def setup_vars(name_min)
93
95
  name_min.each do |name, min|
94
96
  raise VariableError.new(self, name, ">= #{min}", @vars[name]) \
95
- unless @vars[name] && instance_variable_set(:"@#{name}", @vars[name].to_i) >= min
97
+ unless @vars[name]&.respond_to?(:to_i) && instance_variable_set(:"@#{name}", @vars[name].to_i) >= min
96
98
  end
97
99
  end
98
100
 
@@ -116,6 +118,16 @@ class Pagy
116
118
  raise VariableError.new(self, :params, 'must be a Hash or a Proc', @params) \
117
119
  unless (@params = @vars[:params]).is_a?(Hash) || @params.is_a?(Proc)
118
120
  end
121
+
122
+ def setup_request_path_var
123
+ request_path = @vars[:request_path]
124
+ return if request_path.to_s.empty?
125
+
126
+ raise VariableError.new(self, :request_path, 'must be a bare path like "/foo"', request_path) \
127
+ if !request_path.start_with?('/') || request_path.include?('?')
128
+
129
+ @request_path = request_path
130
+ end
119
131
  end
120
132
 
121
133
  require 'pagy/backend'
@@ -6,7 +6,7 @@
6
6
  Usage: link.call( page_number [, text [, extra_attributes_string ]])
7
7
  -%>
8
8
  <% link = pagy_link_proc(pagy, link_extra: 'class="page-link"') -%>
9
- <%# -%><nav aria-label="pager" class="pagy-bootstrap-nav" role="navigation">
9
+ <%# -%><nav class="pagy-bootstrap-nav" role="navigation">
10
10
  <%# -%> <ul class="pagination">
11
11
  <% if pagy.prev -%> <li class="page-item prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></li>
12
12
  <% else -%> <li class="page-item prev disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.prev') %></a></li>
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy, link_extra: 'class="page-link"')
8
8
 
9
- %nav.pagy-bootstrap-nav{"aria-label" => "pager", :role => "navigation"}
9
+ %nav.pagy-bootstrap-nav{:role => "navigation"}
10
10
 
11
11
  %ul.pagination
12
12
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy, link_extra: 'class="page-link"')
8
8
 
9
- nav.pagy-bootstrap-nav role="navigation" aria-label="pager"
9
+ nav.pagy-bootstrap-nav role="navigation"
10
10
 
11
11
  ul.pagination
12
12
 
@@ -6,7 +6,7 @@
6
6
  Usage: link.call( page_number [, text [, extra_attributes_string ]])
7
7
  -%>
8
8
  <% link = pagy_link_proc(pagy) -%>
9
- <%# -%><nav aria-label="pager" class="pagy_nav pagination" role="navigation">
9
+ <%# -%><nav class="pagy_nav pagination" role="navigation">
10
10
  <% if pagy.prev -%> <span class="page prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></span>
11
11
  <% else -%> <span class="page prev disabled"><%== pagy_t('pagy.nav.prev') %></span>
12
12
  <% end -%>
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy)
8
8
 
9
- %nav.pagy_nav.pagination{"aria-label" => "pager", :role => "navigation"}
9
+ %nav.pagy_nav.pagination{:role => "navigation"}
10
10
 
11
11
  - if pagy.prev
12
12
  %span.page.prev!= link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
@@ -6,7 +6,7 @@
6
6
 
7
7
  - link = pagy_link_proc(pagy)
8
8
 
9
- nav.pagy_nav.pagination role="navigation" aria-label="pager"
9
+ nav.pagy_nav.pagination role="navigation"
10
10
 
11
11
  - if pagy.prev
12
12
  span.page.prev ==> link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.1
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
28
14
  email:
29
15
  - dd.nexus@gmail.com
@@ -55,6 +41,7 @@ files:
55
41
  - lib/locales/ko.yml
56
42
  - lib/locales/nb.yml
57
43
  - lib/locales/nl.yml
44
+ - lib/locales/nn.yml
58
45
  - lib/locales/pl.yml
59
46
  - lib/locales/pt-BR.yml
60
47
  - lib/locales/pt.yml
@@ -73,6 +60,7 @@ files:
73
60
  - lib/pagy/backend.rb
74
61
  - lib/pagy/calendar.rb
75
62
  - lib/pagy/calendar/day.rb
63
+ - lib/pagy/calendar/helper.rb
76
64
  - lib/pagy/calendar/month.rb
77
65
  - lib/pagy/calendar/quarter.rb
78
66
  - lib/pagy/calendar/week.rb
@@ -131,7 +119,7 @@ metadata:
131
119
  documentation_uri: https://ddnexus.github.io/pagy
132
120
  bug_tracker_uri: https://github.com/ddnexus/pagy/issues
133
121
  changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
134
- live_support: https://gitter.im/ruby-pagy/Lobby
122
+ support: https://github.com/ddnexus/pagy/discussions/categories/q-a
135
123
  post_install_message:
136
124
  rdoc_options: []
137
125
  require_paths:
@@ -147,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
135
  - !ruby/object:Gem::Version
148
136
  version: '0'
149
137
  requirements: []
150
- rubygems_version: 3.2.32
138
+ rubygems_version: 3.2.33
151
139
  signing_key:
152
140
  specification_version: 4
153
141
  summary: The kick-ass pagination ruby gem