pagy 3.10.0 → 5.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/lib/config/pagy.rb +121 -52
  4. data/lib/javascripts/pagy-dev.js +117 -0
  5. data/lib/javascripts/pagy.js +1 -106
  6. data/lib/javascripts/pagy.mjs +118 -0
  7. data/lib/locales/ar.yml +26 -0
  8. data/lib/locales/bg.yml +2 -2
  9. data/lib/locales/bs.yml +24 -0
  10. data/lib/locales/ca.yml +2 -2
  11. data/lib/locales/cs.yml +2 -2
  12. data/lib/locales/da.yml +2 -2
  13. data/lib/locales/de.yml +2 -2
  14. data/lib/locales/en.yml +2 -2
  15. data/lib/locales/es.yml +2 -2
  16. data/lib/locales/fr.yml +2 -2
  17. data/lib/locales/hr.yml +24 -0
  18. data/lib/locales/id.yml +2 -2
  19. data/lib/locales/it.yml +2 -2
  20. data/lib/locales/ja.yml +2 -2
  21. data/lib/locales/km.yml +2 -2
  22. data/lib/locales/ko.yml +2 -2
  23. data/lib/locales/nb.yml +2 -2
  24. data/lib/locales/nl.yml +2 -2
  25. data/lib/locales/pl.yml +2 -2
  26. data/lib/locales/pt-BR.yml +2 -2
  27. data/lib/locales/pt.yml +2 -2
  28. data/lib/locales/ru.yml +2 -2
  29. data/lib/locales/sr.yml +23 -0
  30. data/lib/locales/sv-SE.yml +2 -2
  31. data/lib/locales/sv.yml +2 -2
  32. data/lib/locales/sw.yml +22 -0
  33. data/lib/locales/ta.yml +22 -0
  34. data/lib/locales/tr.yml +2 -2
  35. data/lib/locales/uk.yml +24 -0
  36. data/lib/locales/zh-CN.yml +2 -2
  37. data/lib/locales/zh-HK.yml +2 -2
  38. data/lib/locales/zh-TW.yml +3 -3
  39. data/lib/pagy/backend.rb +11 -12
  40. data/lib/pagy/calendar/day.rb +29 -0
  41. data/lib/pagy/calendar/month.rb +16 -0
  42. data/lib/pagy/calendar/month_mixin.rb +49 -0
  43. data/lib/pagy/calendar/quarter.rb +23 -0
  44. data/lib/pagy/calendar/week.rb +39 -0
  45. data/lib/pagy/calendar/year.rb +29 -0
  46. data/lib/pagy/calendar.rb +90 -0
  47. data/lib/pagy/console.rb +23 -0
  48. data/lib/pagy/countless.rb +23 -19
  49. data/lib/pagy/exceptions.rb +16 -13
  50. data/lib/pagy/extras/arel.rb +12 -7
  51. data/lib/pagy/extras/array.rb +10 -9
  52. data/lib/pagy/extras/bootstrap.rb +77 -39
  53. data/lib/pagy/extras/bulma.rb +77 -43
  54. data/lib/pagy/extras/calendar.rb +66 -0
  55. data/lib/pagy/extras/countless.rb +17 -17
  56. data/lib/pagy/extras/elasticsearch_rails.rb +66 -37
  57. data/lib/pagy/extras/foundation.rb +74 -41
  58. data/lib/pagy/extras/frontend_helpers.rb +70 -0
  59. data/lib/pagy/extras/gearbox.rb +42 -0
  60. data/lib/pagy/extras/headers.rb +32 -18
  61. data/lib/pagy/extras/i18n.rb +18 -17
  62. data/lib/pagy/extras/items.rb +42 -53
  63. data/lib/pagy/extras/materialize.rb +68 -43
  64. data/lib/pagy/extras/meilisearch.rb +61 -0
  65. data/lib/pagy/extras/metadata.rb +27 -26
  66. data/lib/pagy/extras/navs.rb +54 -29
  67. data/lib/pagy/extras/overflow.rb +57 -52
  68. data/lib/pagy/extras/searchkick.rb +54 -36
  69. data/lib/pagy/extras/semantic.rb +66 -39
  70. data/lib/pagy/extras/standalone.rb +64 -0
  71. data/lib/pagy/extras/support.rb +34 -17
  72. data/lib/pagy/extras/trim.rb +18 -12
  73. data/lib/pagy/extras/uikit.rb +66 -44
  74. data/lib/pagy/frontend.rb +61 -53
  75. data/lib/pagy/i18n.rb +164 -0
  76. data/lib/pagy/url_helpers.rb +38 -0
  77. data/lib/pagy.rb +96 -30
  78. data/lib/templates/bootstrap_nav.html.erb +1 -1
  79. data/lib/templates/bootstrap_nav.html.haml +1 -1
  80. data/lib/templates/bootstrap_nav.html.slim +1 -1
  81. data/lib/templates/foundation_nav.html.erb +1 -1
  82. data/lib/templates/foundation_nav.html.haml +1 -1
  83. data/lib/templates/foundation_nav.html.slim +1 -1
  84. data/lib/templates/uikit_nav.html.erb +2 -2
  85. data/lib/templates/uikit_nav.html.haml +1 -1
  86. data/lib/templates/uikit_nav.html.slim +2 -2
  87. metadata +37 -16
  88. data/lib/locales/README.md +0 -35
  89. data/lib/locales/utils/i18n.rb +0 -25
  90. data/lib/locales/utils/loader.rb +0 -34
  91. data/lib/locales/utils/p11n.rb +0 -88
  92. data/lib/pagy/extras/pagy_search.rb +0 -18
  93. data/lib/pagy/extras/shared.rb +0 -53
  94. data/pagy.gemspec +0 -16
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ bs:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "stavka"
8
+ few: "stavke"
9
+ many: "stavki"
10
+ other: "stavki"
11
+
12
+ nav:
13
+ prev: "‹ Prethodna"
14
+ next: "Sljedeća  ›"
15
+ gap: "…"
16
+
17
+ info:
18
+ no_items: "Nije pronađena %{item_name}"
19
+ single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
21
+
22
+ combo_nav_js: "<label>Stranica %{page_input} od %{pages}</label>"
23
+
24
+ items_selector_js: "<label>Prikaži %{items_input} %{item_name} po stranici</label>"
data/lib/locales/ca.yml CHANGED
@@ -17,6 +17,6 @@ ca:
17
17
  single_page: "Mostrant <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Mostrant %{item_name} <b>%{from}-%{to}</b> de <b>%{count}</b> en total"
