pagy 8.0.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/apps/calendar.ru +745 -0
  3. data/{lib/apps → apps}/demo.ru +35 -52
  4. data/apps/keyset_ar.ru +236 -0
  5. data/apps/keyset_s.ru +238 -0
  6. data/{lib/apps → apps}/rails.ru +40 -33
  7. data/{lib/apps → apps}/repro.ru +33 -24
  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 -0
  12. data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
  13. data/apps/tmp/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/{lib/bin → bin}/pagy +36 -17
  17. data/{lib/config → config}/pagy.rb +37 -68
  18. data/javascripts/pagy-module.js +100 -0
  19. data/javascripts/pagy.js +4 -0
  20. data/javascripts/pagy.min.js +4 -0
  21. data/javascripts/pagy.min.js.map +10 -0
  22. data/javascripts/pagy.mjs +100 -0
  23. data/lib/optimist.rb +1 -1
  24. data/lib/pagy/b64.rb +33 -0
  25. data/lib/pagy/backend.rb +24 -15
  26. data/lib/pagy/calendar/day.rb +5 -4
  27. data/lib/pagy/calendar/month.rb +5 -4
  28. data/lib/pagy/calendar/quarter.rb +5 -4
  29. data/lib/pagy/calendar/unit.rb +103 -0
  30. data/lib/pagy/calendar/week.rb +4 -4
  31. data/lib/pagy/calendar/year.rb +5 -4
  32. data/lib/pagy/calendar.rb +55 -99
  33. data/lib/pagy/console.rb +2 -2
  34. data/lib/pagy/countless.rb +17 -16
  35. data/lib/pagy/extras/arel.rb +8 -10
  36. data/lib/pagy/extras/array.rb +4 -6
  37. data/lib/pagy/extras/bootstrap.rb +7 -7
  38. data/lib/pagy/extras/bulma.rb +13 -9
  39. data/lib/pagy/extras/calendar.rb +35 -6
  40. data/lib/pagy/extras/countless.rb +7 -14
  41. data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
  42. data/lib/pagy/extras/gearbox.rb +36 -35
  43. data/lib/pagy/extras/headers.rb +26 -25
  44. data/lib/pagy/extras/i18n.rb +1 -1
  45. data/lib/pagy/extras/js_tools.rb +12 -9
  46. data/lib/pagy/extras/jsonapi.rb +27 -17
  47. data/lib/pagy/extras/keyset.rb +26 -0
  48. data/lib/pagy/extras/limit.rb +63 -0
  49. data/lib/pagy/extras/meilisearch.rb +11 -11
  50. data/lib/pagy/extras/metadata.rb +7 -3
  51. data/lib/pagy/extras/overflow.rb +9 -8
  52. data/lib/pagy/extras/pagy.rb +18 -18
  53. data/lib/pagy/extras/searchkick.rb +11 -11
  54. data/lib/pagy/extras/size.rb +40 -0
  55. data/lib/pagy/extras/standalone.rb +8 -8
  56. data/lib/pagy/extras/trim.rb +3 -3
  57. data/lib/pagy/frontend.rb +39 -37
  58. data/lib/pagy/i18n.rb +1 -1
  59. data/lib/pagy/keyset/active_record.rb +38 -0
  60. data/lib/pagy/keyset/sequel.rb +51 -0
  61. data/lib/pagy/keyset.rb +99 -0
  62. data/lib/pagy/url_helpers.rb +11 -11
  63. data/lib/pagy.rb +96 -120
  64. data/{lib/locales → locales}/ar.yml +9 -10
  65. data/{lib/locales → locales}/be.yml +2 -2
  66. data/{lib/locales → locales}/bg.yml +2 -2
  67. data/{lib/locales → locales}/bs.yml +2 -2
  68. data/{lib/locales → locales}/ca.yml +5 -7
  69. data/{lib/locales → locales}/ckb.yml +2 -2
  70. data/{lib/locales → locales}/cs.yml +2 -2
  71. data/{lib/locales → locales}/da.yml +5 -7
  72. data/{lib/locales → locales}/de.yml +2 -2
  73. data/{lib/locales → locales}/en.yml +2 -2
  74. data/{lib/locales → locales}/es.yml +2 -2
  75. data/{lib/locales → locales}/fr.yml +2 -2
  76. data/{lib/locales → locales}/hr.yml +2 -2
  77. data/{lib/locales → locales}/id.yml +2 -2
  78. data/{lib/locales → locales}/it.yml +2 -2
  79. data/{lib/locales → locales}/ja.yml +2 -2
  80. data/{lib/locales → locales}/km.yml +2 -2
  81. data/{lib/locales → locales}/ko.yml +3 -5
  82. data/{lib/locales → locales}/nb.yml +2 -2
  83. data/{lib/locales → locales}/nl.yml +2 -2
  84. data/{lib/locales → locales}/nn.yml +2 -2
  85. data/{lib/locales → locales}/pl.yml +2 -2
  86. data/{lib/locales → locales}/pt-BR.yml +2 -2
  87. data/{lib/locales → locales}/pt.yml +2 -2
  88. data/{lib/locales → locales}/ru.yml +7 -9
  89. data/{lib/locales → locales}/sr.yml +2 -2
  90. data/{lib/locales → locales}/sv-SE.yml +2 -2
  91. data/{lib/locales → locales}/sv.yml +2 -2
  92. data/{lib/locales → locales}/sw.yml +2 -2
  93. data/{lib/locales → locales}/ta.yml +2 -2
  94. data/{lib/locales → locales}/tr.yml +2 -2
  95. data/{lib/locales → locales}/uk.yml +2 -2
  96. data/{lib/locales → locales}/vi.yml +2 -2
  97. data/{lib/locales → locales}/zh-CN.yml +2 -2
  98. data/{lib/locales → locales}/zh-HK.yml +2 -2
  99. data/{lib/locales → locales}/zh-TW.yml +2 -2
  100. data/pkg/pagy-9.0.0.gem +0 -0
  101. metadata +75 -70
  102. data/lib/apps/calendar.ru +0 -2196
  103. data/lib/javascripts/pagy-dev.js +0 -112
  104. data/lib/javascripts/pagy-module.js +0 -111
  105. data/lib/javascripts/pagy.js +0 -1
  106. data/lib/pagy/calendar/helper.rb +0 -65
  107. data/lib/pagy/extras/foundation.rb +0 -93
  108. data/lib/pagy/extras/items.rb +0 -64
  109. data/lib/pagy/extras/materialize.rb +0 -97
  110. data/lib/pagy/extras/semantic.rb +0 -91
  111. data/lib/pagy/extras/uikit.rb +0 -96
  112. /data/{lib/javascripts/pagy-module.d.ts → javascripts/pagy.d.ts} +0 -0
  113. /data/{lib/stylesheets → stylesheets}/pagy.css +0 -0
  114. /data/{lib/stylesheets → stylesheets}/pagy.scss +0 -0
  115. /data/{lib/stylesheets → stylesheets}/pagy.tailwind.css +0 -0
