pagy 8.6.3 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +1 -1
  3. data/apps/demo.ru +4 -4
  4. data/apps/keyset_ar.ru +236 -0
  5. data/apps/keyset_s.ru +238 -0
  6. data/apps/rails.ru +5 -5
  7. data/apps/repro.ru +4 -4
  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.sqlite3 → pagy-keyset-ar.sqlite3} +0 -0
  13. data/apps/tmp/{pagy-keyset.sqlite3-shm → pagy-keyset-ar.sqlite3-shm} +0 -0
  14. data/apps/tmp/{pagy-keyset.sqlite3-wal → 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 +13 -13
  18. data/javascripts/pagy.min.js +2 -2
  19. data/javascripts/pagy.min.js.map +2 -2
  20. data/javascripts/pagy.mjs +2 -2
  21. data/lib/pagy/b64.rb +33 -0
  22. data/lib/pagy/backend.rb +21 -17
  23. data/lib/pagy/calendar/day.rb +1 -1
  24. data/lib/pagy/calendar/month.rb +1 -1
  25. data/lib/pagy/calendar/quarter.rb +1 -1
  26. data/lib/pagy/calendar/unit.rb +7 -10
  27. data/lib/pagy/calendar/week.rb +1 -1
  28. data/lib/pagy/calendar/year.rb +1 -1
  29. data/lib/pagy/calendar.rb +5 -5
  30. data/lib/pagy/countless.rb +10 -14
  31. data/lib/pagy/extras/arel.rb +8 -10
  32. data/lib/pagy/extras/array.rb +4 -6
  33. data/lib/pagy/extras/bootstrap.rb +5 -5
  34. data/lib/pagy/extras/bulma.rb +10 -7
  35. data/lib/pagy/extras/calendar.rb +4 -5
  36. data/lib/pagy/extras/countless.rb +6 -13
  37. data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
  38. data/lib/pagy/extras/gearbox.rb +18 -18
  39. data/lib/pagy/extras/headers.rb +25 -24
  40. data/lib/pagy/extras/js_tools.rb +4 -4
  41. data/lib/pagy/extras/jsonapi.rb +26 -16
  42. data/lib/pagy/extras/keyset.rb +26 -0
  43. data/lib/pagy/extras/limit.rb +63 -0
  44. data/lib/pagy/extras/meilisearch.rb +11 -11
  45. data/lib/pagy/extras/metadata.rb +2 -2
  46. data/lib/pagy/extras/overflow.rb +5 -5
  47. data/lib/pagy/extras/pagy.rb +16 -16
  48. data/lib/pagy/extras/searchkick.rb +11 -11
  49. data/lib/pagy/extras/size.rb +1 -1
  50. data/lib/pagy/extras/standalone.rb +6 -6
  51. data/lib/pagy/extras/trim.rb +2 -2
  52. data/lib/pagy/frontend.rb +32 -33
  53. data/lib/pagy/i18n.rb +1 -1
  54. data/lib/pagy/keyset/active_record.rb +38 -0
  55. data/lib/pagy/keyset/sequel.rb +51 -0
  56. data/lib/pagy/keyset.rb +99 -0
  57. data/lib/pagy/url_helpers.rb +5 -5
  58. data/lib/pagy.rb +73 -65
  59. data/locales/ar.yml +1 -1
  60. data/locales/be.yml +1 -1
  61. data/locales/bg.yml +1 -1
  62. data/locales/bs.yml +1 -1
  63. data/locales/ca.yml +1 -1
  64. data/locales/ckb.yml +1 -1
  65. data/locales/cs.yml +1 -1
  66. data/locales/da.yml +1 -1
  67. data/locales/de.yml +1 -1
  68. data/locales/en.yml +1 -1
  69. data/locales/es.yml +1 -1
  70. data/locales/fr.yml +1 -1
  71. data/locales/hr.yml +1 -1
  72. data/locales/id.yml +1 -1
  73. data/locales/it.yml +1 -1
  74. data/locales/ja.yml +1 -1
  75. data/locales/km.yml +1 -1
  76. data/locales/ko.yml +1 -1
  77. data/locales/nb.yml +1 -1
  78. data/locales/nl.yml +1 -1
  79. data/locales/nn.yml +1 -1
  80. data/locales/pl.yml +1 -1
  81. data/locales/pt-BR.yml +1 -1
  82. data/locales/pt.yml +1 -1
  83. data/locales/ru.yml +1 -1
  84. data/locales/sr.yml +1 -1
  85. data/locales/sv-SE.yml +1 -1
  86. data/locales/sv.yml +1 -1
  87. data/locales/sw.yml +1 -1
  88. data/locales/ta.yml +1 -1
  89. data/locales/tr.yml +1 -1
  90. data/locales/uk.yml +1 -1
  91. data/locales/vi.yml +1 -1
  92. data/locales/zh-CN.yml +1 -1
  93. data/locales/zh-HK.yml +1 -1
  94. data/locales/zh-TW.yml +1 -1
  95. data/pkg/pagy-9.0.0.gem +0 -0
  96. metadata +16 -18
  97. data/lib/pagy/extras/foundation.rb +0 -95
  98. data/lib/pagy/extras/items.rb +0 -64
  99. data/lib/pagy/extras/materialize.rb +0 -100
  100. data/lib/pagy/extras/semantic.rb +0 -94
  101. data/lib/pagy/extras/uikit.rb +0 -98
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- warn '[PAGY WARNING] The uikit 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 UikitExtra
12
- # Pagination for uikit: it returns the html with the series of links to the pages
13
- def pagy_uikit_nav(pagy, id: nil, aria_label: nil, **vars)
14
- id = %( id="#{id}") if id
15
- a = pagy_anchor(pagy)
16
-
17
- html = %(<ul#{id} class="pagy-uikit nav uk-pagination uk-flex-center" role="navigation" #{
18
- nav_aria_label(pagy, aria_label:)}>#{
19
- uikit_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="uk-active"><span role="link" aria-current="page" aria-disabled="true">#{
26
- pagy.label_for(item)}</span></li>)
27
- when :gap
28
- %(<li class="uk-disabled"><span>#{pagy_t 'pagy.gap'}</span></li>)
29
- else
30
- raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
31
- end
32
- end
33
- html << %(#{uikit_next_html(pagy, a)}</ul>)
34
- end
35
-
36
- # Javascript pagination for uikit: it returns a nav with a data-pagy attribute used by the pagy.js file
37
- def pagy_uikit_nav_js(pagy, id: nil, aria_label: nil, **vars)
38
- sequels = pagy.sequels(**vars)
39
- id = %( id="#{id}") if id
40
- a = pagy_anchor(pagy)
41
- tokens = { 'before' => uikit_prev_html(pagy, a),
42
- 'a' => %(<li>#{a.(PAGE_TOKEN, LABEL_TOKEN)}</li>),
43
- 'current' => %(<li class="uk-active"><span role="link" aria-current="page" aria-disabled="true">#{
44
- LABEL_TOKEN}</span></li>),
45
- 'gap' => %(<li class="uk-disabled"><span>#{pagy_t 'pagy.gap'}</span></li>),
46
- 'after' => uikit_next_html(pagy, a) }
47
-
48
- %(<ul#{id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-uikit nav-js uk-pagination uk-flex-center" role="navigation" #{
49
- nav_aria_label(pagy, aria_label:)} #{
50
- pagy_data(pagy, :nav, tokens, sequels, pagy.label_sequels(sequels))
51
- }></ul>)
52
- end
53
-
54
- # Javascript combo pagination for uikit: it returns a nav with a data-pagy attribute used by the pagy.js file
55
- def pagy_uikit_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;">#{JSTools::A_TAG})
62
-
63
- %(<ul#{id} class="pagy-uikit combo-nav-js uk-button-group uk-pagination uk-flex-center" role="navigation" #{
64
- nav_aria_label(pagy, aria_label:)} #{
65
- pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
66
- }>#{
67
- uikit_prev_html(pagy, a)
68
- }<li><label>#{
69
- pagy_t('pagy.combo_nav_js', page_input:, pages:)
70
- }</label></li>#{
71
- uikit_next_html(pagy, a)
72
- }</ul>)
73
- end
74
-
75
- private
76
-
77
- def uikit_prev_html(pagy, a)
78
- span = %(<span uk-pagination-previous></span>)
79
- if (p_prev = pagy.prev)
80
- %(<li>#{a.(p_prev, span, aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
81
- else
82
- %(<li class="uk-disabled"><a role="link" aria-disabled="true" aria-label="#{
83
- pagy_t('pagy.aria_label.prev')}">#{span}</a></li>)
84
- end
85
- end
86
-
87
- def uikit_next_html(pagy, a)
88
- span = %(<span uk-pagination-next></span>)
89
- if (p_next = pagy.next)
90
- %(<li>#{a.(p_next, span, aria_label: pagy_t('pagy.aria_label.prev'))}</li>)
91
- else
92
- %(<li class="uk-disabled"><a role="link" aria-disabled="true" aria-label="#{
93
- pagy_t('pagy.aria_label.next')}">#{span}</a></li>)
94
- end
95
- end
96
- end
97
- Frontend.include UikitExtra
98
- end