19
19
 
20
- combo_nav_js: "Pàgina %{page_input} de %{pages}"
20
+ combo_nav_js: "<label>Pàgina %{page_input} de %{pages}</label>"
21
21
 
22
- items_selector_js: "Mostra %{items_input} %{item_name} per pàgina"
22
+ items_selector_js: "<label>Mostra %{items_input} %{item_name} per pàgina</label>"
data/lib/locales/cs.yml CHANGED
@@ -17,6 +17,6 @@ cs:
17
17
  single_page: "Zobrazeno <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Zobrazeno %{item_name} <b>%{from}-%{to}</b> z <b>%{count}</b> celkem"
19
19
 
20
- combo_nav_js: "Strana %{page_input} z %{pages}"
20
+ combo_nav_js: "<label>Strana %{page_input} z %{pages}</label>"
21
21
 
22
- items_selector_js: "Zobrazit %{items_input} %{item_name} na stránce"
22
+ items_selector_js: "<label>Zobrazit %{items_input} %{item_name} na stránce</label>"
data/lib/locales/da.yml CHANGED
@@ -17,6 +17,6 @@ da:
17
17
  single_page: "Viser <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> til <b>%{count}</b> totalt"
19
19
 
20
- combo_nav_js: "Side %{page_input} of %{pages}"
20
+ combo_nav_js: "<label>Side %{page_input} of %{pages}</label>"
21
21
 
22
- items_selector_js: "Antal %{items_input} %{item_name} per side"
22
+ items_selector_js: "<label>Antal %{items_input} %{item_name} per side</label>"
data/lib/locales/de.yml CHANGED
@@ -17,6 +17,6 @@ de:
17
17
  single_page: "Zeige <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Zeige %{item_name} <b>%{from}-%{to}</b> von <b>%{count}</b> gesamt"
19
19
 
20
- combo_nav_js: "Seite %{page_input} von %{pages}"
20
+ combo_nav_js: "<label>Seite %{page_input} von %{pages}</label>"
21
21
 
22
- items_selector_js: "Zeige %{items_input} %{item_name} pro Seite"
22
+ items_selector_js: "<label>Zeige %{items_input} %{item_name} pro Seite</label>"
data/lib/locales/en.yml CHANGED
@@ -17,6 +17,6 @@ en:
17
17
  single_page: "Displaying <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Displaying %{item_name} <b>%{from}-%{to}</b> of <b>%{count}</b> in total"
19
19
 
20
- combo_nav_js: "Page %{page_input} of %{pages}"
20
+ combo_nav_js: "<label>Page %{page_input} of %{pages}</label>"
21
21
 
22
- items_selector_js: "Show %{items_input} %{item_name} per page"
22
+ items_selector_js: "<label>Show %{items_input} %{item_name} per page</label>"
data/lib/locales/es.yml CHANGED
@@ -17,6 +17,6 @@ es:
17
17
  single_page: "Mostrando %{count} %{item_name}"
18
18
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} de %{count} en total"
19
19
 
20
- combo_nav_js: "Página %{page_input} de %{pages}"
20
+ combo_nav_js: "<label>Página %{page_input} de %{pages}</label>"
21
21
 
22
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
22
+ items_selector_js: "<label>Mostrar %{items_input} %{item_name} por página</label>"
data/lib/locales/fr.yml CHANGED
@@ -17,6 +17,6 @@ fr:
17
17
  single_page: "Affichage de <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Affichage des %{item_name} <b>%{from} à %{to}</b> sur <b>%{count}</b> au total"
19
19
 
20
- combo_nav_js: "Page %{page_input} sur %{pages}"
20
+ combo_nav_js: "<label>Page %{page_input} sur %{pages}</label>"
21
21
 
22
- items_selector_js: "Afficher %{items_input} %{item_name} par page"
22
+ items_selector_js: "<label>Afficher %{items_input} %{item_name} par page</label>"
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ hr:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "stavka"
8
+ few: "stavke"
9
+ many: "stavki"
10
+ other: "stavki"
11
+
12
+ nav:
13
+ prev: "&lsaquo;&nbsp;Prethodna"
14
+ next: "Sljedeća &nbsp;&rsaquo;"
15
+ gap: "&hellip;"
16
+
17
+ info:
18
+ no_items: "Nije pronađena %{item_name}"
19
+ single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
21
+
22
+ combo_nav_js: "<label>Stranica %{page_input} od %{pages}</label>"
23
+
24
+ items_selector_js: "<label>Prikaži %{items_input} %{item_name} po stranici</label>"
data/lib/locales/id.yml CHANGED
@@ -15,6 +15,6 @@ id:
15
15
  single_page: "Menampilkan <b>%{count}</b> %{item_name}"
16
16
  multiple_pages: "Menampilkan %{item_name} <b>%{from}-%{to}</b> dari total <b>%{count}</b>"
17
17
 
18
- combo_nav_js: "Halaman %{page_input} dari %{pages}"
18
+ combo_nav_js: "<label>Halaman %{page_input} dari %{pages}</label>"
19
19
 
20
- items_selector_js: "Tampilkan %{items_input} %{item_name} per halaman"
20
+ items_selector_js: "<label>Tampilkan %{items_input} %{item_name} per halaman</label>"
data/lib/locales/it.yml CHANGED
@@ -17,6 +17,6 @@ it:
17
17
  single_page: "Visualizzazione di <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Visualizzazione %{item_name} <b>%{from}-%{to}</b> di <b>%{count}</b> in totale"
19
19
 
20
- combo_nav_js: "Pagina %{page_input} di %{pages}"
20
+ combo_nav_js: "<label>Pagina %{page_input} di %{pages}</label>"
21
21
 
22
- items_selector_js: "Mostra %{items_input} %{item_name} per pagina"
22
+ items_selector_js: "<label>Mostra %{items_input} %{item_name} per pagina</label>"
data/lib/locales/ja.yml CHANGED
@@ -15,6 +15,6 @@ ja:
15
15
  single_page: "<b>%{count}</b> 件の%{item_name}"
16
16
  multiple_pages: "<b>%{count}</b> 件中 <b>%{from}-%{to}</b> 件目の%{item_name}を表示中"