@@ -15,27 +15,22 @@
15
15
  # DOC
16
16
  # https://ddnexus.github.io/pagy/playground/#2-rails-app
17
17
 
18
- VERSION = '8.0.0'
18
+ VERSION = '9.0.0'
19
19
 
20
20
  # Gemfile
21
21
  require 'bundler/inline'
22
- gemfile(true) do
22
+ require 'bundler'
23
+ Bundler.configure
24
+ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
23
25
  source 'https://rubygems.org'
24
26
  gem 'oj'
25
27
  gem 'puma'
26
- gem 'rails', '~> 7.1'
27
- gem 'sqlite3'
28
+ gem 'rails'
29
+ # activerecord/sqlite3_adapter.rb probably useless) constraint !!!
30
+ # https://github.com/rails/rails/blame/v7.1.3.4/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L14
31
+ gem 'sqlite3', '~> 1.4.0'
28
32
  end
29
33
 
30
- # Pagy initializer
31
- require 'pagy/extras/pagy'
32
- require 'pagy/extras/items'
33
- require 'pagy/extras/overflow'
34
- Pagy::DEFAULT[:size] = [1, 4, 4, 1]
35
- Pagy::DEFAULT[:items] = 10
36
- Pagy::DEFAULT[:overflow] = :empty_page
37
- Pagy::DEFAULT.freeze
38
-
39
34
  # require 'rails/all' # too much stuff
