pagy 0.15.1 → 0.16.0
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 +1 -1
- data/lib/pagy/extras/initializer_example.rb +4 -0
- data/lib/pagy/extras/searchkick.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da9304305299f0be41d53a9d6f13619fd5c625fafe1719b7d2606dc4d41689c2
|
4
|
+
data.tar.gz: 860fd52099ad641fc92ae5a0a1139a2eb93e041aa314071916f80b968dcb27fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1092d3a3c662c9e88ceafd7a5062ca157b1115129878bdb8751de0609422360d07607eb60d4b277a2c18b1253acaf6d39552d314fdd0b679326b445874af00a6
|
7
|
+
data.tar.gz: 2ade9847094373264920036d0ce2fa9eaebcc7d912115f6614799a3f5b078d3b32317db627e2ec23c8dee8df119cc6c976dce1371781e16b1631aac7798b543e
|
data/lib/pagy.rb
CHANGED
@@ -41,6 +41,10 @@
|
|
41
41
|
# See https://ddnexus.github.io/pagy/extras/responsive#breakpoints
|
42
42
|
# Pagy::VARS[:breakpoints] = { 0 => [1,2,2,1], 350 => [2,3,3,2], 550 => [3,4,4,3] } # example of width/size pairs
|
43
43
|
|
44
|
+
# Searchkick: Paginate `Searchkick::Results` objects efficiently avoiding expensive oject-wrapping and without overriding.
|
45
|
+
# See https://ddnexus.github.io/pagy/extras/searchkick
|
46
|
+
# require 'pagy/extras/searchkick'
|
47
|
+
|
44
48
|
# Trim: Remove the page=1 param from links
|
45
49
|
# See https://ddnexus.github.io/pagy/extras/trim
|
46
50
|
# require 'pagy/extras/trim'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/searchkick
|
2
|
+
|
3
|
+
class Pagy
|
4
|
+
# Add specialized backend methods to paginate Searchkick::Results
|
5
|
+
module Backend ; private
|
6
|
+
# Return Pagy object and items
|
7
|
+
def pagy_searchkick(results, vars={})
|
8
|
+
pagy = Pagy.new(pagy_searchkick_get_vars(results, vars))
|
9
|
+
return pagy, results
|
10
|
+
end
|
11
|
+
|
12
|
+
def pagy_searchkick_get_vars(results, vars)
|
13
|
+
# Return the merged variables to initialize the Pagy object
|
14
|
+
{ count: results.total_count,
|
15
|
+
page: results.options[:page],
|
16
|
+
items: results.options[:per_page] }.merge!(vars)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
|
14
14
|
and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/pagy/extras/materialize.rb
|
37
37
|
- lib/pagy/extras/out_of_range.rb
|
38
38
|
- lib/pagy/extras/responsive.rb
|
39
|
+
- lib/pagy/extras/searchkick.rb
|
39
40
|
- lib/pagy/extras/templates/nav.html.erb
|
40
41
|
- lib/pagy/extras/templates/nav.html.haml
|
41
42
|
- lib/pagy/extras/templates/nav.html.slim
|