17
17
 
18
- combo_nav_js: "%{page_input} / %{pages} ページ"
18
+ combo_nav_js: "<label>%{page_input} / %{pages} ページ</label>"
19
19
 
20
- items_selector_js: "%{items_input} 件ずつ表示"
20
+ items_selector_js: "<label>%{items_input} 件ずつ表示</label>"
data/lib/locales/km.yml CHANGED
@@ -14,6 +14,6 @@ km:
14
14
  single_page: "បង្ហាញ <b>%{count}</b> %{item_name}"
15
15
  multiple_pages: "បង្ហាញ %{item_name} <b>%{from}-%{to}</b> នៃ <b>%{count}</b> ជាចំនួនសរុប"
16
16
 
17
- combo_nav_js: "ទំព័រ %{page_input} នៃ %{pages}"
17
+ combo_nav_js: "<label>ទំព័រ %{page_input} នៃ %{pages}</label>"
18
18
 
19
- items_selector_js: "បង្ហាញ %{items_input} %{item_name} ក្នុង ១ ទំព័រ"
19
+ items_selector_js: "<label>បង្ហាញ %{items_input} %{item_name} ក្នុង ១ ទំព័រ</label>"
data/lib/locales/ko.yml CHANGED
@@ -15,6 +15,6 @@ ko:
15
15
  single_page: "<b>%{count}</b>개의 %{item_name} 표시됨"
16
16
  multiple_pages: "총 <b>%{count}</b>개의 %{item_name} 중 <b>%{from}-%{to}</b>"
17
17
 
18
- combo_nav_js: " %{pages} 중 %{page_input} 페이지"
18
+ combo_nav_js: "<label>총 %{pages} 중 %{page_input} 페이지</label>"
19
19
 
20
- items_selector_js: "페이지 당 %{items_input}개 표시%"
20
+ items_selector_js: "<label>페이지 당 %{items_input}개 표시%</label>"
data/lib/locales/nb.yml CHANGED
@@ -17,6 +17,6 @@ nb:
17
17
  single_page: "Viser <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> av totalt <b>%{count}</b>"
19
19
 
20
- combo_nav_js: "Side %{page_input} av %{pages}"
20
+ combo_nav_js: "<label>Side %{page_input} av %{pages}</label>"
21
21
 
22
- items_selector_js: "Vis %{items_input} %{item_name} per side"
22
+ items_selector_js: "<label>Vis %{items_input} %{item_name} per side</label>"
data/lib/locales/nl.yml CHANGED
@@ -17,6 +17,6 @@ nl:
17
17
  single_page: "Toont <b>%{count}</b> %{item_name}"
18
18
  multiple_pages: "Toont <b>%{from}-%{to}</b> %{item_name} van <b>%{count}</b> in totaal"
19
19
 
20
- combo_nav_js: "Pagina %{page_input} van %{pages}"
20
+ combo_nav_js: "<label>Pagina %{page_input} van %{pages}</label>"
21
21
 
22
- items_selector_js: "Toont %{items_input} %{item_name} per pagina"
22
+ items_selector_js: "<label>Toont %{items_input} %{item_name} per pagina</label>"
data/lib/locales/pl.yml CHANGED
@@ -19,6 +19,6 @@ pl:
19
19
  single_page: "Wyświetlono <b>%{count}</b> %{item_name}"
20
20
  multiple_pages: "Wyświetlono %{item_name} <b>%{from}-%{to}</b> z wszystkich <b>%{count}</b>"
21
21
 
22
- combo_nav_js: "Strona %{page_input} z %{pages}"
22
+ combo_nav_js: "<label>Strona %{page_input} z %{pages}</label>"
23
23
 
24
- items_selector_js: "Pokaż %{items_input} %{item_name} na stronie"
24
+ items_selector_js: "<label>Pokaż %{items_input} %{item_name} na stronie</label>"
@@ -17,6 +17,6 @@ pt-BR:
17
17
  single_page: "Mostrando %{count} %{item_name}"
18
18
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} do total de %{count}"
19
19
 
20
- combo_nav_js: "Página %{page_input} de %{pages}"
20
+ combo_nav_js: "<label>Página %{page_input} de %{pages}</label>"
21
21
 