40
35
  require 'action_controller/railtie'
41
36
  require 'active_record'
@@ -53,7 +48,7 @@ class PagyRails < Rails::Application # :nodoc:
53
48
 
54
49
  routes.draw do
55
50
  root to: 'comments#index'
56
- get '/javascript' => 'pagy#javascript'
51
+ get '/javascripts/:file', to: 'pagy#javascripts', file: /.*/
57
52
  end
58
53
  end
59
54
 
@@ -64,6 +59,16 @@ unless File.writable?(dir)
64
59
  exit 1
65
60
  end
66
61
 
62
+ # Pagy initializer
63
+ require 'pagy/extras/pagy'
64
+ require 'pagy/extras/limit'
65
+ require 'pagy/extras/overflow'
66
+ Pagy::DEFAULT[:limit] = 10
67
+ Pagy::DEFAULT[:overflow] = :empty_page
68
+ Pagy::DEFAULT.freeze
69
+
70
+ # Activerecord initializer
71
+ ActiveRecord::Base.logger = Logger.new(OUTPUT)
67
72
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: "#{dir}/tmp/pagy-rails.sqlite3")
68
73
  ActiveRecord::Schema.define do
69
74
  create_table :posts, force: true do |t|
@@ -93,9 +98,6 @@ Post.all.each_with_index do |post, pi|
93
98
  2.times { |ci| Comment.create(post:, body: "Comment #{ci + 1} to Post #{pi + 1}") }
94
99
  end
95
100
 
96
- # Down here to avoid logging the DB seed above at each restart
97
- ActiveRecord::Base.logger = Logger.new(OUTPUT)
98
-
99
101
  # Helpers
100
102
  module CommentsHelper
101
103
  include Pagy::Frontend
@@ -114,9 +116,13 @@ end
114
116
 
115
117
  # You don't need this in real rails apps (see https://ddnexus.github.io/pagy/docs/api/javascript/setup/#2-configure)
116
118
  class PagyController < ActionController::Base
117
- def javascript
118
- file = "pagy#{'-dev' if ENV['DEBUG']}.js"
119
- render js: Pagy.root.join('javascripts', file).read
119
+ def javascripts
120
+ format = params[:file].split('.').last
121
+ if format == 'js'
122
+ render js: Pagy.root.join('javascripts', params[:file]).read
123
+ elsif format == 'map'
124
+ render json: Pagy.root.join('javascripts', params[:file]).read
125
+ end
120
126
  end
121
127
  end
122
128
 
@@ -127,15 +133,16 @@ TEMPLATE = <<~ERB
127
133
  <html lang="en">
128
134
  <html>
129
135
  <head>
130
- <script src="/javascript"></script>
131
- <script type="application/javascript">
136
+ <title>Pagy Rails App</title>
137
+ <script src="/javascripts/pagy.min.js"></script>
138
+ <script>
132
139
  window.addEventListener("load", Pagy.init);
133
140
  </script>
134
141
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
135
142
  <style type="text/css">
136
143
  @media screen { html, body {
137
144
  font-size: 1rem;
138
- line-heigth: 1.2s;
145
+ line-height: 1.2s;
139
146
  padding: 0;
140
147
  margin: 0;
141
148
  } }
@@ -165,10 +172,10 @@ TEMPLATE = <<~ERB
165
172
  <body>
166
173
 
167
174
  <div class="content">
168
- <h3>Pagy Rails App</h3>
175
+ <h1>Pagy Rails App</h1>
169
176
  <p> Self-contained, standalone Rails app usable to easily reproduce any rails related pagy issue.</p>
170
177
  <p>Please, report the following versions in any new issue.</p>
171
- <h4>Versions</h4>
178
+ <h2>Versions</h2>
172
179
  <ul>
173
180
  <li>Ruby: <%== RUBY_VERSION %></li>
174
181
  <li>Rack: <%== Rack::RELEASE %></li>
