pagy 8.0.1 → 8.1.0

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/{gem/apps → apps}/calendar.ru +1 -1
  3. data/{gem/apps → apps}/demo.ru +1 -1
  4. data/{gem/apps → apps}/rails.ru +10 -10
  5. data/{gem/apps → apps}/repro.ru +1 -1
  6. data/{gem/bin → bin}/pagy +1 -1
  7. data/{gem/config → config}/pagy.rb +9 -9
  8. data/javascripts/pagy-dev.js +114 -0
  9. data/{gem/javascripts → javascripts}/pagy-module.js +4 -2
  10. data/javascripts/pagy.js +1 -0
  11. data/{gem/lib → lib}/pagy/calendar/day.rb +1 -1
  12. data/{gem/lib → lib}/pagy/calendar/month.rb +1 -1
  13. data/{gem/lib → lib}/pagy/calendar/quarter.rb +1 -1
  14. data/{gem/lib → lib}/pagy/calendar/week.rb +1 -1
  15. data/{gem/lib → lib}/pagy/calendar/year.rb +1 -1
  16. data/{gem/lib → lib}/pagy/calendar.rb +4 -4
  17. data/{gem/lib → lib}/pagy/console.rb +2 -2
  18. data/{gem/lib → lib}/pagy/countless.rb +10 -7
  19. data/{gem/lib → lib}/pagy/extras/bootstrap.rb +2 -2
  20. data/{gem/lib → lib}/pagy/extras/bulma.rb +3 -2
  21. data/{gem/lib → lib}/pagy/extras/calendar.rb +2 -2
  22. data/{gem/lib → lib}/pagy/extras/countless.rb +1 -1
  23. data/{gem/lib → lib}/pagy/extras/foundation.rb +2 -2
  24. data/lib/pagy/extras/gearbox.rb +55 -0
  25. data/{gem/lib → lib}/pagy/extras/headers.rb +1 -1
  26. data/{gem/lib → lib}/pagy/extras/items.rb +2 -2
  27. data/{gem/lib → lib}/pagy/extras/js_tools.rb +3 -0
  28. data/{gem/lib → lib}/pagy/extras/jsonapi.rb +1 -1
  29. data/{gem/lib → lib}/pagy/extras/materialize.rb +3 -2
  30. data/{gem/lib → lib}/pagy/extras/metadata.rb +1 -1
  31. data/{gem/lib → lib}/pagy/extras/pagy.rb +2 -2
  32. data/{gem/lib → lib}/pagy/extras/semantic.rb +3 -2
  33. data/{gem/lib → lib}/pagy/extras/standalone.rb +2 -2
  34. data/{gem/lib → lib}/pagy/extras/uikit.rb +2 -2
  35. data/{gem/lib → lib}/pagy/frontend.rb +2 -2
  36. data/{gem/lib → lib}/pagy/url_helpers.rb +8 -8
  37. data/{gem/lib → lib}/pagy.rb +26 -28
  38. data/{gem/locales → locales}/ru.yml +5 -7
  39. metadata +93 -93
  40. data/gem/javascripts/pagy-dev.js +0 -112
  41. data/gem/javascripts/pagy.js +0 -1
  42. data/gem/lib/pagy/extras/gearbox.rb +0 -54
  43. /data/{gem/javascripts → javascripts}/pagy-module.d.ts +0 -0
  44. /data/{gem/lib → lib}/optimist.rb +0 -0
  45. /data/{gem/lib → lib}/pagy/backend.rb +0 -0
  46. /data/{gem/lib → lib}/pagy/calendar/helper.rb +0 -0
  47. /data/{gem/lib → lib}/pagy/exceptions.rb +0 -0
  48. /data/{gem/lib → lib}/pagy/extras/arel.rb +0 -0
  49. /data/{gem/lib → lib}/pagy/extras/array.rb +0 -0
  50. /data/{gem/lib → lib}/pagy/extras/elasticsearch_rails.rb +0 -0
  51. /data/{gem/lib → lib}/pagy/extras/i18n.rb +0 -0
  52. /data/{gem/lib → lib}/pagy/extras/meilisearch.rb +0 -0
  53. /data/{gem/lib → lib}/pagy/extras/overflow.rb +0 -0
  54. /data/{gem/lib → lib}/pagy/extras/searchkick.rb +0 -0
  55. /data/{gem/lib → lib}/pagy/extras/trim.rb +0 -0
  56. /data/{gem/lib → lib}/pagy/i18n.rb +0 -0
  57. /data/{gem/locales → locales}/ar.yml +0 -0
  58. /data/{gem/locales → locales}/be.yml +0 -0
  59. /data/{gem/locales → locales}/bg.yml +0 -0
  60. /data/{gem/locales → locales}/bs.yml +0 -0
  61. /data/{gem/locales → locales}/ca.yml +0 -0
  62. /data/{gem/locales → locales}/ckb.yml +0 -0
  63. /data/{gem/locales → locales}/cs.yml +0 -0
  64. /data/{gem/locales → locales}/da.yml +0 -0
  65. /data/{gem/locales → locales}/de.yml +0 -0
  66. /data/{gem/locales → locales}/en.yml +0 -0
  67. /data/{gem/locales → locales}/es.yml +0 -0
  68. /data/{gem/locales → locales}/fr.yml +0 -0
  69. /data/{gem/locales → locales}/hr.yml +0 -0
  70. /data/{gem/locales → locales}/id.yml +0 -0
  71. /data/{gem/locales → locales}/it.yml +0 -0
  72. /data/{gem/locales → locales}/ja.yml +0 -0
  73. /data/{gem/locales → locales}/km.yml +0 -0
  74. /data/{gem/locales → locales}/ko.yml +0 -0
  75. /data/{gem/locales → locales}/nb.yml +0 -0
  76. /data/{gem/locales → locales}/nl.yml +0 -0
  77. /data/{gem/locales → locales}/nn.yml +0 -0
  78. /data/{gem/locales → locales}/pl.yml +0 -0
  79. /data/{gem/locales → locales}/pt-BR.yml +0 -0
  80. /data/{gem/locales → locales}/pt.yml +0 -0
  81. /data/{gem/locales → locales}/sr.yml +0 -0
  82. /data/{gem/locales → locales}/sv-SE.yml +0 -0
  83. /data/{gem/locales → locales}/sv.yml +0 -0
  84. /data/{gem/locales → locales}/sw.yml +0 -0
  85. /data/{gem/locales → locales}/ta.yml +0 -0
  86. /data/{gem/locales → locales}/tr.yml +0 -0
  87. /data/{gem/locales → locales}/uk.yml +0 -0
  88. /data/{gem/locales → locales}/vi.yml +0 -0
  89. /data/{gem/locales → locales}/zh-CN.yml +0 -0
  90. /data/{gem/locales → locales}/zh-HK.yml +0 -0
  91. /data/{gem/locales → locales}/zh-TW.yml +0 -0
  92. /data/{gem/stylesheets → stylesheets}/pagy.css +0 -0
  93. /data/{gem/stylesheets → stylesheets}/pagy.scss +0 -0
  94. /data/{gem/stylesheets → stylesheets}/pagy.tailwind.css +0 -0