22
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
22
+ items_selector_js: "<label>Mostrar %{items_input} %{item_name} por página</label>"
data/lib/locales/pt.yml CHANGED
@@ -17,6 +17,6 @@ pt:
17
17
  single_page: "Mostrando %{count} %{item_name}"
18
18
  multiple_pages: "Mostrando %{item_name} %{from}-%{to} de um total de %{count}"
19
19
 
20
- combo_nav_js: "Página %{page_input} de %{pages}"
20
+ combo_nav_js: "<label>Página %{page_input} de %{pages}</label>"
21
21
 
22
- items_selector_js: "Mostrar %{items_input} %{item_name} por página"
22
+ items_selector_js: "<label>Mostrar %{items_input} %{item_name} por página</label>"
data/lib/locales/ru.yml CHANGED
@@ -19,6 +19,6 @@ ru:
19
19
  single_page: "<b>%{count}</b> %{item_name}"
20
20
  multiple_pages: "Всего <b>%{count}</b> %{item_name}, показаны с <b>%{from}</b> по <b>%{to}</b>"
21
21
 
22
- combo_nav_js: "Страница %{page_input} из %{pages}"
22
+ combo_nav_js: "<label>Страница %{page_input} из %{pages}</label>"
23
23
 
24
- items_selector_js: "Показать %{items_input} %{item_name} на странице"
24
+ items_selector_js: "<label>Показать %{items_input} %{item_name} на странице</label>"
@@ -0,0 +1,23 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ sr:
4
+ pagy:
5
+ item_name:
6
+ one: "ставка"
7
+ few: "ставкe"
8
+ many: "ставки"
9
+ other: "ставки"
10
+
11
+ nav:
12
+ prev: "&lsaquo;&nbsp;Претходна"
13
+ next: "Следећa &nbsp;&rsaquo;"
14
+ gap: "&hellip;"
15
+
16
+ info:
17
+ no_items: "Нema пронађених %{item_name}"
18
+ single_page: "Приказује се <b>%{count}</b> %{item_name}"
19
+ multiple_pages: "Приказ %{item_name} <b>%{from}-%{to}</b> од <b>%{count}</b> укупно"
20
+
21
+ combo_nav_js: "<label>Страниca %{page_input} од %{pages}</label>"
22
+
23
+ items_selector_js: "<label>Прикажи %{items_input} %{item_name} по страниcи</label>"
@@ -18,6 +18,6 @@ sv-SE:
18
18
  single_page: "Visar <b>%{count}</b> %{item_name}"
19
19
  multiple_pages: "Visar %{item_name} <b>%{from}-%{to}</b> av <b>%{count}</b> totalt"
20
20
 
21
- combo_nav_js: "Sida %{page_input} av %{pages}"
21
+ combo_nav_js: "<label>Sida %{page_input} av %{pages}</label>"
22
22
 
23
- items_selector_js: "Visa %{items_input} %{item_name} per sida"
23
+ items_selector_js: "<label>Visa %{items_input} %{item_name} per sida</label>"
data/lib/locales/sv.yml CHANGED
@@ -18,6 +18,6 @@ sv:
18
18
  single_page: "Visar <b>%{count}</b> %{item_name}"
19
19
  multiple_pages: "Visar %{item_name} <b>%{from}-%{to}</b> av <b>%{count}</b> totalt"
20
20
 
21
- combo_nav_js: "Sida %{page_input} av %{pages}"
21
+ combo_nav_js: "<label>Sida %{page_input} av %{pages}</label>"
22
22
 