@@ -176,8 +183,8 @@ TEMPLATE = <<~ERB
176
183
  <li>Pagy: <%== Pagy::VERSION %></li>
177
184
  </ul>
178
185
 
179
- <h4>Collection</h4>
180
- <div class="collection">
186
+ <h3>Collection</h3>
187
+ <div id="records" class="collection">
181
188
  <% @comments.each do |comment| %>
182
189
  <p style="margin: 0;"><%= comment.body %></p>
183
190
  <% end %>
@@ -185,19 +192,19 @@ TEMPLATE = <<~ERB
185
192
  <hr>
186
193
 
187
194
  <h4>pagy_nav</h4>
188
- <%== pagy_nav(@pagy) %>
195
+ <%== pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
189
196
 
190
197
  <h4>pagy_nav_js</h4>
191
- <%== pagy_nav_js(@pagy) %>
198
+ <%== pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
192
199
 
193
200
  <h4>pagy_combo_nav_js</h4>
194
- <%== pagy_combo_nav_js(@pagy) %>
201
+ <%== pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
195
202
 
196
- <h4>pagy_items_selector_js</h4>
197
- <%== pagy_items_selector_js(@pagy) %>
203
+ <h4>pagy_limit_selector_js</h4>
204
+ <%== pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
198
205
 
199
206
  <h4>pagy_info</h4>
200
- <%== pagy_info(@pagy) %>
207
+ <%== pagy_info(@pagy, id: 'pagy-info') %>
201
208
  </div>
202
209
 
203
210
  </body>
@@ -15,10 +15,12 @@
15
15
  # DOC
16
16
  # https://ddnexus.github.io/pagy/playground/#1-repro-app
17
17
 
18
- VERSION = '8.0.0'
18
+ VERSION = '9.0.0'
19
19
 
20
20
  require 'bundler/inline'
21
- gemfile(true) do
21
+ require 'bundler'
22
+ Bundler.configure
23
+ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
22
24
  source 'https://rubygems.org'
23
25
  gem 'oj'
24
26
  gem 'puma'
@@ -29,26 +31,29 @@ end
29
31
  # Edit this section adding/removing the extras and Pagy::DEFAULT as needed
30
32
  # pagy initializer
31
33
  require 'pagy/extras/pagy'
32
- require 'pagy/extras/items'
34
+ require 'pagy/extras/limit'
33
35
  require 'pagy/extras/overflow'
34
36
  Pagy::DEFAULT[:overflow] = :empty_page
35
- Pagy::DEFAULT[:size] = [1, 4, 4, 1]
36
37
  Pagy::DEFAULT.freeze
37
38
 
38
39
  require 'sinatra/base'
39
40
  # Sinatra application
40
41
  class PagyRepro < Sinatra::Base
41
- PAGY_JS = "pagy#{'-dev' if ENV['DEBUG']}.js".freeze
42
-
43
42
  configure do
44
43
  enable :inline_templates
45
44
  end
46
45
  include Pagy::Backend
47
- # Serve pagy.js or pagy-dev.js
48
- get("/#{PAGY_JS}") do
49
- content_type 'application/javascript'
50
- send_file Pagy.root.join('javascripts', PAGY_JS)
46
+
47
+ get('/javascripts/:file') do
48
+ format = params[:file].split('.').last
49
+ if format == 'js'
50
+ content_type 'application/javascript'
51
+ elsif format == 'map'
52
+ content_type 'application/json'
53
+ end
54
+ send_file Pagy.root.join('javascripts', params[:file])
51
55
  end
56
+
52
57
  # Edit this action as needed
53
58
  get '/' do
54
59
  collection = MockCollection.new
@@ -93,15 +98,16 @@ __END__
93
98
  <html lang="en">
94
99
  <html>
95
100
  <head>
96
- <script src="<%= %(/#{PAGY_JS}) %>"></script>
97
- <script type="application/javascript">
101
+ <title>Pagy Repro App</title>
102
+ <script src="javascripts/pagy.min.js"></script>
103
+ <script>
98
104
  window.addEventListener("load", Pagy.init);
99
105
  </script>
100
106
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
101
107
  <style type="text/css">
