pagy 8.6.0 → 9.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +5 -5
  3. data/apps/demo.ru +8 -9
  4. data/apps/keyset_ar.ru +236 -0
  5. data/apps/keyset_s.ru +238 -0
  6. data/apps/rails.ru +7 -9
  7. data/apps/repro.ru +5 -6
  8. data/apps/tmp/calendar.sqlite3 +0 -0
  9. data/apps/tmp/calendar.sqlite3-shm +0 -0
  10. data/apps/tmp/calendar.sqlite3-wal +0 -0
  11. data/apps/tmp/local_secret.txt +1 -1
  12. data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
  13. data/apps/tmp/{pagy-rails.sqlite3 → pagy-keyset-ar.sqlite3-shm} +0 -0
  14. data/apps/tmp/pagy-keyset-ar.sqlite3-wal +0 -0
  15. data/apps/tmp/pagy-keyset-s.sqlite3 +0 -0
  16. data/bin/pagy +4 -2
  17. data/config/pagy.rb +34 -31
  18. data/javascripts/pagy-module.js +1 -1
  19. data/javascripts/pagy.js +2 -2
  20. data/javascripts/pagy.min.js +2 -2
  21. data/javascripts/pagy.min.js.map +3 -3
  22. data/javascripts/pagy.mjs +2 -2
  23. data/lib/pagy/b64.rb +33 -0
  24. data/lib/pagy/backend.rb +21 -17
  25. data/lib/pagy/calendar/day.rb +1 -1
  26. data/lib/pagy/calendar/month.rb +1 -1
  27. data/lib/pagy/calendar/quarter.rb +1 -1
  28. data/lib/pagy/calendar/unit.rb +7 -10
  29. data/lib/pagy/calendar/week.rb +1 -1
  30. data/lib/pagy/calendar/year.rb +1 -1
  31. data/lib/pagy/calendar.rb +5 -5
  32. data/lib/pagy/countless.rb +11 -15
  33. data/lib/pagy/extras/arel.rb +8 -10
  34. data/lib/pagy/extras/array.rb +4 -6
  35. data/lib/pagy/extras/bootstrap.rb +5 -5
  36. data/lib/pagy/extras/bulma.rb +10 -7
  37. data/lib/pagy/extras/calendar.rb +4 -5
  38. data/lib/pagy/extras/countless.rb +15 -13
  39. data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
  40. data/lib/pagy/extras/gearbox.rb +26 -26
  41. data/lib/pagy/extras/headers.rb +25 -24
  42. data/lib/pagy/extras/js_tools.rb +8 -8
  43. data/lib/pagy/extras/jsonapi.rb +26 -16
  44. data/lib/pagy/extras/keyset.rb +36 -0
  45. data/lib/pagy/extras/limit.rb +63 -0
  46. data/lib/pagy/extras/meilisearch.rb +11 -11
  47. data/lib/pagy/extras/metadata.rb +2 -2
  48. data/lib/pagy/extras/overflow.rb +6 -6
  49. data/lib/pagy/extras/pagy.rb +16 -16
  50. data/lib/pagy/extras/searchkick.rb +11 -11
  51. data/lib/pagy/extras/size.rb +2 -2
  52. data/lib/pagy/extras/standalone.rb +6 -6
  53. data/lib/pagy/extras/trim.rb +2 -2
  54. data/lib/pagy/frontend.rb +32 -33
  55. data/lib/pagy/i18n.rb +1 -1
  56. data/lib/pagy/keyset/active_record.rb +38 -0
  57. data/lib/pagy/keyset/sequel.rb +51 -0
  58. data/lib/pagy/keyset.rb +98 -0
  59. data/lib/pagy/shared_methods.rb +27 -0
  60. data/lib/pagy/url_helpers.rb +4 -4
  61. data/lib/pagy.rb +54 -68
  62. data/locales/ar.yml +2 -1
  63. data/locales/be.yml +1 -1
  64. data/locales/bg.yml +1 -1
  65. data/locales/bs.yml +1 -1
  66. data/locales/ca.yml +1 -1
  67. data/locales/ckb.yml +1 -1
  68. data/locales/cs.yml +1 -1
  69. data/locales/da.yml +1 -1
  70. data/locales/de.yml +1 -1
  71. data/locales/en.yml +1 -1
  72. data/locales/es.yml +1 -1
  73. data/locales/fr.yml +1 -1
  74. data/locales/hr.yml +1 -1
  75. data/locales/id.yml +1 -1
  76. data/locales/it.yml +1 -1
  77. data/locales/ja.yml +1 -1
  78. data/locales/km.yml +1 -1
  79. data/locales/ko.yml +1 -1
  80. data/locales/nb.yml +1 -1
  81. data/locales/nl.yml +1 -1
  82. data/locales/nn.yml +1 -1
  83. data/locales/pl.yml +1 -1
  84. data/locales/pt-BR.yml +1 -1
  85. data/locales/pt.yml +1 -1
  86. data/locales/ru.yml +1 -1
  87. data/locales/sr.yml +1 -1
  88. data/locales/sv-SE.yml +1 -1
  89. data/locales/sv.yml +1 -1
  90. data/locales/sw.yml +1 -1
  91. data/locales/ta.yml +1 -1
  92. data/locales/tr.yml +1 -1
  93. data/locales/uk.yml +1 -1
  94. data/locales/vi.yml +1 -1
  95. data/locales/zh-CN.yml +1 -1
  96. data/locales/zh-HK.yml +1 -1
  97. data/locales/zh-TW.yml +1 -1
  98. metadata +16 -16
  99. data/lib/pagy/extras/foundation.rb +0 -95
  100. data/lib/pagy/extras/items.rb +0 -64
  101. data/lib/pagy/extras/materialize.rb +0 -100
  102. data/lib/pagy/extras/semantic.rb +0 -94
  103. data/lib/pagy/extras/uikit.rb +0 -98