23
- items_selector_js: "Visa %{items_input} %{item_name} per sida"
23
+ items_selector_js: "<label>Visa %{items_input} %{item_name} per sida</label>"
@@ -0,0 +1,22 @@
1
+ # :one_other pluralization
2
+
3
+ sw:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "kifaa"
8
+ other: "vifaa"
9
+
10
+ nav:
11
+ prev: "&lsaquo;&nbsp;Awali"
12
+ next: "Ifuatayo&nbsp;&rsaquo;"
13
+ gap: "&hellip;"
14
+
15
+ info:
16
+ no_items: "Hamna %{item_name} vilivyopatikana"
17
+ single_page: "Inaonyesha %{item_name} <b>%{count}</b>"
18
+ multiple_pages: "Inaonyesha %{item_name} <b>%{from}-%{to}</b> ya <b>%{count}</b> kwa jumla"
19
+
20
+ combo_nav_js: "<label>Kurasa %{page_input} ya %{pages}</label>"
21
+
22
+ items_selector_js: "<label>Onyesha %{items_input} %{item_name} kwa kila ukurasa</label>"
@@ -0,0 +1,22 @@
1
+ # :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ ta:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "பதிவு"
8
+ other: "பதிவுகள்"
9
+
10
+ nav:
11
+ prev: "&lsaquo;&nbsp;முந்தையது"
12
+ next: "அடுத்தது&nbsp;&rsaquo;"
13
+ gap: "&hellip;"
14
+
15
+ info:
16
+ no_items: "%{item_name} கிடைக்கவில்லை"
17
+ single_page: "<b>%{count}</b> %{item_name} காட்டப்படுகின்றது"
18
+ multiple_pages: "மொத்தம் <b>%{count}</b> %{item_name}, காட்டப்படுபவை <b>%{from}-%{to}</b>"
19
+
20
+ combo_nav_js: "<label>%{pages}-இல் %{page_input}-வது பக்கம்</label>"
21
+
22
+ items_selector_js: "<label>ஒரு பக்கத்திற்கு %{items_input} %{item_name} காட்டு</label>"
data/lib/locales/tr.yml CHANGED
@@ -15,6 +15,6 @@ tr:
15
15
  single_page: "Toplam <b>%{count}</b> %{item_name} gösteriliyor"
16
16
  multiple_pages: "<b>%{count}</b> %{item_name} içerisinden <b>%{from}-%{to}</b> kadarı gösteriliyor"
17
17
 
18
- combo_nav_js: "Sayfa %{page_input} / %{pages}"
18
+ combo_nav_js: "<label>Sayfa %{page_input} / %{pages}</label>"
19
19
 
20
- items_selector_js: "Sayfada %{items_input} %{item_name} göster"
20
+ items_selector_js: "<label>Sayfada %{items_input} %{item_name} göster</label>"
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ uk:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "запис"
8
+ few: "записів"
9
+ many: "записів"
10
+ other: "записів"
11
+
12
+ nav:
13
+ prev: "&lsaquo;&nbsp;Назад"
14
+ next: "Далі&nbsp;&rsaquo;"
15
+ gap: "&hellip;"
16
+
17
+ info:
18
+ no_items: "Більше %{item_name} немає"
19
+ single_page: "<b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Загалом <b>%{count}</b> %{item_name}, показані з <b>%{from}</b> по <b>%{to}</b>"
21
+
22
+ combo_nav_js: "<label>Сторінка %{page_input} з %{pages}</label>"
23
+
24
+ items_selector_js: "<label>Показати %{items_input} %{item_name} на сторінці</label>"
@@ -15,6 +15,6 @@ zh-CN:
15
15
  single_page: "显示<b>%{count}</b> 项%{item_name}"
16
16
  multiple_pages: "共 <b>%{count}</b> 项%{item_name},显示 <b>%{from}-%{to}</b>"
17
17
 
18
- combo_nav_js: " %{page_input} / %{pages} "
18
+ combo_nav_js: "<label>第 %{page_input} / %{pages} 页</label>"
19
19
 
20
- items_selector_js: "每页显示 %{items_input} 条%"
20
+ items_selector_js: "<label>每页显示 %{items_input} 条%</label>"
@@ -15,6 +15,6 @@ zh-HK:
15
15
  single_page: "顯示 <b>%{count}</b> %{item_name}"
16
16
  multiple_pages: "共 <b>%{count}</b> %{item_name},顯示 <b>%{from}-%{to}</b>"
17
17
 
18
- combo_nav_js: " %{page_input} / %{pages} "
18
+ combo_nav_js: "<label>第 %{page_input} / %{pages} 頁</label>"
19
19
 
20
- items_selector_js: "每頁顯示 %{items_input} 記錄"
20
+ items_selector_js: "<label>每頁顯示 %{items_input} 記錄</label>"
@@ -10,11 +10,11 @@ zh-TW:
10
10
  next: "下一頁&nbsp;&rsaquo;"
11
11
  gap: "&hellip;"
12
12
 