102
108
  @media screen { html, body {
103
109
  font-size: 1rem;
104
- line-heigth: 1.2s;
110
+ line-height: 1.2s;
105
111
  padding: 0;
106
112
  margin: 0;
107
113
  } }
@@ -127,7 +133,6 @@ __END__
127
133
  <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
128
134
  </style>
129
135
  </head>
130
-
131
136
  <body>
132
137
  <%= yield %>
133
138
  </body>
@@ -135,10 +140,10 @@ __END__
135
140
 
136
141
  @@ main
137
142
  <div class="content">
138
- <h3>Pagy Repro App</h3>
143
+ <h1>Pagy Repro App</h1>
139
144
  <p> Self-contained, standalone Sinatra app usable to easily reproduce any pagy issue.</p>
140
145
  <p>Please, report the following versions in any new issue.</p>
141
- <h4>Versions</h4>
146
+ <h2>Versions</h4>
142
147
  <ul>
143
148
  <li>Ruby: <%= RUBY_VERSION %></li>
144
149
  <li>Rack: <%= Rack::RELEASE %></li>
@@ -146,23 +151,27 @@ __END__
146
151
  <li>Pagy: <%= Pagy::VERSION %></li>
147
152
  </ul>
148
153
 
149
- <h4>Collection</h4>
150
- <p>@records: <%= @records.join(',') %></p>
154
+ <h3>Collection</h3>
155
+ <p id="records">@records: <%= @records.join(',') %></p>
151
156
 
152
157
  <hr>
153
158
 
154
159
  <h4>pagy_nav</h4>
155
- <%= pagy_nav(@pagy) %>
160
+ <%= pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
161
+
162
+ <h4>pagy_nav_js</h4>
163
+ <%= pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
156
164
 
157
165
  <h4>pagy_nav_js</h4>