data/lib/pagy.rb CHANGED
@@ -2,48 +2,77 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'pathname'
5
+ require_relative 'pagy/shared_methods'
5
6
 
6
- # Core class
7
+ # Top superclass: it should define only what's common to all the subclasses
7
8
  class Pagy
8
- VERSION = '8.6.0'
9
+ VERSION = '9.0.2'
10
+
11
+ # Core default: constant for easy access, but mutable for customizable defaults
12
+ DEFAULT = { count_args: [:all], # rubocop:disable Style/MutableConstant
13
+ ends: true,
14
+ limit: 20,
15
+ outset: 0,
16
+ page: 1,
17
+ page_param: :page,
18
+ size: 7 } # AR friendly
9
19
 
10
20
  # Gem root pathname to get the path of Pagy files stylesheets, javascripts, apps, locales, etc.
11
21
  def self.root
12
22
  @root ||= Pathname.new(__dir__).parent.freeze
13
23
  end
14
24
 
15
- # Core default: constant for easy access, but mutable for customizable defaults
16
- DEFAULT = { page: 1, # rubocop:disable Style/MutableConstant
17
- items: 20,
18
- outset: 0,
19
- size: 7,
20
- ends: true,
21
- count_args: [:all], # AR friendly
22
- page_param: :page }
25
+ include SharedMethods
23
26
 
24
- attr_reader :count, :page, :items, :vars, :last, :offset, :in, :from, :to, :prev, :next
27
+ attr_reader :count, :from, :in, :last, :next, :offset, :prev, :to
25
28
  alias pages last
26
29
 
27
30
  # Merge and validate the options, do some simple arithmetic and set the instance variables
28
- def initialize(vars)
29
- normalize_vars(vars)
30
- setup_vars(count: 0, page: 1, outset: 0)
31
- setup_items_var
32
- setup_last_var
33
- raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
34
-
35
- setup_offset_var
31
+ def initialize(**vars)
32
+ assign_vars(DEFAULT, vars)
33
+ assign_and_check(count: 0, page: 1, outset: 0)
34
+ assign_limit
35
+ assign_offset
36
+ assign_last
37
+ check_overflow
36
38
  @from = [@offset - @outset + 1, @count].min
37
- @to = [@offset - @outset + @items, @count].min
39
+ @to = [@offset - @outset + @limit, @count].min
38
40
  @in = [@to - @from + 1, @count].min
41
+ assign_prev_and_next
42
+ end
43
+
44
+ # Setup @last (overridden by the gearbox extra)
45
+ def assign_last
46
+ @last = [(@count.to_f / @limit).ceil, 1].max
47
+ @last = @vars[:max_pages] if @vars[:max_pages] && @last > vars[:max_pages]
48
+ end
49
+
50
+ # Assign @offset (overridden by the gearbox extra)
51
+ def assign_offset
52
+ @offset = (@limit * (@page - 1)) + @outset # may be already set from gear_box
53
+ end
54
+
55
+ # Assign @prev and @next
56
+ def assign_prev_and_next
39
57
  @prev = (@page - 1 unless @page == 1)
40
58
  @next = @page == @last ? (1 if @vars[:cycle]) : @page + 1
41
59
  end
42
60
 
43
- # Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
61
+ # Checks the @page <= @last
62
+ def check_overflow
63
+ raise OverflowError.new(self, :page, "in 1..#{@last}", @page) if @page > @last
64
+ end
65
+
66
+ # Label for the current page. Allow the customization of the output (overridden by the calendar extra)
67
+ def label = @page.to_s
68
+
69
+ # Label for any page. Allow the customization of the output (overridden by the calendar extra)
70
+ def label_for(page) = page.to_s
71
+
72
+ # Return the array of page numbers and :gap e.g. [1, :gap, 8, "9", 10, :gap, 36]
44
73
  def series(size: @vars[:size], **_)
45
- raise VariableError.new(self, :size, 'to be a positive Integer or 0', size) \
46
- unless size.is_a?(Integer)
74
+ raise VariableError.new(self, :size, 'to be an Integer >= 0', size) \
75
+ unless size.is_a?(Integer) && size >= 0
47
76
  return [] if size.zero?