@@ -1,54 +0,0 @@
1
- # See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/gearbox
2
- # frozen_string_literal: true
3
-
4
- class Pagy # :nodoc:
5
- DEFAULT[:gearbox_extra] = true # extra enabled by default
6
- DEFAULT[:gearbox_items] = [15, 30, 60, 100]
7
-
8
- # Automatically change the number of items per page depending on the page number
9
- # accepts an array as the :gearbox_items variable, that will determine the items for the first pages
10
- module GearboxExtra
11
- # Setup @items based on the :gearbox_items variable
12
- def setup_items_var
13
- return super if !@vars[:gearbox_extra] || @vars[:items_extra]
14
-
15
- gearbox_items = @vars[:gearbox_items]
16
- raise VariableError.new(self, :gearbox_items, 'to be an Array of positives', gearbox_items) \
17
- unless gearbox_items.is_a?(Array) && gearbox_items.all? { |num| num.positive? rescue false } # rubocop:disable Style/RescueModifier
18
-
19
- @items = gearbox_items[@page - 1] || gearbox_items.last
20
- end
21
-
22
- # Setup @pages and @last based on the :gearbox_items variable (not used by Pagy::Countless)
23
- def setup_pages_var
24
- return super if !@vars[:gearbox_extra] || @vars[:items_extra]
25
-
26
- gearbox_items = @vars[:gearbox_items]
27
- # This algorithm is thousands of times faster than the one in the geared_pagination gem
28
- @pages = @last = (if @count > (sum = gearbox_items.sum)
29
- [((@count - sum).to_f / gearbox_items.last).ceil, 1].max + gearbox_items.count
30
- else
31
- pages = 0
32
- remainder = @count
33
- while remainder.positive?
34
- pages += 1
35
- remainder -= gearbox_items[pages - 1]
36
- end
37
- [pages, 1].max
38
- end)
39
- end
40
-
41
- # Setup @offset based on the :gearbox_items variable
42
- def setup_offset_var
43
- return super if !@vars[:gearbox_extra] || @vars[:items_extra]
44
-
45
- gearbox_items = @vars[:gearbox_items]
46
- @offset = if @page <= gearbox_items.count
47
- gearbox_items[0, @page - 1].sum
48
- else
49
- gearbox_items.sum + (gearbox_items.last * (@page - gearbox_items.count - 1))
50
- end + @outset
51
- end
52
- end
53
- prepend GearboxExtra
54
- end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes