pagy 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pagy.rb +2 -2
- data/lib/pagy/frontend.rb +4 -4
- data/pagy.gemspec +2 -2
- 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: 9fc2f90371fc435135b19f4ee4be00d69cdf946cb925babfb6646b03306d62c5
|
4
|
+
data.tar.gz: fd07adf8fe473bc5e6aaf644a7d08fb1de9352b7aec204338cd11c26f610c12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc0a479d3bd32c7f06814912d107079e1c31f1c73f3033a4d69566ade0b98339d5104371e3b59932dd00134605b6c2e46d1b6db89ba5ef88f060d81006519c87
|
7
|
+
data.tar.gz: 1aa594ad6986364960fe70df3cad7f41474e66f8b6fb9995d075195ea340661bc729c8b6459c9f8eed190fc7bb447d2b4456a09127fe74e255f7f7bec01c19fd
|
data/lib/pagy.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
-
class Pagy ; VERSION = '0.8.
|
5
|
+
class Pagy ; VERSION = '0.8.1'
|
6
6
|
|
7
7
|
class OutOfRangeError < StandardError; end
|
8
8
|
|
@@ -10,7 +10,7 @@ class Pagy ; VERSION = '0.8.0'
|
|
10
10
|
def self.root; Pathname.new(__FILE__).dirname end
|
11
11
|
|
12
12
|
# default core vars
|
13
|
-
VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page }
|
13
|
+
VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params: {} }
|
14
14
|
|
15
15
|
# default I18n vars
|
16
16
|
zero_one = [:zero, :one] ; I18N = { file: Pagy.root.join('locales', 'pagy.yml').to_s, plurals: -> (c) {(zero_one[c] || :other).to_s.freeze} }
|
data/lib/pagy/frontend.rb
CHANGED
@@ -35,9 +35,9 @@ class Pagy
|
|
35
35
|
|
36
36
|
|
37
37
|
# this works with all Rack-based frameworks (Sinatra, Padrino, Rails, ...)
|
38
|
-
def pagy_url_for(page,
|
39
|
-
params = request.GET.merge(page_param => page)
|
40
|
-
"#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}"
|
38
|
+
def pagy_url_for(page, pagy)
|
39
|
+
params = request.GET.merge(pagy.vars[:page_param] => page).merge!(pagy.vars[:params])
|
40
|
+
"#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{pagy.vars[:anchor]}"
|
41
41
|
end
|
42
42
|
|
43
43
|
|
@@ -50,7 +50,7 @@ class Pagy
|
|
50
50
|
# returns a specialized proc to generate the HTML links
|
51
51
|
def pagy_link_proc(pagy, lx=''.freeze) # "lx" means "link extra"
|
52
52
|
p_prev, p_next, p_lx = pagy.prev, pagy.next, pagy.vars[:link_extra]
|
53
|
-
a, b = %(<a href="#{pagy_url_for(MARKER, pagy
|
53
|
+
a, b = %(<a href="#{pagy_url_for(MARKER, pagy)}"#{p_lx ? %( #{p_lx}) : ''.freeze}#{lx.empty? ? lx : %( #{lx})}).split(MARKER)
|
54
54
|
-> (n, text=n, x=''.freeze) { "#{a}#{n}#{b}#{ if n == p_prev ; ' rel="prev"'.freeze
|
55
55
|
elsif n == p_next ; ' rel="next"'.freeze
|
56
56
|
else ''.freeze end }#{x.empty? ? x : %( #{x})}>#{text}</a>" }
|
data/pagy.gemspec
CHANGED
@@ -32,10 +32,10 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_development_dependency 'rubocop', '~> 0.55.0' # needs to be fixed since it constantly adds new cops
|
33
33
|
|
34
34
|
|
35
|
-
s.post_install_message = <<
|
35
|
+
s.post_install_message = <<END_OF_MESSAGE
|
36
36
|
******************************************************************************
|
37
37
|
Pagy CHANGELOG: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
|
38
38
|
******************************************************************************
|
39
|
-
|
39
|
+
END_OF_MESSAGE
|
40
40
|
|
41
41
|
end
|