pagy 0.8.3 → 0.8.4
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 +3 -3
- data/lib/pagy/frontend.rb +10 -11
- 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: dda23dfaf654fccdeafca5c511f6e1f23c501e4599989f5e6887b1d1f0ecc3ad
|
4
|
+
data.tar.gz: 9be4570f44ffdd234e58364ff92bbec6fd5f8dedad6050a7defef37314dd84e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e7cb89a79da6e3a8f9610ed4e0088cfc731a14f61fef6b0a1dc40eec0b692639dd3d41692774bf0f8e87464609eb9e52cc0afd653c9f66214b3e703d3d559d
|
7
|
+
data.tar.gz: d2418aa0a685140b8e73c06fe510076126bdc62f0d264f1be5a1e282f53600387ae5905b5c552aaf19d6e2b82eb64a215044484189a5522323ea578e85ea00a2
|
data/lib/pagy.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
-
class Pagy ; VERSION = '0.8.
|
5
|
+
class Pagy ; VERSION = '0.8.4'
|
6
6
|
|
7
7
|
class OutOfRangeError < StandardError; end
|
8
8
|
|
9
9
|
# root pathname to get the path of pagy files like templates or dictionaries
|
10
10
|
def self.root; Pathname.new(__FILE__).dirname end
|
11
11
|
|
12
|
-
# default
|
13
|
-
VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params: {} }
|
12
|
+
# default vars
|
13
|
+
VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params: {}, anchor: ''.freeze, link_extra: ''.freeze, item_path: 'pagy.info.item_name'.freeze }
|
14
14
|
|
15
15
|
attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next
|
16
16
|
|
data/lib/pagy/frontend.rb
CHANGED
@@ -28,9 +28,9 @@ class Pagy
|
|
28
28
|
|
29
29
|
# return examples: "Displaying items 41-60 of 324 in total" or "Displaying Products 41-60 of 324 in total"
|
30
30
|
def pagy_info(pagy)
|
31
|
-
name = pagy_t(pagy.vars[:item_path]
|
32
|
-
|
33
|
-
pagy_t(
|
31
|
+
name = pagy_t(pagy.vars[:item_path], count: pagy.count)
|
32
|
+
path = pagy.pages == 1 ? 'pagy.info.single_page'.freeze : 'pagy.info.multiple_pages'.freeze
|
33
|
+
pagy_t(path, item_name: name, count: pagy.count, from: pagy.from, to: pagy.to)
|
34
34
|
end
|
35
35
|
|
36
36
|
|
@@ -47,16 +47,15 @@ class Pagy
|
|
47
47
|
|
48
48
|
MARKER = "-pagy-#{'pagy'.hash}-".freeze
|
49
49
|
|
50
|
-
# returns a
|
51
|
-
def pagy_link_proc(pagy,
|
52
|
-
p_prev, p_next
|
53
|
-
a, b = %(<a href="#{pagy_url_for(MARKER, pagy)}"
|
54
|
-
-> (n, text=n,
|
55
|
-
|
56
|
-
|
50
|
+
# returns a performance optimized proc to generate the HTML links
|
51
|
+
def pagy_link_proc(pagy, link_extra=''.freeze)
|
52
|
+
p_prev, p_next = pagy.prev, pagy.next
|
53
|
+
a, b = %(<a href="#{pagy_url_for(MARKER, pagy)}" #{pagy.vars[:link_extra]} #{link_extra}).split(MARKER, 2)
|
54
|
+
-> (n, text=n, extra=''.freeze) { "#{a}#{n}#{b}#{ if n == p_prev ; ' rel="prev"'.freeze
|
55
|
+
elsif n == p_next ; ' rel="next"'.freeze
|
56
|
+
else ''.freeze end } #{extra}>#{text}</a>" }
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
59
|
# Pagy::Frontend::I18N constant
|
61
60
|
zero_one = [:zero, :one]; I18N = { plurals: -> (c) {(zero_one[c] || :other).to_s.freeze}, data: {}}
|
62
61
|
def I18N.load_file(file) I18N[:data].replace(YAML.load_file(file).first[1]) 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.8.
|
4
|
+
version: 0.8.4
|
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-06-
|
11
|
+
date: 2018-06-02 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,
|