48
77
 
49
78
  [].tap do |series|
@@ -53,13 +82,13 @@ class Pagy
53
82
  left = ((size - 1) / 2.0).floor # left half might be 1 page shorter for even size
54
83
  start = if @page <= left # beginning pages
55
84
  1
56
- elsif @page > @last - (size - left) # end pages
85
+ elsif @page > (@last - size + left) # end pages
57
86
  @last - size + 1
58
87
  else # intermediate pages
59
88
  @page - left
60
89
  end
61
90
  series.push(*start...start + size)
62
- # Insert first and last ends plus gaps when needed
91
+ # Set first and last pages plus gaps when needed, respecting the size
63
92
  if vars[:ends] && size >= 7
64
93
  series[0] = 1 unless series[0] == 1
65
94
  series[1] = :gap unless series[1] == 2
@@ -70,51 +99,8 @@ class Pagy
70
99
  series[series.index(@page)] = @page.to_s
71
100
  end
72
101
  end
73
-
74
- # Label for any page. Allow the customization of the output (overridden by the calendar extra)
75
- def label_for(page)
76
- page.to_s
77
- end
78
-
79
- # Label for the current page. Allow the customization of the output (overridden by the calendar extra)
80
- def label
81
- @page.to_s
82
- end
83
-
84
- protected
85
-
86
- # Apply defaults, cleanup blanks and set @vars
87
- def normalize_vars(vars)
88
- @vars = DEFAULT.merge(vars.delete_if { |k, v| DEFAULT.key?(k) && (v.nil? || v == '') })
89
- end
90
-
91
- # Setup and validates the passed vars: var must be present and value.to_i must be >= to min
92
- def setup_vars(name_min)
93
- name_min.each do |name, min|
94
- raise VariableError.new(self, name, ">= #{min}", @vars[name]) \
95
- unless @vars[name]&.respond_to?(:to_i) && instance_variable_set(:"@#{name}", @vars[name].to_i) >= min
96
- end
97
- end
98
-
99
- # Setup @items (overridden by the gearbox extra)
100
- def setup_items_var
101
- setup_vars(items: 1)
102
- end
103
-
104
- # Setup @last (overridden by the gearbox extra)
105
- def setup_last_var
106
- @last = [(@count.to_f / @items).ceil, 1].max
107
- @last = vars[:max_pages] if vars[:max_pages] && @last > vars[:max_pages]
108
- end
109
- alias setup_pages_var setup_last_var
110
-
111
- # Setup @offset based on the :gearbox_items variable
112
- def setup_offset_var
113
- @offset = (@items * (@page - 1)) + @outset # may be already set from gear_box
114
- end
115
102
  end
116
103
 
117
- require_relative 'pagy/extras/size' # will be opt in in v9.0
118
104
  require_relative 'pagy/backend'
119
105
  require_relative 'pagy/frontend'
120
106
  require_relative 'pagy/exceptions'
data/locales/ar.yml CHANGED
@@ -8,6 +8,7 @@ ar:
8
8
  two: "صفحتين"
9
9
  few: "صفحات"
10
10
  many: "صفحات"
11
+ other: "صفحات"
11
12
  prev: "السابق"
12
13
  next: "التالي"
13
14
  prev: "&lt;"
@@ -25,4 +26,4 @@ ar:
25
26
  single_page: "عرض %{count} %{item_name}"
26
27
  multiple_pages: "عرض %{item_name} %{from}-%{to} من اجمالي %{count}"
27
28
  combo_nav_js: "الصفحة %{page_input} من %{pages}"
28
- items_selector_js: "عرض %{items_input} %{item_name} لكل صفحة"
29
+ limit_selector_js: "عرض %{limit_input} %{item_name} لكل صفحة"
data/locales/be.yml CHANGED
@@ -22,4 +22,4 @@ be:
22
22
  single_page: "%{count} %{item_name}"
23
23
  multiple_pages: "Усяго %{count} %{item_name}, паказаны з %{from} па %{to}"
24
24
  combo_nav_js: "Старонка %{page_input} з %{pages}"
25
- items_selector_js: "Паказаць %{items_input} %{item_name} на старонцы"
25
+ limit_selector_js: "Паказаць %{limit_input} %{item_name} на старонцы"
data/locales/bg.yml CHANGED
@@ -18,4 +18,4 @@ bg:
18
18
  single_page: "Показани са %{count} %{item_name}"
19
19
  multiple_pages: "Показани са %{item_name} %{from}-%{to} от %{count} общо"
20
20
  combo_nav_js: "Страница %{page_input} от %{pages}"
21
- items_selector_js: "Покажи %{items_input} %{item_name} на страница"
21
+ limit_selector_js: "Покажи %{limit_input} %{item_name} на страница"
data/locales/bs.yml CHANGED
@@ -22,4 +22,4 @@ bs:
22
22
  single_page: "Prikazuje se %{count} %{item_name}"
