pagy 8.6.2 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apps/calendar.ru +5 -5
- data/apps/demo.ru +4 -4
- data/apps/keyset_ar.ru +236 -0
- data/apps/keyset_s.ru +238 -0
- data/apps/rails.ru +7 -8
- data/apps/repro.ru +4 -4
- data/apps/tmp/calendar.sqlite3 +0 -0
- data/apps/tmp/calendar.sqlite3-shm +0 -0
- data/apps/tmp/calendar.sqlite3-wal +0 -0
- data/apps/tmp/local_secret.txt +1 -1
- data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
- data/apps/tmp/pagy-keyset-ar.sqlite3-shm +0 -0
- data/apps/tmp/pagy-keyset-ar.sqlite3-wal +0 -0
- data/apps/tmp/pagy-keyset-s.sqlite3 +0 -0
- data/bin/pagy +4 -2
- data/config/pagy.rb +14 -13
- data/javascripts/pagy-module.js +1 -1
- data/javascripts/pagy.js +2 -2
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +2 -2
- data/javascripts/pagy.mjs +2 -2
- data/lib/pagy/b64.rb +33 -0
- data/lib/pagy/backend.rb +21 -17
- data/lib/pagy/calendar/day.rb +1 -1
- data/lib/pagy/calendar/month.rb +1 -1
- data/lib/pagy/calendar/quarter.rb +1 -1
- data/lib/pagy/calendar/unit.rb +7 -10
- data/lib/pagy/calendar/week.rb +1 -1
- data/lib/pagy/calendar/year.rb +1 -1
- data/lib/pagy/calendar.rb +5 -5
- data/lib/pagy/countless.rb +10 -14
- data/lib/pagy/extras/arel.rb +8 -10
- data/lib/pagy/extras/array.rb +4 -6
- data/lib/pagy/extras/bootstrap.rb +5 -5
- data/lib/pagy/extras/bulma.rb +10 -7
- data/lib/pagy/extras/calendar.rb +4 -5
- data/lib/pagy/extras/countless.rb +6 -13
- data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
- data/lib/pagy/extras/gearbox.rb +18 -18
- data/lib/pagy/extras/headers.rb +25 -24
- data/lib/pagy/extras/js_tools.rb +4 -4
- data/lib/pagy/extras/jsonapi.rb +26 -16
- data/lib/pagy/extras/keyset.rb +26 -0
- data/lib/pagy/extras/limit.rb +63 -0
- data/lib/pagy/extras/meilisearch.rb +11 -11
- data/lib/pagy/extras/metadata.rb +2 -2
- data/lib/pagy/extras/overflow.rb +5 -5
- data/lib/pagy/extras/pagy.rb +16 -16
- data/lib/pagy/extras/searchkick.rb +11 -11
- data/lib/pagy/extras/size.rb +1 -1
- data/lib/pagy/extras/standalone.rb +6 -6
- data/lib/pagy/extras/trim.rb +2 -2
- data/lib/pagy/frontend.rb +32 -33
- data/lib/pagy/i18n.rb +1 -1
- data/lib/pagy/keyset/active_record.rb +38 -0
- data/lib/pagy/keyset/sequel.rb +51 -0
- data/lib/pagy/keyset.rb +99 -0
- data/lib/pagy/url_helpers.rb +5 -5
- data/lib/pagy.rb +73 -65
- data/locales/ar.yml +2 -1
- data/locales/be.yml +1 -1
- data/locales/bg.yml +1 -1
- data/locales/bs.yml +1 -1
- data/locales/ca.yml +1 -1
- data/locales/ckb.yml +1 -1
- data/locales/cs.yml +1 -1
- data/locales/da.yml +1 -1
- data/locales/de.yml +1 -1
- data/locales/en.yml +1 -1
- data/locales/es.yml +1 -1
- data/locales/fr.yml +1 -1
- data/locales/hr.yml +1 -1
- data/locales/id.yml +1 -1
- data/locales/it.yml +1 -1
- data/locales/ja.yml +1 -1
- data/locales/km.yml +1 -1
- data/locales/ko.yml +1 -1
- data/locales/nb.yml +1 -1
- data/locales/nl.yml +1 -1
- data/locales/nn.yml +1 -1
- data/locales/pl.yml +1 -1
- data/locales/pt-BR.yml +1 -1
- data/locales/pt.yml +1 -1
- data/locales/ru.yml +1 -1
- data/locales/sr.yml +1 -1
- data/locales/sv-SE.yml +1 -1
- data/locales/sv.yml +1 -1
- data/locales/sw.yml +1 -1
- data/locales/ta.yml +1 -1
- data/locales/tr.yml +1 -1
- data/locales/uk.yml +1 -1
- data/locales/vi.yml +1 -1
- data/locales/zh-CN.yml +1 -1
- data/locales/zh-HK.yml +1 -1
- data/locales/zh-TW.yml +1 -1
- data/pkg/pagy-9.0.0.gem +0 -0
- metadata +16 -15
- data/lib/pagy/extras/foundation.rb +0 -95
- data/lib/pagy/extras/items.rb +0 -64
- data/lib/pagy/extras/materialize.rb +0 -100
- data/lib/pagy/extras/semantic.rb +0 -94
- data/lib/pagy/extras/uikit.rb +0 -98
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
21
|
+
limit_selector_js: "Mostra %{limit_input} %{item_name} per pagina"
|
data/locales/ja.yml
CHANGED
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
|
-
|
19
|
+
limit_selector_js: "បង្ហាញ %{limit_input} %{item_name} ក្នុង ១ ទំព័រ"
|
data/locales/ko.yml
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
17
|
+
limit_selector_js: "Hiển thị %{limit_input} %{item_name} mỗi trang"
|
data/locales/zh-CN.yml
CHANGED
data/locales/zh-HK.yml
CHANGED
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
|
-
|
19
|
+
limit_selector_js: "每頁顯示 %{limit_input} 項%{item_name}"
|
data/pkg/pagy-9.0.0.gem
ADDED
Binary file
|
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:
|
4
|
+
version: 9.0.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: 2024-07-
|
11
|
+
date: 2024-07-18 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,12 +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
|
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
|
30
36
|
- bin/pagy
|
31
37
|
- config/pagy.rb
|
32
38
|
- javascripts/pagy-module.js
|
@@ -37,6 +43,7 @@ files:
|
|
37
43
|
- javascripts/pagy.mjs
|
38
44
|
- lib/optimist.rb
|
39
45
|
- lib/pagy.rb
|
46
|
+
- lib/pagy/b64.rb
|
40
47
|
- lib/pagy/backend.rb
|
41
48
|
- lib/pagy/calendar.rb
|
42
49
|
- lib/pagy/calendar/day.rb
|
@@ -55,26 +62,26 @@ files:
|
|
55
62
|
- lib/pagy/extras/calendar.rb
|
56
63
|
- lib/pagy/extras/countless.rb
|
57
64
|
- lib/pagy/extras/elasticsearch_rails.rb
|
58
|
-
- lib/pagy/extras/foundation.rb
|
59
65
|
- lib/pagy/extras/gearbox.rb
|
60
66
|
- lib/pagy/extras/headers.rb
|
61
67
|
- lib/pagy/extras/i18n.rb
|
62
|
-
- lib/pagy/extras/items.rb
|
63
68
|
- lib/pagy/extras/js_tools.rb
|
64
69
|
- lib/pagy/extras/jsonapi.rb
|
65
|
-
- lib/pagy/extras/
|
70
|
+
- lib/pagy/extras/keyset.rb
|
71
|
+
- lib/pagy/extras/limit.rb
|
66
72
|
- lib/pagy/extras/meilisearch.rb
|
67
73
|
- lib/pagy/extras/metadata.rb
|
68
74
|
- lib/pagy/extras/overflow.rb
|
69
75
|
- lib/pagy/extras/pagy.rb
|
70
76
|
- lib/pagy/extras/searchkick.rb
|
71
|
-
- lib/pagy/extras/semantic.rb
|
72
77
|
- lib/pagy/extras/size.rb
|
73
78
|
- lib/pagy/extras/standalone.rb
|
74
79
|
- lib/pagy/extras/trim.rb
|
75
|
-
- lib/pagy/extras/uikit.rb
|
76
80
|
- lib/pagy/frontend.rb
|
77
81
|
- lib/pagy/i18n.rb
|
82
|
+
- lib/pagy/keyset.rb
|
83
|
+
- lib/pagy/keyset/active_record.rb
|
84
|
+
- lib/pagy/keyset/sequel.rb
|
78
85
|
- lib/pagy/url_helpers.rb
|
79
86
|
- locales/ar.yml
|
80
87
|
- locales/be.yml
|
@@ -112,6 +119,7 @@ files:
|
|
112
119
|
- locales/zh-CN.yml
|
113
120
|
- locales/zh-HK.yml
|
114
121
|
- locales/zh-TW.yml
|
122
|
+
- pkg/pagy-9.0.0.gem
|
115
123
|
- stylesheets/pagy.css
|
116
124
|
- stylesheets/pagy.scss
|
117
125
|
- stylesheets/pagy.tailwind.css
|
@@ -125,14 +133,7 @@ metadata:
|
|
125
133
|
bug_tracker_uri: https://github.com/ddnexus/pagy/issues
|
126
134
|
changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
|
127
135
|
support: https://github.com/ddnexus/pagy/discussions/categories/q-a
|
128
|
-
post_install_message:
|
129
|
-
*********************** PAGY WARNING! ***********************
|
130
|
-
The foundation, materialize, semantic and uikit CSS extras
|
131
|
-
have been discontinued and will be removed in v9
|
132
|
-
https://github.com/ddnexus/pagy/discussions/672
|
133
|
-
The javascript files have been deprecated/renamed
|
134
|
-
https://ddnexus.github.io/pagy/changelog/#deprecations
|
135
|
-
*************************************************************
|
136
|
+
post_install_message:
|
136
137
|
rdoc_options: []
|
137
138
|
require_paths:
|
138
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
|
data/lib/pagy/extras/items.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/items
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require_relative 'js_tools'
|
5
|
-
|
6
|
-
class Pagy # :nodoc:
|
7
|
-
DEFAULT[:items_param] = :items
|
8
|
-
DEFAULT[:max_items] = 100
|
9
|
-
DEFAULT[:items_extra] = true # extra enabled by default
|
10
|
-
|
11
|
-
# Allow the client to request a custom number of items per page with an optional selector UI
|
12
|
-
module ItemsExtra
|
13
|
-
# Additions for the Backend module
|
14
|
-
module BackendAddOn
|
15
|
-
private
|
16
|
-
|
17
|
-
# Set the items variable considering the params and other pagy variables
|
18
|
-
def pagy_set_items_from_params(vars)
|
19
|
-
return if vars[:items] # :items explicitly set
|
20
|
-
return unless vars.key?(:items_extra) ? vars[:items_extra] : DEFAULT[:items_extra] # :items_extra is false
|
21
|
-
return unless (items_count = pagy_get_items_size(vars)) # no items from request params
|
22
|
-
|
23
|
-
vars[:items] = [items_count.to_i, vars.key?(:max_items) ? vars[:max_items] : DEFAULT[:max_items]].compact.min
|
24
|
-
end
|
25
|
-
|
26
|
-
# Get the items count from the params
|
27
|
-
# Overridable by the jsonapi extra
|
28
|
-
def pagy_get_items_size(vars)
|
29
|
-
params[vars[:items_param] || DEFAULT[:items_param]]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
Backend.prepend ItemsExtra::BackendAddOn
|
33
|
-
|
34
|
-
# Additions for the Frontend module
|
35
|
-
module FrontendAddOn
|
36
|
-
ITEMS_TOKEN = '__pagy_items__'
|
37
|
-
|
38
|
-
# Return the items selector HTML. For example "Show [20] items per page"
|
39
|
-
def pagy_items_selector_js(pagy, id: nil, item_name: nil)
|
40
|
-
return '' unless pagy.vars[:items_extra]
|
41
|
-
|
42
|
-
id = %( id="#{id}") if id
|
43
|
-
vars = pagy.vars
|
44
|
-
items = vars[:items]
|
45
|
-
vars[:items] = ITEMS_TOKEN
|
46
|
-
url_token = pagy_url_for(pagy, PAGE_TOKEN)
|
47
|
-
vars[:items] = items # restore the items
|
48
|
-
|
49
|
-
items_input = %(<input name="items" type="number" min="1" max="#{vars[:max_items]}" value="#{
|
50
|
-
items}" style="padding: 0; text-align: center; width: #{items.to_s.length + 1}rem;">#{JSTools::A_TAG})
|
51
|
-
|
52
|
-
%(<span#{id} class="pagy items-selector-js" #{
|
53
|
-
pagy_data(pagy, :selector, pagy.from, url_token)
|
54
|
-
}><label>#{
|
55
|
-
pagy_t('pagy.items_selector_js',
|
56
|
-
item_name: item_name || pagy_t('pagy.item_name', count: items),
|
57
|
-
items_input:,
|
58
|
-
count: items)
|
59
|
-
}</label></span>)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
Frontend.prepend ItemsExtra::FrontendAddOn
|
63
|
-
end
|
64
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
warn '[PAGY WARNING] The materialize 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 MaterializeExtra
|
12
|
-
# Pagination for materialize: it returns the html with the series of links to the pages
|
13
|
-
def pagy_materialize_nav(pagy, id: nil, aria_label: nil, **vars)
|
14
|
-
id = %( id="#{id}") if id
|
15
|
-
a = pagy_anchor(pagy)
|
16
|
-
|
17
|
-
html = +%(<div#{id} class="pagy-materialize nav pagination" role="navigation" #{
|
18
|
-
nav_aria_label(pagy, aria_label:)}><ul class="pagination">#{
|
19
|
-
materialize_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 class="waves-effect">#{a.(item)}</li>)
|
24
|
-
when String
|
25
|
-
%(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{pagy.label_for(item)}</a></li>)
|
26
|
-
when :gap
|
27
|
-
%(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></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 << %(#{materialize_next_html(pagy, a)}</ul></div>)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Javascript pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
|
36
|
-
def pagy_materialize_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
|
-
|
41
|
-
tokens = { 'before' => %(<ul class="pagination">#{materialize_prev_html pagy, a}),
|
42
|
-
'a' => %(<li class="waves-effect">#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
|
43
|
-
'current' => %(<li class="active"><a role="link" aria-current="page" aria-disabled="true">#{
|
44
|
-
LABEL_TOKEN}</a></li>),
|
45
|
-
'gap' => %(<li class="gap disabled"><a role="link" aria-disabled="true">#{pagy_t 'pagy.gap'}</a></li>),
|
46
|
-
'after' => %(#{materialize_next_html pagy, a}</ul>) }
|
47
|
-
|
48
|
-
%(<div#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize nav-js" role="navigation" #{
|
49
|
-
nav_aria_label(pagy, aria_label:)} #{
|
50
|
-
pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
|
51
|
-
}></div>)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Javascript combo pagination for materialize: it returns a nav with a data-pagy attribute used by the pagy.js file
|
55
|
-
def pagy_materialize_combo_nav_js(pagy, id: nil, aria_label: nil)
|
56
|
-
id = %( id="#{id}") if id
|
57
|
-
a = pagy_anchor(pagy)
|
58
|
-
pages = pagy.pages
|
59
|
-
|
60
|
-
page_input = %(<input name="page" type="number" min="1" max="#{pages}" value="#{pagy.page}" aria-current="page" ) <<
|
61
|
-
%(style="text-align: center; width: #{pages.to_s.length + 1}rem; height: 1.5rem; font-size: 1.2rem; ) <<
|
62
|
-
%(border: none; border-radius: 2px; color: white; background-color: #ee6e73;" class="browser-default"> ) <<
|
63
|
-
JSTools::A_TAG
|
64
|
-
|
65
|
-
%(<ul#{id} class="pagy-materialize combo-nav-js pagination" role="navigation" style="padding-right: 0;" #{
|
66
|
-
nav_aria_label(pagy, aria_label:)} #{
|
67
|
-
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
|
68
|
-
}>#{
|
69
|
-
materialize_prev_html(pagy, a)
|
70
|
-
}<li style="vertical-align: -webkit-baseline-middle;"><label style="font-size: 1.2rem;">#{
|
71
|
-
pagy_t('pagy.combo_nav_js', page_input:, pages:)
|
72
|
-
}</label></li>#{
|
73
|
-
materialize_next_html(pagy, a)
|
74
|
-
}</ul>)
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def materialize_prev_html(pagy, a)
|
80
|
-
if (p_prev = pagy.prev)
|
81
|
-
%(<li class="waves-effect prev">#{
|
82
|
-
a.(p_prev, '<i class="material-icons">chevron_left</i>', aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
|
83
|
-
else
|
84
|
-
%(<li class="prev disabled"><a role="link" aria-disabled="true" aria-label="#{
|
85
|
-
pagy_t('pagy.aria_label.prev')}"><i class="material-icons">chevron_left</i></a></li>)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def materialize_next_html(pagy, a)
|
90
|
-
if (p_next = pagy.next)
|
91
|
-
%(<li class="waves-effect next">#{
|
92
|
-
a.(p_next, '<i class="material-icons">chevron_right</i>', aria_label: pagy_t('pagy.aria_label.next'))}</li>)
|
93
|
-
else
|
94
|
-
%(<li class="next disabled"#><a role="link" aria-disabled="true" aria-label="#{
|
95
|
-
pagy_t('pagy.aria_label.next')}><i class="material-icons">chevron_right</i></a></li>)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
Frontend.prepend MaterializeExtra
|
100
|
-
end
|