158
- <%= pagy_nav_js(@pagy) %>
166
+ <%= pagy_nav_js(@pagy, id: 'nav-js-responsive', aria_label: 'Pages nav_js_responsove',
167
+ steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
159
168
 
160
169
  <h4>pagy_combo_nav_js</h4>
161
- <%= pagy_combo_nav_js(@pagy) %>
170
+ <%= pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
162
171
 
163
- <h4>pagy_items_selector_js</h4>
164
- <%= pagy_items_selector_js(@pagy) %>
172
+ <h4>pagy_limit_selector_js</h4>
173
+ <%= pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
165
174
 
166
175
  <h4>pagy_info</h4>
167
- <%= pagy_info(@pagy) %>
176
+ <%= pagy_info(@pagy, id: 'pagy-info') %>
168
177
  </div>
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ 0db96a70cc96bc7061757f38eec002ce6b14c6d987c4373d79a9f48bdcb0a26f4e00c88eec7a18c496d2779eb277f8b4a85f41dcac4c85482c7d5dd7cf05ba87
Binary file
Binary file
Binary file
Binary file
@@ -1,10 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- VERSION = '8.0.0'
5
- APPS = %w[repro rails demo calendar].freeze
4
+ VERSION = '9.0.0'
5
+ APPS = %w[repro rails demo calendar keyset_ar keyset_s].freeze
6
+ LINUX = RbConfig::CONFIG['host_os'].include?('linux')
7
+ HOST = '0.0.0.0'
8
+ PORT = '8000'
6
9
 
7
- require_relative '../optimist'
10
+ require_relative '../lib/optimist'
8
11
  opts = Optimist.options do
9
12
  text <<~HEAD
10
13
  Pagy #{VERSION} (https://ddnexus.github.io/pagy/playground)
@@ -14,33 +17,43 @@ opts = Optimist.options do
14
17
  rails Reproduce rails related issues
15
18
  demo Showcase all the helpers and styles
16
19
  calendar Showcase the calendar; reproduce related issues
20
+ keyset_ar Showcase the keyset ActiveRecord pagination
21
+ keyset_s Showcase the keyset Sequel pagination
17
22
  USAGE
18
23
  pagy APP [options] Showcase APP from the installed gem
19
24
  pagy clone APP Clone APP to the current dir
20
25
  pagy APPFILE [options] Develop APPFILE from local path
21
26
  EXAMPLES
22
- pagy demo Showcase demo at http://0.0.0.0:8000
27
+ pagy demo Showcase demo at http://#{HOST}:#{PORT}
23
28
  pagy clone repro Clone repro to ./repro.ru
24
- pagy ~/my-repro.ru Develop ~/my-repro.ru at http://0.0.0.0:8000
29
+ pagy ~/my-repro.ru Develop ~/my-repro.ru at#{HOST}:#{PORT}
25
30
  HEAD
26
31
  text 'Rackup options'
27
- opt :env, 'Environment', default: 'development'
28
- opt :host, 'Host', default: '0.0.0.0', short: :o
29
- opt :port, 'Port', default: 8000
30
- text 'Rerun options'
31
- opt :rerun, 'Enable rerun for development', default: true
32
- opt :clear, 'Clear screen before each rerun'
32
+ opt :env, 'Environment', default: 'development'
33
+ opt :host, 'Host', default: HOST, short: :o
34
+ opt :port, 'Port', default: PORT
35
+ opt :install, 'Install bundle for users', default: true
36
+ if LINUX
37
+ text 'Rerun options'
38
+ opt :rerun, 'Enable rerun for development', default: true
39
+ opt :clear, 'Clear screen before each rerun'
40
+ end
33
41
  text 'Other options'
34
- opt :quiet, 'Quiet mode for development'
42
+ opt :quiet, 'Quiet mode for development'
35
43
  version VERSION
36
44
  end
37
45
  Optimist.educate if ARGV.empty?
38
46
 
47
+ run_from_repo = File.exist?(File.expand_path('../pagy.gemspec', __dir__))
48
+
49
+ # Handles gems
39
50
  require 'bundler/inline'
40
- gemfile true do
51
+ require 'bundler'
52
+ Bundler.configure
53
+ gemfile(opts[:install]) do
41
54
  source 'https://rubygems.org'
42
55
  gem 'rackup'
43
- gem 'rerun'
56
+ gem 'rerun' if LINUX
44
57
  end
45
58
 
46
59
  path = ->(app) { File.expand_path("../apps/#{app}.ru", __dir__) }
@@ -70,14 +83,20 @@ else
70
83
  end
71
84
  Optimist.die("#{file.inspect} app not found") unless File.exist?(file)
72
85
  # Run command
73
- rackup = "rackup -I #{File.expand_path('..', __dir__)} -r pagy -o #{opts[:host]} -p #{opts[:port]} -E #{opts[:env]} #{file}"
86
+ gem_dir = File.expand_path('..', __dir__)
87
+ rackup = "rackup -I #{gem_dir}/lib -r pagy -o #{opts[:host]} -p #{opts[:port]} -E #{opts[:env]} #{file}"
74
88
  rackup << ' -q' if opts[:quiet]
75
89
  if opts[:rerun]
76
90
  name = File.basename(file)
77
- rerun = "rerun --name #{name} -d #{File.dirname(file)} -p #{name}"
91
+ dir = File.dirname(file)
92
+ rerun = if run_from_repo # rerun app also when gem dir files change (for pagy devs)
93
+ "rerun --name #{name} -d #{dir},#{gem_dir} -p **/*.{rb,js,css,scss,ru,yml}"
94
+ else
95
+ "rerun --name #{name} -d #{dir} -p #{name}" # rerun only when app.ru changes
96
+ end
78
97
  rerun << ' -q' if opts[:quiet]
79
98
  rerun << ' -c' if opts[:clear]
80
99
  rerun << " -- #{rackup}"
81
100
  end
82
- exec(rerun || rackup)
101
+ exec("PAGY_INSTALL_BUNDLE='#{opts[:install]}' #{rerun || rackup}")
83
102
  end
@@ -1,39 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (8.0.0)
3
+ # Pagy initializer file (9.0.0)
4
4
  # Customize only what you really need and notice that the core Pagy works also without any of the following lines.
5
5
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
6
6
 
7
7
 
8
- # Pagy DEFAULT Variables
8
+ # Pagy Variables
9
9
  # See https://ddnexus.github.io/pagy/docs/api/pagy#variables
10
- # All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden per instance by just passing them to
10
+ # You can set any pagy variable as a Pagy::DEFAULT. They can also be overridden per instance by just passing them to
11
11
  # Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods
12
-
13
- # Instance variables
14
- # See https://ddnexus.github.io/pagy/docs/api/pagy#instance-variables
15
- # Pagy::DEFAULT[:page] = 1 # default
16
- # Pagy::DEFAULT[:items] = 20 # default
17
- # Pagy::DEFAULT[:outset] = 0 # default
18
-
19
- # Other Variables
20
- # See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables
21
- # Pagy::DEFAULT[:size] = [1,4,4,1] # default in pagy < 7.0
22
- # Pagy::DEFAULT[:page_param] = :page # default
23
- # Pagy::DEFAULT[:fragment] = '#fragment' # example
24
- # Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example
25
- # Pagy::DEFAULT[:cycle] = true # example
26
- # Pagy::DEFAULT[:request_path] = '/foo' # example
27
- # Pagy::DEFAULT[:count_args] = [] # example for non AR ORMs
28
- # Pagy::DEFAULT[:params] = {} # default
29
- # NOTICE: The :params can be also set as a lambda e.g:
30
- # ->(params){ params.exclude('useless').merge!('custom' => 'useful') }
12
+ # Here are the few that make more sense as DEFAULTs:
13
+ # Pagy::DEFAULT[:limit] = 20 # default
14
+ # Pagy::DEFAULT[:size] = 7 # default
15
+ # Pagy::DEFAULT[:ends] = true # default
16
+ # Pagy::DEFAULT[:page_param] = :page # default
17
+ # Pagy::DEFAULT[:count_args] = [] # example for non AR ORMs
18
+ # Pagy::DEFAULT[:max_pages] = 3000 # example
31
19
 
32
20
 
33
21
  # Extras
34
22
  # See https://ddnexus.github.io/pagy/categories/extra
35
23
 
36
24
 
25
+ # Legacy Compatibility Extras
26
+
27
+ # Size extra: Enable the Array type for the `:size` variable (e.g. `size: [1,4,4,1]`)
28
+ # See https://ddnexus.github.io/pagy/docs/extras/size
29
+ # require 'pagy/extras/size' # must be required before the other extras
30
+
31
+
37
32
  # Backend Extras
38
33
 
39
34
  # Arel extra: For better performance utilizing grouped ActiveRecord collections:
@@ -47,21 +42,12 @@
47
42
  # Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day)
48
43
  # See https://ddnexus.github.io/pagy/docs/extras/calendar
49
44
  # require 'pagy/extras/calendar'
50
- # Default for each unit
51
- # Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination
52
- # Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format
53
- #
54
- # Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination
55
- # Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format
56
- #
57
- # Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination
58
- # Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format
59
- #
60
- # Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
61
- # Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
62
- #
63
- # Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
64
- # Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
45
+ # Default for each calendar unit class in IRB:
46
+ # >> Pagy::Calendar::Year::DEFAULT
47
+ # >> Pagy::Calendar::Quarter::DEFAULT
48
+ # >> Pagy::Calendar::Month::DEFAULT
49
+ # >> Pagy::Calendar::Week::DEFAULT
50
+ # >> Pagy::Calendar::Day::DEFAULT
65
51
  #
66
52
  # Uncomment the following lines, if you need calendar localization without using the I18n extra
67
53
  # module LocalizePagyCalendar
@@ -89,7 +75,7 @@
89
75
  # See http://ddnexus.github.io/pagy/extras/headers
90
76
  # require 'pagy/extras/headers'
91
77
  # Pagy::DEFAULT[:headers] = { page: 'Current-Page',
92
- # items: 'Page-Items',
78
+ # limit: 'Page-Items',
93
79
  # count: 'Total-Count',
94
80
  # pages: 'Total-Pages' } # default
95
81
 
@@ -104,8 +90,8 @@
104
90
 
105
91
  # Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
106
92
  # See https://ddnexus.github.io/pagy/docs/extras/metadata
107
- # you must require the frontend helpers internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
108
- # require 'pagy/extras/frontend_helpers'
93
+ # you must require the JS Tools internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
94
+ # require 'pagy/extras/js_tools'
109
95
  # require 'pagy/extras/metadata'
110
96
  # For performance reasons, you should explicitly set ONLY the metadata you use in the frontend
111
97
  # Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example
@@ -132,48 +118,32 @@
132
118
  # See https://ddnexus.github.io/pagy/docs/extras/bulma
133
119
  # require 'pagy/extras/bulma'
134
120
 
135
- # Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination
136
- # See https://ddnexus.github.io/pagy/docs/extras/foundation
137
- # require 'pagy/extras/foundation'
138
-
139
- # Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination
140
- # See https://ddnexus.github.io/pagy/docs/extras/materialize
141
- # require 'pagy/extras/materialize'
142
-
143
121
  # Pagy extra: Add the pagy styled versions of the javascript-powered navs
144
122
  # and a few other components to the Pagy::Frontend module.
145
123
  # See https://ddnexus.github.io/pagy/docs/extras/pagy
146
124
  # require 'pagy/extras/pagy'
147
125
 
148
- # Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination
149
- # See https://ddnexus.github.io/pagy/docs/extras/semantic
150
- # require 'pagy/extras/semantic'
151
-
152
- # UIkit extra: Add nav helper and templates for UIkit pagination
153
- # See https://ddnexus.github.io/pagy/docs/extras/uikit
154
- # require 'pagy/extras/uikit'
155
-
156
126
  # Multi size var used by the *_nav_js helpers
157
127
  # See https://ddnexus.github.io/pagy/docs/extras/pagy#steps
158
- # Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
128
+ # Pagy::DEFAULT[:steps] = { 0 => 5, 540 => 7, 720 => 9 } # example
159
129
 
160
130
 
161
131
  # Feature Extras
162
132
 
163
- # Gearbox extra: Automatically change the number of items per page depending on the page number
133
+ # Gearbox extra: Automatically change the limit per page depending on the page number
164
134
  # See https://ddnexus.github.io/pagy/docs/extras/gearbox
165
135
  # require 'pagy/extras/gearbox'
166
136
  # set to false only if you want to make :gearbox_extra an opt-in variable
167
137
  # Pagy::DEFAULT[:gearbox_extra] = false # default true
168
- # Pagy::DEFAULT[:gearbox_items] = [15, 30, 60, 100] # default
138
+ # Pagy::DEFAULT[:gearbox_limit] = [15, 30, 60, 100] # default
169
139
 
170
- # Items extra: Allow the client to request a custom number of items per page with an optional selector UI
171
- # See https://ddnexus.github.io/pagy/docs/extras/items
172
- # require 'pagy/extras/items'
173
- # set to false only if you want to make :items_extra an opt-in variable
174
- # Pagy::DEFAULT[:items_extra] = false # default true
175
- # Pagy::DEFAULT[:items_param] = :items # default
176
- # Pagy::DEFAULT[:max_items] = 100 # default
140
+ # Limit extra: Allow the client to request a custom limit per page with an optional selector UI
141
+ # See https://ddnexus.github.io/pagy/docs/extras/limit
142
+ # require 'pagy/extras/limit'
143
+ # set to false only if you want to make :limit_extra an opt-in variable
144
+ # Pagy::DEFAULT[:limit_extra] = false # default true
145
+ # Pagy::DEFAULT[:limit_param] = :limit # default
146
+ # Pagy::DEFAULT[:limit_max] = 100 # default
177
147
 
178
148
  # Overflow extra: Allow for easy handling of overflowing pages
179
149
  # See https://ddnexus.github.io/pagy/docs/extras/overflow
@@ -197,10 +167,9 @@
197
167
  # set to false only if you want to make :jsonapi an opt-in variable
198
168
  # Pagy::DEFAULT[:jsonapi] = false # default true
199
169
 
200
-
201
170
  # Rails
202
171
  # Enable the .js file required by the helpers that use javascript
203
- # (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js)
172
+ # (pagy*_nav_js, pagy*_combo_nav_js, and pagy_limit_selector_js)
204
173
  # See https://ddnexus.github.io/pagy/docs/api/javascript
205
174
 
206
175
  # With the asset pipeline