23
23
  multiple_pages: "Prikaz %{item_name} %{from}-%{to} od %{count} ukupno"
24
24
  combo_nav_js: "Stranica %{page_input} od %{pages}"
25
- items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
25
+ limit_selector_js: "Prikaži %{limit_input} %{item_name} po stranici"
data/locales/ca.yml CHANGED
@@ -18,4 +18,4 @@ ca:
18
18
  single_page: "Mostrant %{count} %{item_name}"
19
19
  multiple_pages: "Mostrant %{item_name} %{from}-%{to} de %{count} en total"
20
20
  combo_nav_js: "Pàgina %{page_input} de %{pages}"
21
- items_selector_js: "Mostra %{items_input} %{item_name} per pàgina"
21
+ limit_selector_js: "Mostra %{limit_input} %{item_name} per pàgina"
data/locales/ckb.yml CHANGED
@@ -15,4 +15,4 @@ ckb:
15
15
  single_page: "پیشاندانی %{count} %{item_name}"
16
16
  multiple_pages: "پشاندانی %{item_name}ی %{from}-%{to} لە کۆی %{count} بە گشتی"
17
17
  combo_nav_js: "پەڕی %{page_input} لە %{pages}"
18
- items_selector_js: "نیشاندانی %{items_input} %{item_name} لە هەر پەڕێک"
18
+ limit_selector_js: "نیشاندانی %{limit_input} %{item_name} لە هەر پەڕێک"
data/locales/cs.yml CHANGED
@@ -20,4 +20,4 @@ cs:
20
20
  single_page: "Zobrazeno %{count} %{item_name}"
21
21
  multiple_pages: "Zobrazeny položky %{from}-%{to} z %{count} celkem"
22
22
  combo_nav_js: "Strana %{page_input} z %{pages}"
23
- items_selector_js: "Zobrazit %{items_input} %{item_name} na stránce"
23
+ limit_selector_js: "Zobrazit %{limit_input} %{item_name} na stránce"
data/locales/da.yml CHANGED
@@ -18,4 +18,4 @@ da:
18
18
  single_page: "Viser %{count} %{item_name}"
19
19
  multiple_pages: "Viser %{item_name} %{from}-%{to} af %{count} totalt"
20
20
  combo_nav_js: "Side %{page_input} af %{pages}"
21
- items_selector_js: "Antal %{items_input} %{item_name} per side"
21
+ limit_selector_js: "Antal %{limit_input} %{item_name} per side"
data/locales/de.yml CHANGED
@@ -18,4 +18,4 @@ de:
18
18
  single_page: "Zeige %{count} %{item_name}"
19
19
  multiple_pages: "Zeige %{item_name} %{from}-%{to} von %{count} gesamt"
20
20
  combo_nav_js: "Seite %{page_input} von %{pages}"
21
- items_selector_js: "Zeige %{items_input} %{item_name} pro Seite"
21
+ limit_selector_js: "Zeige %{limit_input} %{item_name} pro Seite"
data/locales/en.yml CHANGED
@@ -18,4 +18,4 @@ en:
18
18
  single_page: "Displaying %{count} %{item_name}"
19
19
  multiple_pages: "Displaying %{item_name} %{from}-%{to} of %{count} in total"
20
20
  combo_nav_js: "Page %{page_input} of %{pages}"
21
- items_selector_js: "Show %{items_input} %{item_name} per page"
21
+ limit_selector_js: "Show %{limit_input} %{item_name} per page"
data/locales/es.yml CHANGED
@@ -18,4 +18,4 @@ es:
18
18
  single_page: "Mostrando %{count} %{item_name}"
19
19
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} de %{count} en total"
20
20
  combo_nav_js: "Página %{page_input} de %{pages}"
21
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
21
+ limit_selector_js: "Mostrar %{limit_input} %{item_name} por página"
data/locales/fr.yml CHANGED
@@ -18,4 +18,4 @@ fr:
18
18
  single_page: "Affichage de %{count} %{item_name}"
19
19
  multiple_pages: "Affichage des %{item_name} %{from} à %{to} sur %{count} au total"
20
20
  combo_nav_js: "Page %{page_input} sur %{pages}"
21
- items_selector_js: "Afficher %{items_input} %{item_name} par page"
21
+ limit_selector_js: "Afficher %{limit_input} %{item_name} par page"
data/locales/hr.yml CHANGED
@@ -22,4 +22,4 @@ hr:
22
22
  single_page: "Prikazuje se %{count} %{item_name}"
23
23
  multiple_pages: "Prikaz %{item_name} %{from}-%{to} od %{count} ukupno"
24
24
  combo_nav_js: "Stranica %{page_input} od %{pages}"
25
- items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
25
+ limit_selector_js: "Prikaži %{limit_input} %{item_name} po stranici"
data/locales/id.yml CHANGED
@@ -16,4 +16,4 @@ id:
16
16
  single_page: "Menampilkan %{count} %{item_name}"