13
- combo_nav_js: "第 %{page_input} / %{pages} 頁"
14
-
15
13
  info:
16
14
  no_items: "沒找到項"
17
15
  single_page: "顯示 <b>%{count}</b> 項%{item_name}"
18
16
  multiple_pages: "共 <b>%{count}</b> 項%{item_name},顯示 <b>%{from}-%{to}</b>"
19
17
 
20
- items_selector_js: "每頁顯示 %{items_input} 項%{item_name}"
18
+ combo_nav_js: "<label>第 %{page_input} / %{pages} 頁</label>"
19
+
20
+ items_selector_js: "<label>每頁顯示 %{items_input} 項%{item_name}</label>"
data/lib/pagy/backend.rb CHANGED
@@ -1,33 +1,32 @@
1
1
  # See Pagy::Backend API documentation: https://ddnexus.github.io/pagy/api/backend
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  class Pagy
6
- # Defines a few generic methods to paginate an ORM collection out of the box,
5
+ # Define a few generic methods to paginate an ORM collection out of the box,
7
6
  # or any collection by overriding pagy_get_items and/or pagy_get_vars in your controller
8
-
9
7
  # See also the extras if you need specialized methods to paginate Arrays or other collections
8
+ module Backend
9
+ private
10
10
 
11
- module Backend ; private # the whole module is private so no problem with including it in a controller
12
-
13
- # Return Pagy object and items
14
- def pagy(collection, vars={})
11
+ # Return Pagy object and paginated items/results
12
+ def pagy(collection, vars = {})
15
13
  pagy = Pagy.new(pagy_get_vars(collection, vars))
16
- return pagy, pagy_get_items(collection, pagy)
14
+ [pagy, pagy_get_items(collection, pagy)]
17
15
  end
18
16
 
19
17
  # Sub-method called only by #pagy: here for easy customization of variables by overriding
18
+ # You may need to override the count call for non AR collections
20
19
  def pagy_get_vars(collection, vars)
21
- vars[:count] ||= (c = collection.count(:all)).is_a?(Hash) ? c.size : c
22
- vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
20
+ pagy_set_items_from_params(vars) if defined?(ItemsExtra)
21
+ vars[:count] ||= (count = collection.count(:all)).is_a?(Hash) ? count.size : count
22
+ vars[:page] ||= params[vars[:page_param] || DEFAULT[:page_param]]
23
23
  vars
24
24
  end
25
25
 
26
26
  # Sub-method called only by #pagy: here for easy customization of record-extraction by overriding
27
+ # You may need to override this method for collections without offset|limit
27
28
  def pagy_get_items(collection, pagy)
28
- # This should work with ActiveRecord, Sequel, Mongoid...
29
29
  collection.offset(pagy.offset).limit(pagy.items)
30
30
  end
31
-
32
31
  end
33
32
  end
