pagy 5.1.1 → 5.1.2
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/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/pagy/extras/standalone.rb +8 -6
- data/lib/pagy/url_helpers.rb +5 -5
- data/lib/pagy.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af6c795ba446552a412f0f45e76a267cf767d8f4dec3564a90096525bb298ea
|
4
|
+
data.tar.gz: 57a3f62877f0ed653ebe68f59963fb865e252e68c55e5c3a91794b9aa3b9584a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0520f9933ea293895b8d26b0a78ea0af1a61054b5b89fce3a06c1f8f292d82357f6e105f76ab7bd4665f6ee9765bc69ce284428b8fe61b8f0a6b4768136c8e4a
|
7
|
+
data.tar.gz: '0903950d58220f510b5c2700b42f23f19c5cd267bc73eb5404d918863717b816836609256ef3a340534a9bc74e50260915b8b023b502c9dbe503bb443fab968f'
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (5.1.
|
3
|
+
# Pagy initializer file (5.1.2)
|
4
4
|
# Customize only what you really need and notice that 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
|
|
data/lib/javascripts/pagy.js
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
require 'uri'
|
5
5
|
class Pagy
|
6
|
+
# Use pagy without any request object, nor Rack environment/gem, nor any defined params method,
|
7
|
+
# even in the irb/rails console without any app or config.
|
6
8
|
module StandaloneExtra
|
7
9
|
# Extracted from Rack::Utils and reformatted for rubocop
|
8
10
|
module QueryUtils
|
@@ -34,15 +36,15 @@ class Pagy
|
|
34
36
|
# it works exactly as the regular #pagy_url_for, relying on the params method and Rack.
|
35
37
|
# If there is a defined pagy.vars[:url] variable it does not need the params method nor Rack.
|
36
38
|
def pagy_url_for(pagy, page, absolute: nil)
|
37
|
-
|
38
|
-
return super unless (url =
|
39
|
+
vars = pagy.vars
|
40
|
+
return super unless (url = vars[:url])
|
39
41
|
|
40
|
-
params
|
41
|
-
params[
|
42
|
-
params[
|
42
|
+
params = vars[:params].clone # safe when it gets reused
|
43
|
+
params[vars[:page_param]] = page
|
44
|
+
params[vars[:items_param]] = vars[:items] if vars[:items_extra]
|
43
45
|
|
44
46
|
query_string = "?#{QueryUtils.build_nested_query(pagy_massage_params(params))}"
|
45
|
-
"#{url}#{query_string}#{
|
47
|
+
"#{url}#{query_string}#{vars[:fragment]}"
|
46
48
|
end
|
47
49
|
end
|
48
50
|
# In ruby 3+ `UrlHelpers.prepend StandaloneExtra` would be enough instead of using the next 2 lines
|
data/lib/pagy/url_helpers.rb
CHANGED
@@ -7,13 +7,13 @@ class Pagy
|
|
7
7
|
# It supports all Rack-based frameworks (Sinatra, Padrino, Rails, ...).
|
8
8
|
# For non-rack environments you can use the standalone extra
|
9
9
|
def pagy_url_for(pagy, page, absolute: nil)
|
10
|
-
|
11
|
-
params
|
12
|
-
params[
|
13
|
-
params[
|
10
|
+
vars = pagy.vars
|
11
|
+
params = request.params.merge(vars[:params].transform_keys(&:to_s))
|
12
|
+
params[vars[:page_param].to_s] = page
|
13
|
+
params[vars[:items_param].to_s] = vars[:items] if vars[:items_extra]
|
14
14
|
|
15
15
|
query_string = "?#{Rack::Utils.build_nested_query(pagy_massage_params(params))}"
|
16
|
-
"#{request.base_url if absolute}#{request.path}#{query_string}#{
|
16
|
+
"#{request.base_url if absolute}#{request.path}#{query_string}#{vars[:fragment]}"
|
17
17
|
end
|
18
18
|
|
19
19
|
# Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
|
data/lib/pagy.rb
CHANGED