17
17
  multiple_pages: "Menampilkan %{item_name} %{from}-%{to} dari total %{count}"
18
18
  combo_nav_js: "Halaman %{page_input} dari %{pages}"
19
- items_selector_js: "Tampilkan %{items_input} %{item_name} per halaman"
19
+ limit_selector_js: "Tampilkan %{limit_input} %{item_name} per halaman"
data/locales/it.yml CHANGED
@@ -18,4 +18,4 @@ it:
18
18
  single_page: "Visualizzazione di %{count} %{item_name}"
19
19
  multiple_pages: "Visualizzazione %{item_name} %{from}-%{to} di %{count} in totale"
20
20
  combo_nav_js: "Pagina %{page_input} di %{pages}"
21
- items_selector_js: "Mostra %{items_input} %{item_name} per pagina"
21
+ limit_selector_js: "Mostra %{limit_input} %{item_name} per pagina"
data/locales/ja.yml CHANGED
@@ -16,4 +16,4 @@ ja:
16
16
  single_page: "%{count} 件の%{item_name}"
17
17
  multiple_pages: "%{count} 件中 %{from}-%{to} 件目の%{item_name}を表示中"
18
18
  combo_nav_js: "%{page_input} / %{pages} ページ"
19
- items_selector_js: "%{items_input} 件ずつ表示"
19
+ limit_selector_js: "%{limit_input} 件ずつ表示"
data/locales/km.yml CHANGED
@@ -16,4 +16,4 @@ km:
16
16
  single_page: "បង្ហាញ %{count} %{item_name}"
17
17
  multiple_pages: "បង្ហាញ %{item_name} %{from}-%{to} នៃ %{count} ជាចំនួនសរុប"
18
18
  combo_nav_js: "ទំព័រ %{page_input} នៃ %{pages}"
19
- items_selector_js: "បង្ហាញ %{items_input} %{item_name} ក្នុង ១ ទំព័រ"
19
+ limit_selector_js: "បង្ហាញ %{limit_input} %{item_name} ក្នុង ១ ទំព័រ"
data/locales/ko.yml CHANGED
@@ -14,4 +14,4 @@ ko:
14
14
  single_page: "%{count}개의 %{item_name} 표시됨"
15
15
  multiple_pages: "총 %{count}개의 %{item_name} 중 %{from}-%{to}"
16
16
  combo_nav_js: "총 %{pages} 중 %{page_input} 페이지"
17
- items_selector_js: "페이지 당 %{items_input}개 표시%"
17
+ limit_selector_js: "페이지 당 %{limit_input}개 표시%"
data/locales/nb.yml CHANGED
@@ -18,4 +18,4 @@ nb:
18
18
  single_page: "Viser %{count} %{item_name}"
19
19
  multiple_pages: "Viser %{item_name} %{from}-%{to} av totalt %{count}"
20
20
  combo_nav_js: "Side %{page_input} av %{pages}"
21
- items_selector_js: "Vis %{items_input} %{item_name} per side"
21
+ limit_selector_js: "Vis %{limit_input} %{item_name} per side"
data/locales/nl.yml CHANGED
@@ -18,4 +18,4 @@ nl:
18
18
  single_page: "Toont %{count} %{item_name}"
19
19
  multiple_pages: "Toont %{from}-%{to} %{item_name} van %{count} in totaal"
20
20
  combo_nav_js: "Pagina %{page_input} van %{pages}"
21
- items_selector_js: "Toont %{items_input} %{item_name} per pagina"
21
+ limit_selector_js: "Toont %{limit_input} %{item_name} per pagina"
data/locales/nn.yml CHANGED
@@ -18,4 +18,4 @@ nn:
18
18
  single_page: "Viser %{count} %{item_name}"
19
19
  multiple_pages: "Viser %{item_name} %{from}-%{to} av totalt %{count}"
20
20
  combo_nav_js: "Side %{page_input} av %{pages}"
21
- items_selector_js: "Vis %{items_input} %{item_name} per side"
21
+ limit_selector_js: "Vis %{limit_input} %{item_name} per side"
data/locales/pl.yml CHANGED
@@ -22,4 +22,4 @@ pl:
22
22
  single_page: "Wyświetlono %{count} %{item_name}"
23
23
  multiple_pages: "Wyświetlono %{item_name} %{from}-%{to} z wszystkich %{count}"
24
24
  combo_nav_js: "Strona %{page_input} z %{pages}"
25
- items_selector_js: "Pokaż %{items_input} %{item_name} na stronie"
25
+ limit_selector_js: "Pokaż %{limit_input} %{item_name} na stronie"
data/locales/pt-BR.yml CHANGED
@@ -18,4 +18,4 @@ pt-BR:
18
18
  single_page: "Mostrando %{count} %{item_name}"
19
19
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} do total de %{count}"
20
20
  combo_nav_js: "Página %{page_input} de %{pages}"
