pagy 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/apps/calendar.ru +745 -0
- data/{lib/apps → apps}/demo.ru +35 -52
- data/apps/keyset_ar.ru +236 -0
- data/apps/keyset_s.ru +238 -0
- data/{lib/apps → apps}/rails.ru +40 -33
- data/{lib/apps → apps}/repro.ru +33 -24
- 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 -0
- 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/{lib/bin → bin}/pagy +36 -17
- data/{lib/config → config}/pagy.rb +37 -68
- data/javascripts/pagy-module.js +100 -0
- data/javascripts/pagy.js +4 -0
- data/javascripts/pagy.min.js +4 -0
- data/javascripts/pagy.min.js.map +10 -0
- data/javascripts/pagy.mjs +100 -0
- data/lib/optimist.rb +1 -1
- data/lib/pagy/b64.rb +33 -0
- data/lib/pagy/backend.rb +24 -15
- data/lib/pagy/calendar/day.rb +5 -4
- data/lib/pagy/calendar/month.rb +5 -4
- data/lib/pagy/calendar/quarter.rb +5 -4
- data/lib/pagy/calendar/unit.rb +103 -0
- data/lib/pagy/calendar/week.rb +4 -4
- data/lib/pagy/calendar/year.rb +5 -4
- data/lib/pagy/calendar.rb +55 -99
- data/lib/pagy/console.rb +2 -2
- data/lib/pagy/countless.rb +17 -16
- data/lib/pagy/extras/arel.rb +8 -10
- data/lib/pagy/extras/array.rb +4 -6
- data/lib/pagy/extras/bootstrap.rb +7 -7
- data/lib/pagy/extras/bulma.rb +13 -9
- data/lib/pagy/extras/calendar.rb +35 -6
- data/lib/pagy/extras/countless.rb +7 -14
- data/lib/pagy/extras/elasticsearch_rails.rb +15 -15
- data/lib/pagy/extras/gearbox.rb +36 -35
- data/lib/pagy/extras/headers.rb +26 -25
- data/lib/pagy/extras/i18n.rb +1 -1
- data/lib/pagy/extras/js_tools.rb +12 -9
- data/lib/pagy/extras/jsonapi.rb +27 -17
- 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 +7 -3
- data/lib/pagy/extras/overflow.rb +9 -8
- data/lib/pagy/extras/pagy.rb +18 -18
- data/lib/pagy/extras/searchkick.rb +11 -11
- data/lib/pagy/extras/size.rb +40 -0
- data/lib/pagy/extras/standalone.rb +8 -8
- data/lib/pagy/extras/trim.rb +3 -3
- data/lib/pagy/frontend.rb +39 -37
- 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 +11 -11
- data/lib/pagy.rb +96 -120
- data/{lib/locales → locales}/ar.yml +9 -10
- data/{lib/locales → locales}/be.yml +2 -2
- data/{lib/locales → locales}/bg.yml +2 -2
- data/{lib/locales → locales}/bs.yml +2 -2
- data/{lib/locales → locales}/ca.yml +5 -7
- data/{lib/locales → locales}/ckb.yml +2 -2
- data/{lib/locales → locales}/cs.yml +2 -2
- data/{lib/locales → locales}/da.yml +5 -7
- data/{lib/locales → locales}/de.yml +2 -2
- data/{lib/locales → locales}/en.yml +2 -2
- data/{lib/locales → locales}/es.yml +2 -2
- data/{lib/locales → locales}/fr.yml +2 -2
- data/{lib/locales → locales}/hr.yml +2 -2
- data/{lib/locales → locales}/id.yml +2 -2
- data/{lib/locales → locales}/it.yml +2 -2
- data/{lib/locales → locales}/ja.yml +2 -2
- data/{lib/locales → locales}/km.yml +2 -2
- data/{lib/locales → locales}/ko.yml +3 -5
- data/{lib/locales → locales}/nb.yml +2 -2
- data/{lib/locales → locales}/nl.yml +2 -2
- data/{lib/locales → locales}/nn.yml +2 -2
- data/{lib/locales → locales}/pl.yml +2 -2
- data/{lib/locales → locales}/pt-BR.yml +2 -2
- data/{lib/locales → locales}/pt.yml +2 -2
- data/{lib/locales → locales}/ru.yml +7 -9
- data/{lib/locales → locales}/sr.yml +2 -2
- data/{lib/locales → locales}/sv-SE.yml +2 -2
- data/{lib/locales → locales}/sv.yml +2 -2
- data/{lib/locales → locales}/sw.yml +2 -2
- data/{lib/locales → locales}/ta.yml +2 -2
- data/{lib/locales → locales}/tr.yml +2 -2
- data/{lib/locales → locales}/uk.yml +2 -2
- data/{lib/locales → locales}/vi.yml +2 -2
- data/{lib/locales → locales}/zh-CN.yml +2 -2
- data/{lib/locales → locales}/zh-HK.yml +2 -2
- data/{lib/locales → locales}/zh-TW.yml +2 -2
- data/pkg/pagy-9.0.0.gem +0 -0
- metadata +75 -70
- data/lib/apps/calendar.ru +0 -2196
- data/lib/javascripts/pagy-dev.js +0 -112
- data/lib/javascripts/pagy-module.js +0 -111
- data/lib/javascripts/pagy.js +0 -1
- data/lib/pagy/calendar/helper.rb +0 -65
- data/lib/pagy/extras/foundation.rb +0 -93
- data/lib/pagy/extras/items.rb +0 -64
- data/lib/pagy/extras/materialize.rb +0 -97
- data/lib/pagy/extras/semantic.rb +0 -91
- data/lib/pagy/extras/uikit.rb +0 -96
- /data/{lib/javascripts/pagy-module.d.ts → javascripts/pagy.d.ts} +0 -0
- /data/{lib/stylesheets → stylesheets}/pagy.css +0 -0
- /data/{lib/stylesheets → stylesheets}/pagy.scss +0 -0
- /data/{lib/stylesheets → stylesheets}/pagy.tailwind.css +0 -0
data/{lib/apps → apps}/rails.ru
RENAMED
@@ -15,27 +15,22 @@
|
|
15
15
|
# DOC
|
16
16
|
# https://ddnexus.github.io/pagy/playground/#2-rails-app
|
17
17
|
|
18
|
-
VERSION = '
|
18
|
+
VERSION = '9.0.0'
|
19
19
|
|
20
20
|
# Gemfile
|
21
21
|
require 'bundler/inline'
|
22
|
-
|
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'
|
27
|
-
|
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 '/
|
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
|
118
|
-
|
119
|
-
|
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
|
-
|
131
|
-
<script
|
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-
|
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
|
-
<
|
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
|
-
<
|
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
|
-
<
|
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>
|
197
|
-
<%==
|
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>
|
data/{lib/apps → apps}/repro.ru
RENAMED
@@ -15,10 +15,12 @@
|
|
15
15
|
# DOC
|
16
16
|
# https://ddnexus.github.io/pagy/playground/#1-repro-app
|
17
17
|
|
18
|
-
VERSION = '
|
18
|
+
VERSION = '9.0.0'
|
19
19
|
|
20
20
|
require 'bundler/inline'
|
21
|
-
|
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/
|
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
|
-
|
48
|
-
get(
|
49
|
-
|
50
|
-
|
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
|
-
|
97
|
-
<script
|
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-
|
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
|
-
<
|
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
|
-
<
|
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
|
-
<
|
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>
|
164
|
-
<%=
|
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
|
data/{lib/bin → bin}/pagy
RENAMED
@@ -1,10 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
VERSION = '
|
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
|
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
|
29
|
+
pagy ~/my-repro.ru Develop ~/my-repro.ru at#{HOST}:#{PORT}
|
25
30
|
HEAD
|
26
31
|
text 'Rackup options'
|
27
|
-
opt :env,
|
28
|
-
opt :host,
|
29
|
-
opt :port,
|
30
|
-
|
31
|
-
|
32
|
-
|
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,
|
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
|
-
|
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
|
-
|
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
|
-
|
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 (
|
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
|
8
|
+
# Pagy Variables
|
9
9
|
# See https://ddnexus.github.io/pagy/docs/api/pagy#variables
|
10
|
-
#
|
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
|
-
#
|
14
|
-
#
|
15
|
-
# Pagy::DEFAULT[:
|
16
|
-
# Pagy::DEFAULT[:
|
17
|
-
# Pagy::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
|
52
|
-
# Pagy::Calendar::
|
53
|
-
#
|
54
|
-
# Pagy::Calendar::
|
55
|
-
# Pagy::Calendar::
|
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
|
-
#
|
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
|
108
|
-
# require 'pagy/extras/
|
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 =>
|
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
|
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[:
|
138
|
+
# Pagy::DEFAULT[:gearbox_limit] = [15, 30, 60, 100] # default
|
169
139
|
|
170
|
-
#
|
171
|
-
# See https://ddnexus.github.io/pagy/docs/extras/
|
172
|
-
# require 'pagy/extras/
|
173
|
-
# set to false only if you want to make :
|
174
|
-
# Pagy::DEFAULT[:
|
175
|
-
# Pagy::DEFAULT[:
|
176
|
-
# Pagy::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
|
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
|