pagy 4.10.2 → 4.11.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/lib/config/pagy.rb +2 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/pagy.rb +1 -1
- data/lib/pagy/countless.rb +2 -0
- data/lib/pagy/extras/countless.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed7987ef93f9d2d45f8b37c7d8c62546bb08b658699d4fdacf7e06b2e5abdefe
|
4
|
+
data.tar.gz: d2330d05cbf068d938425ed64ec3a0b0a16cf86d36cd2a2b2d8fc2568942a2d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c938d41fae6e33cfd0d569655b134f2d239fe44f6fc5cdcfc76234e20d5c6a9e2650e6bd6f3230044783353ba65dde5afb24867af8df4c59189eee67dda25fea
|
7
|
+
data.tar.gz: 585446ab8b45078fcb666dc9a406516eeac7f715cca90118d5927f5d89acf0cc51056aa75aebed9885c3e5b25f61f9e4baad75869f2d244ab01a359919493b98
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (4.
|
3
|
+
# Pagy initializer file (4.11.0)
|
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
|
|
@@ -42,6 +42,7 @@
|
|
42
42
|
# Countless extra: Paginate without any count, saving one query per rendering
|
43
43
|
# See https://ddnexus.github.io/pagy/extras/countless
|
44
44
|
# require 'pagy/extras/countless'
|
45
|
+
# Pagy::VARS[:countless_minimal] = false # default (eager loading)
|
45
46
|
|
46
47
|
# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
|
47
48
|
# See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
|
data/lib/javascripts/pagy.js
CHANGED
data/lib/pagy.rb
CHANGED
data/lib/pagy/countless.rb
CHANGED
@@ -11,6 +11,8 @@ class Pagy
|
|
11
11
|
# Merge and validate the options, do some simple arithmetic and set a few instance variables
|
12
12
|
def initialize(vars={}) # rubocop:disable Lint/MissingSuper
|
13
13
|
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
|
14
|
+
@vars[:fragment] = Pagy.deprecated_var(:anchor, @vars[:anchor], :fragment, @vars[:fragment]) if @vars[:anchor]
|
15
|
+
|
14
16
|
INSTANCE_VARS_MIN.each do |k,min| # validate instance variables
|
15
17
|
raise VariableError.new(self), "expected :#{k} >= #{min}; got #{@vars[k].inspect}" \
|
16
18
|
unless @vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min
|
@@ -5,6 +5,8 @@ require 'pagy/countless'
|
|
5
5
|
|
6
6
|
class Pagy
|
7
7
|
|
8
|
+
VARS[:countless_minimal] = false
|
9
|
+
|
8
10
|
module Backend
|
9
11
|
private # the whole module is private so no problem with including it in a controller
|
10
12
|
|
@@ -17,13 +19,15 @@ class Pagy
|
|
17
19
|
# Sub-method called only by #pagy_countless: here for easy customization of variables by overriding
|
18
20
|
def pagy_countless_get_vars(_collection, vars)
|
19
21
|
pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
|
20
|
-
vars[:page]
|
22
|
+
vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
|
21
23
|
vars
|
22
24
|
end
|
23
25
|
|
24
26
|
# Sub-method called only by #pagy_countless: here for easy customization of record-extraction by overriding
|
25
27
|
def pagy_countless_get_items(collection, pagy)
|
26
28
|
# This should work with ActiveRecord, Sequel, Mongoid...
|
29
|
+
return collection.offset(pagy.offset).limit(pagy.items) if pagy.vars[:countless_minimal]
|
30
|
+
|
27
31
|
items = collection.offset(pagy.offset).limit(pagy.items + 1).to_a
|
28
32
|
items_size = items.size
|
29
33
|
items.pop if items_size == pagy.items + 1
|
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: 4.
|
4
|
+
version: 4.11.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: 2021-08-
|
11
|
+
date: 2021-08-20 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,
|