21
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
21
+ limit_selector_js: "Mostrar %{limit_input} %{item_name} por página"
data/locales/pt.yml CHANGED
@@ -18,4 +18,4 @@ pt:
18
18
  single_page: "Mostrando %{count} %{item_name}"
19
19
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} de um total de %{count}"
20
20
  combo_nav_js: "Página %{page_input} de %{pages}"
21
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
21
+ limit_selector_js: "Mostrar %{limit_input} %{item_name} por página"
data/locales/ru.yml CHANGED
@@ -22,4 +22,4 @@ ru:
22
22
  single_page: "%{count} %{item_name}"
23
23
  multiple_pages: "Всего %{count} %{item_name}, показаны с %{from} по %{to}"
24
24
  combo_nav_js: "Страница %{page_input} из %{pages}"
25
- items_selector_js: "Показать %{items_input} %{item_name} на странице"
25
+ limit_selector_js: "Показать %{limit_input} %{item_name} на странице"
data/locales/sr.yml CHANGED
@@ -22,4 +22,4 @@ sr:
22
22
  single_page: "Приказује се %{count} %{item_name}"
23
23
  multiple_pages: "Приказ %{item_name} %{from}-%{to} од %{count} укупно"
24
24
  combo_nav_js: "Страниca %{page_input} од %{pages}"
25
- items_selector_js: "Прикажи %{items_input} %{item_name} по страниcи"
25
+ limit_selector_js: "Прикажи %{limit_input} %{item_name} по страниcи"
data/locales/sv-SE.yml CHANGED
@@ -18,4 +18,4 @@ sv-SE:
18
18
  single_page: "Visar %{count} %{item_name}"
19
19
  multiple_pages: "Visar %{item_name} %{from}-%{to} av %{count} totalt"
20
20
  combo_nav_js: "Sida %{page_input} av %{pages}"
21
- items_selector_js: "Visa %{items_input} %{item_name} per sida"
21
+ limit_selector_js: "Visa %{limit_input} %{item_name} per sida"
data/locales/sv.yml CHANGED
@@ -18,4 +18,4 @@ sv:
18
18
  single_page: "Visar %{count} %{item_name}"
19
19
  multiple_pages: "Visar %{item_name} %{from}-%{to} av %{count} totalt"
20
20
  combo_nav_js: "Sida %{page_input} av %{pages}"
21
- items_selector_js: "Visa %{items_input} %{item_name} per sida"
21
+ limit_selector_js: "Visa %{limit_input} %{item_name} per sida"
data/locales/sw.yml CHANGED
@@ -20,4 +20,4 @@ sw:
20
20
  single_page: "Inaonyesha %{item_name} %{count}"
21
21
  multiple_pages: "Inaonyesha %{item_name} %{from}-%{to} ya %{count} kwa jumla"
22
22
  combo_nav_js: "Kurasa %{page_input} ya %{pages}"
23
- items_selector_js: "Onyesha %{items_input} %{item_name} kwa kila ukurasa"
23
+ limit_selector_js: "Onyesha %{limit_input} %{item_name} kwa kila ukurasa"
data/locales/ta.yml CHANGED
@@ -20,4 +20,4 @@ ta:
20
20
  single_page: "%{count} %{item_name} காட்டப்படுகின்றது"
21
21
  multiple_pages: "மொத்தம் %{count} %{item_name}, காட்டப்படுபவை %{from}-%{to}"
22
22
  combo_nav_js: "%{pages}-இல் %{page_input}-வது பக்கம்"
23
- items_selector_js: "ஒரு பக்கத்திற்கு %{items_input} %{item_name} காட்டு"
23
+ limit_selector_js: "ஒரு பக்கத்திற்கு %{limit_input} %{item_name} காட்டு"
data/locales/tr.yml CHANGED
@@ -16,4 +16,4 @@ tr:
16
16
  single_page: "Toplam %{count} %{item_name} gösteriliyor"
17
17
  multiple_pages: "%{count} %{item_name} içerisinden %{from}-%{to} kadarı gösteriliyor"
18
18
  combo_nav_js: "Sayfa %{page_input} / %{pages}"
19
- items_selector_js: "Sayfada %{items_input} %{item_name} göster"
19
+ limit_selector_js: "Sayfada %{limit_input} %{item_name} göster"
data/locales/uk.yml CHANGED
@@ -22,4 +22,4 @@ uk:
22
22
  single_page: "%{count} %{item_name}"
23
23
  multiple_pages: "Загалом %{count} %{item_name}, показані з %{from} по %{to}"
24
24
  combo_nav_js: "Сторінка %{page_input} з %{pages}"
25
- items_selector_js: "Показати %{items_input} %{item_name} на сторінці"
25
+ limit_selector_js: "Показати %{limit_input} %{item_name} на сторінці"
data/locales/vi.yml CHANGED
@@ -14,4 +14,4 @@ vi:
14
14
  single_page: "%{count} %{item_name}"
15
15
  multiple_pages: "Đang hiển thị %{from}-%{to} trong tổng số %{count} %{item_name}"