@@ -0,0 +1,29 @@
1
+ # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
+ # frozen_string_literal: true
3
+
4
+ class Pagy # :nodoc:
5
+ class Calendar # :nodoc:
6
+ # Calendar day subclass
7
+ class Day < Calendar
8
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
9
+ format: '%Y-%m-%d' }
10
+
11
+ protected
12
+
13
+ # Setup the calendar variables
14
+ def setup_unit_vars
15
+ super
16
+ @initial = new_time(@starting.year, @starting.month, @starting.day)
17
+ @final = new_time(@ending.year, @ending.month, @ending.day) + DAY
18
+ @pages = @last = (@final - @initial).to_i / DAY
19
+ @from = starting_time_for(@page)
20
+ @to = @from + DAY
21
+ end
22
+
23
+ # Starting time for the page
24
+ def starting_time_for(page)
25
+ @initial + (offset_units_for(page) * DAY)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'month_mixin'
5
+
6
+ class Pagy # :nodoc:
7
+ class Calendar # :nodoc:
8
+ # Calendar month subclass
9
+ class Month < Calendar
10
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
11
+ format: '%Y-%m' }
12
+ MONTHS = 1 # number of months in the unit
13
+ include MonthMixin
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pagy
4
+ class Calendar
5
+ # Mixin for month based unit periods
6
+ # It is used for month and quarter, but you could use it to implement less common unit of 6, 4, 2 months
7
+ # (see the https://ddnexus.github.io/pagy/api/calendar#custom-units sections for details).
8
+ # The including class must set the MONTHS duration for the unit and the usual DEFAULT.
9
+ module MonthMixin
10
+ protected
11
+
12
+ # Setup the calendar variables
13
+ def setup_unit_vars
14
+ super
15
+ @months = self.class::MONTHS # number of months in the unit
16
+ @initial = unit_starting_time_for(@starting)
17
+ @final = add_months_to(unit_starting_time_for(@ending), @months)
18
+ @pages = @last = (months_in(@final) - months_in(@initial)) / @months
19
+ @from = starting_time_for(@page)
20
+ @to = add_months_to(@from, @months)
21
+ end
22
+
23
+ # Starting time for the page
24
+ def starting_time_for(page)
25
+ add_months_to(@initial, offset_units_for(page) * @months)
26
+ end
27
+
28
+ private
29
+
30
+ # Unit starting time for time
31
+ def unit_starting_time_for(time)
32
+ # remove 1 month for 0-11 calculations and add it back for 1-12 conversion
33
+ starting_month = (@months * ((time.month - 1) / @months)) + 1
34
+ new_time(time.year, starting_month)
35
+ end
36
+
37
+ # Number of months in time
38
+ def months_in(time)
39
+ (time.year * 12) + time.month
40
+ end
41
+
42
+ # Add months to time
43
+ def add_months_to(time, months)
44
+ months += months_in(time) - 1 # remove 1 month for 0-11 calculations
45
+ new_time(months / 12, (months % 12) + 1) # add 1 month back for 1-12 conversion
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'month_mixin'
5
+
6
+ class Pagy # :nodoc:
7
+ class Calendar # :nodoc:
8
+ # Calendar quarter subclass
9
+ class Quarter < Calendar
10
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
11
+ format: '%Y-Q%q' } # '%q' token
12
+ MONTHS = 3 # number of months of the unit
13
+ include MonthMixin
14
+
15
+ # The label for any page, with the substitution of the '%q' token
16
+ def label_for(page, opts = {})
17
+ starting_time = starting_time_for(page.to_i) # page could be a string
18
+ opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (starting_time.month / 4) + 1 }
19
+ localize(starting_time, opts)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
+ # frozen_string_literal: true
3
+
4
+ class Pagy # :nodoc:
5
+ class Calendar # :nodoc:
6
+ # Calendar week subclass
7
+ class Week < Calendar
8
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
9
+ format: '%Y-%W',
10
+ offset: 0 }
11
+
12
+ protected
13
+
14
+ # Setup the calendar variables
15
+ def setup_unit_vars
16
+ setup_vars(offset: 0)
17
+ super
18
+ @initial = unit_starting_time_for(@starting)
19
+ @final = unit_starting_time_for(@ending) + WEEK
20
+ @pages = @last = (@final - @initial).to_i / WEEK
21
+ @from = starting_time_for(@page)
22
+ @to = @from + WEEK
23
+ end
24
+
25
+ # Starting time for the page
26
+ def starting_time_for(page)
27
+ @initial + (offset_units_for(page) * WEEK)
28
+ end
29
+
30
+ private
31
+
32
+ # Unit starting time for time
33
+ def unit_starting_time_for(time)
34
+ starting_time = time - (((time.wday - @offset) * DAY) % WEEK)
35
+ new_time(starting_time.year, starting_time.month, starting_time.day)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ # See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/api/calendar
2
+ # frozen_string_literal: true
3
+
4
+ class Pagy # :nodoc:
5
+ class Calendar # :nodoc:
6
+ # Calendar year subclass
7
+ class Year < Calendar
8
+ DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
9
+ format: '%Y' }
10
+
11
+ protected
12
+
13
+ # Setup the calendar variables
14
+ def setup_unit_vars
15
+ super
16
+ @initial = new_time(@starting.year)
17
+ @final = new_time(@ending.year + 1)
18
+ @pages = @last = @final.year - @initial.year
19
+ @from = starting_time_for(@page)
20
+ @to = new_time(@from.year + 1)
21
+ end
22
+
23
+ # Starting time for the page
24
+ def starting_time_for(page)
25
+ new_time(@initial.year + offset_units_for(page))
26
+ end
27
+ end
28
+ end
29
+ end