16
16
  combo_nav_js: "Trang %{page_input} trên %{pages}"
17
- items_selector_js: "Hiển thị %{items_input} %{item_name} mỗi trang"
17
+ limit_selector_js: "Hiển thị %{limit_input} %{item_name} mỗi trang"
data/locales/zh-CN.yml CHANGED
@@ -16,4 +16,4 @@ zh-CN:
16
16
  single_page: "显示%{count} 项%{item_name}"
17
17
  multiple_pages: "共 %{count} 项%{item_name},显示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 页"
19
- items_selector_js: "每页显示 %{items_input} 条%"
19
+ limit_selector_js: "每页显示 %{limit_input} 条%"
data/locales/zh-HK.yml CHANGED
@@ -16,4 +16,4 @@ zh-HK:
16
16
  single_page: "顯示 %{count} %{item_name}"
17
17
  multiple_pages: "共 %{count} %{item_name},顯示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 頁"
19
- items_selector_js: "每頁顯示 %{items_input} 記錄"
19
+ limit_selector_js: "每頁顯示 %{limit_input} 記錄"
data/locales/zh-TW.yml CHANGED
@@ -16,4 +16,4 @@ zh-TW:
16
16
  single_page: "顯示 %{count} 項%{item_name}"
17
17
  multiple_pages: "共 %{count} 項%{item_name},顯示 %{from}-%{to}"
18
18
  combo_nav_js: "第 %{page_input} / %{pages} 頁"
19
- items_selector_js: "每頁顯示 %{items_input} 項%{item_name}"
19
+ limit_selector_js: "每頁顯示 %{limit_input} 項%{item_name}"
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: 8.6.0
4
+ version: 9.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-27 00:00:00.000000000 Z
11
+ date: 2024-07-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email:
@@ -21,13 +21,18 @@ files:
21
21
  - LICENSE.txt
22
22
  - apps/calendar.ru
23
23
  - apps/demo.ru
24
+ - apps/keyset_ar.ru
25
+ - apps/keyset_s.ru
24
26
  - apps/rails.ru
25
27
  - apps/repro.ru
26
28
  - apps/tmp/calendar.sqlite3
27
29
  - apps/tmp/calendar.sqlite3-shm
28
30
  - apps/tmp/calendar.sqlite3-wal
29
31
  - apps/tmp/local_secret.txt
30
- - apps/tmp/pagy-rails.sqlite3
32
+ - apps/tmp/pagy-keyset-ar.sqlite3
33
+ - apps/tmp/pagy-keyset-ar.sqlite3-shm
34
+ - apps/tmp/pagy-keyset-ar.sqlite3-wal
35
+ - apps/tmp/pagy-keyset-s.sqlite3
31
36
  - bin/pagy
32
37
  - config/pagy.rb
33
38
  - javascripts/pagy-module.js
@@ -38,6 +43,7 @@ files:
38
43
  - javascripts/pagy.mjs
39
44
  - lib/optimist.rb
40
45
  - lib/pagy.rb
46
+ - lib/pagy/b64.rb
41
47
  - lib/pagy/backend.rb
42
48
  - lib/pagy/calendar.rb
43
49
  - lib/pagy/calendar/day.rb
@@ -56,26 +62,27 @@ files:
56
62
  - lib/pagy/extras/calendar.rb
57
63
  - lib/pagy/extras/countless.rb
58
64
  - lib/pagy/extras/elasticsearch_rails.rb
59
- - lib/pagy/extras/foundation.rb
60
65
  - lib/pagy/extras/gearbox.rb
61
66
  - lib/pagy/extras/headers.rb
62
67
  - lib/pagy/extras/i18n.rb
63
- - lib/pagy/extras/items.rb
64
68
  - lib/pagy/extras/js_tools.rb
65
69
  - lib/pagy/extras/jsonapi.rb
66
- - lib/pagy/extras/materialize.rb
70
+ - lib/pagy/extras/keyset.rb
71
+ - lib/pagy/extras/limit.rb
67
72
  - lib/pagy/extras/meilisearch.rb
68
73
  - lib/pagy/extras/metadata.rb
69
74
  - lib/pagy/extras/overflow.rb
70
75
  - lib/pagy/extras/pagy.rb
71
76
  - lib/pagy/extras/searchkick.rb
72
- - lib/pagy/extras/semantic.rb
73
77
  - lib/pagy/extras/size.rb
74
78
  - lib/pagy/extras/standalone.rb
75
79
  - lib/pagy/extras/trim.rb
76
- - lib/pagy/extras/uikit.rb
77
80
  - lib/pagy/frontend.rb
78
81
  - lib/pagy/i18n.rb
82
+ - lib/pagy/keyset.rb
83
+ - lib/pagy/keyset/active_record.rb
84
+ - lib/pagy/keyset/sequel.rb
85
+ - lib/pagy/shared_methods.rb
79
86
  - lib/pagy/url_helpers.rb
80
87
  - locales/ar.yml
81
88
  - locales/be.yml
@@ -126,14 +133,7 @@ metadata:
126
133
  bug_tracker_uri: https://github.com/ddnexus/pagy/issues
127
134
  changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
128
135
  support: https://github.com/ddnexus/pagy/discussions/categories/q-a
129
- post_install_message: |
130
- *********************** PAGY WARNING! ***********************
131
- The foundation, materialize, semantic and uikit CSS extras
132
- have been discontinued and will be removed in v9
133
- https://github.com/ddnexus/pagy/discussions/672
134
- The javascript files have been deprecated/renamed
135
- https://ddnexus.github.io/pagy/changelog/#deprecations
136
- *************************************************************
136
+ post_install_message:
137
137
  rdoc_options: []
138
138
  require_paths:
139
139
  - lib
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- warn '[PAGY WARNING] The foundation extra has been discontinued and it will be removed in v9 ' \
4
- '(https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328)'
5
-
6
- require_relative 'js_tools'
7
-
8
- class Pagy # :nodoc:
9
- # Frontend modules are specially optimized for performance.
10
- # The resulting code may not look very elegant, but produces the best benchmarks
11
- module FoundationExtra
12
- # Pagination for Foundation: it returns the html with the series of links to the pages
13
- def pagy_foundation_nav(pagy, id: nil, aria_label: nil, **vars)
14
- id = %( id="#{id}") if id
15
- a = pagy_anchor(pagy)
16
-
17
- html = +%(<nav#{id} class="pagy-foundation-nav" #{
18
- nav_aria_label(pagy, aria_label:)}><ul class="pagination"> #{
19
- foundation_prev_html(pagy, a)})
20
- pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
21
- html << case item
22
- when Integer
23
- %(<li>#{a.(item)}</li>)
24
- when String
25
- %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</li>)
26
- when :gap
27
- %(<li class="ellipsis gap"></li>)
28
- else
29
- raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
30
- end
31
- end
32
- html << %(#{foundation_next_html(pagy, a)}</ul></nav>)
33
- end
34
-
35
- # Javascript pagination for foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
36
- def pagy_foundation_nav_js(pagy, id: nil, aria_label: nil, **vars)
37
- sequels = pagy.sequels(**vars)
38
- id = %( id="#{id}") if id
39
- a = pagy_anchor(pagy)
40
- tokens = { 'before' => %(<ul class="pagination">#{foundation_prev_html pagy, a}),
41
- 'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
42
- 'current' => %(<li class="current" role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</li>),
43
- 'gap' => %(<li class="ellipsis gap"></li>),
44
- 'after' => %(#{foundation_next_html pagy, a}</ul>) }
45
-
46
- %(<nav#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" #{
47
- nav_aria_label(pagy, aria_label:)} #{
48
- pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
49
- }></nav>)
50
- end
51
-
52
- # Javascript combo pagination for Foundation: it returns a nav with a data-pagy attribute used by the pagy.js file
53
- def pagy_foundation_combo_nav_js(pagy, id: nil, aria_label: nil)
54
- id = %( id="#{id}") if id
55
- a = pagy_anchor(pagy)
56
- pages = pagy.pages
57
-
58
- page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
59
- %(style="text-align: center; width: #{pages.to_s.length + 1}rem; ) <<
60
- %(height: 1.5rem; padding: .5rem; margin: 0 .4rem; font-size: .875rem;" class="current">#{JSTools::A_TAG})
61
-
62
- %(<nav#{id} class="pagy-foundation-combo-nav-js" #{
63
- nav_aria_label(pagy, aria_label:)} #{
64
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
65
- }><ul class="pagination">#{
66
- foundation_prev_html(pagy, a)
67
- }<li style="padding: 0 .3rem"><label style="display: flex; align-items: center; white-space: nowrap">#{
68
- pagy_t('pagy.combo_nav_js', page_input:, pages:)
69
- }</label></li>#{
70
- foundation_next_html(pagy, a)
71
- }</ul></nav>)
72
- end
73
-
74
- private
75
-
76
- def foundation_prev_html(pagy, a)
77
- if (p_prev = pagy.prev)
78
- %(<li class="prev">#{a.(p_prev, pagy_t('pagy.prev'), aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
79
- else
80
- %(<li class="prev disabled" role="link" aria-disabled="true" aria-label="#{
81
- pagy_t('pagy.aria_label.prev')}">#{pagy_t('pagy.prev')}</li>)
82
- end
83
- end
84
-
85
- def foundation_next_html(pagy, a)
86
- if (p_next = pagy.next)
87
- %(<li class="next">#{a.(p_next, pagy_t('pagy.next'), aria_label: pagy_t('pagy.aria_label.next'))}</li>)
88
- else
89
- %(<li class="next disabled" role="link" aria-disabled="true" aria-label="#{
90
- pagy_t('pagy.aria_label.next')}">#{pagy_t('pagy.next')}</li>)
91
- end
92
- end
93
- end
94
- Frontend.prepend FoundationExtra
95
- end