pagy 3.8.3 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/locales/bs.yml +24 -0
- data/lib/locales/cs.yml +22 -0
- data/lib/locales/hr.yml +24 -0
- data/lib/locales/sr.yml +23 -0
- data/lib/locales/sw.yml +22 -0
- data/lib/locales/utils/p11n.rb +12 -1
- data/lib/pagy.rb +25 -12
- data/lib/pagy/countless.rb +1 -1
- data/lib/pagy/exceptions.rb +1 -0
- data/lib/pagy/extras/support.rb +10 -2
- data/lib/pagy/frontend.rb +1 -0
- metadata +11 -5
- data/lib/locales/README.md +0 -35
- data/pagy.gemspec +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e16e1b508c2096d675f846a898da3e1338e8535b460074535e1742cd08a3c6cb
|
4
|
+
data.tar.gz: 450a453312266d3af1f8b18a9cd0734ebc002a6533b9f6c269d7802706f66116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da6eccb117de48a28d0572d011b29040c7c5f17dcb8282a1a7eadc0c5d11f38aea062e6a4f8e6db40ceba2b2022a54af1deb74e7a2eeb720f0b76b4fdba11098
|
7
|
+
data.tar.gz: 873549bfee07251e7c5948eb24837f01309db20b69e512cffa53a8552e5ca6c634c60a49239d0e87480635118e83e213acc29981d9cbd0d30874a912443e4a6d
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2020 Domizio Demichelis
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/config/pagy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Pagy initializer file (3.
|
4
|
+
# Pagy initializer file (3.13.0)
|
5
5
|
# Customize only what you really need and notice that Pagy works also without any of the following lines.
|
6
6
|
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
7
7
|
|
data/lib/javascripts/pagy.js
CHANGED
data/lib/locales/bs.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
bs:
|
4
|
+
pagy:
|
5
|
+
|
6
|
+
item_name:
|
7
|
+
one: "stavka"
|
8
|
+
few: "stavke"
|
9
|
+
many: "stavki"
|
10
|
+
other: "stavki"
|
11
|
+
|
12
|
+
nav:
|
13
|
+
prev: "‹ Prethodna"
|
14
|
+
next: "Sljedeća ›"
|
15
|
+
gap: "…"
|
16
|
+
|
17
|
+
info:
|
18
|
+
no_items: "Nije pronađena %{item_name}"
|
19
|
+
single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
|
20
|
+
multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
|
21
|
+
|
22
|
+
combo_nav_js: "Stranica %{page_input} od %{pages}"
|
23
|
+
|
24
|
+
items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
|
data/lib/locales/cs.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# :czech pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
cs:
|
4
|
+
pagy:
|
5
|
+
item_name:
|
6
|
+
one: "položka"
|
7
|
+
few: "položek"
|
8
|
+
other: "položky"
|
9
|
+
|
10
|
+
nav:
|
11
|
+
prev: "‹ Předchozí"
|
12
|
+
next: "Další ›"
|
13
|
+
gap: "…"
|
14
|
+
|
15
|
+
info:
|
16
|
+
no_items: "Nic nebylo nalezeno"
|
17
|
+
single_page: "Zobrazeno <b>%{count}</b> %{item_name}"
|
18
|
+
multiple_pages: "Zobrazeno %{item_name} <b>%{from}-%{to}</b> z <b>%{count}</b> celkem"
|
19
|
+
|
20
|
+
combo_nav_js: "Strana %{page_input} z %{pages}"
|
21
|
+
|
22
|
+
items_selector_js: "Zobrazit %{items_input} %{item_name} na stránce"
|
data/lib/locales/hr.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
hr:
|
4
|
+
pagy:
|
5
|
+
|
6
|
+
item_name:
|
7
|
+
one: "stavka"
|
8
|
+
few: "stavke"
|
9
|
+
many: "stavki"
|
10
|
+
other: "stavki"
|
11
|
+
|
12
|
+
nav:
|
13
|
+
prev: "‹ Prethodna"
|
14
|
+
next: "Sljedeća ›"
|
15
|
+
gap: "…"
|
16
|
+
|
17
|
+
info:
|
18
|
+
no_items: "Nije pronađena %{item_name}"
|
19
|
+
single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
|
20
|
+
multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
|
21
|
+
|
22
|
+
combo_nav_js: "Stranica %{page_input} od %{pages}"
|
23
|
+
|
24
|
+
items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
|
data/lib/locales/sr.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
sr:
|
4
|
+
pagy:
|
5
|
+
item_name:
|
6
|
+
one: "ставка"
|
7
|
+
few: "ставкe"
|
8
|
+
many: "ставки"
|
9
|
+
other: "ставки"
|
10
|
+
|
11
|
+
nav:
|
12
|
+
prev: "‹ Претходна"
|
13
|
+
next: "Следећa ›"
|
14
|
+
gap: "…"
|
15
|
+
|
16
|
+
info:
|
17
|
+
no_items: "Нema пронађених %{item_name}"
|
18
|
+
single_page: "Приказује се <b>%{count}</b> %{item_name}"
|
19
|
+
multiple_pages: "Приказ %{item_name} <b>%{from}-%{to}</b> од <b>%{count}</b> укупно"
|
20
|
+
|
21
|
+
combo_nav_js: "Страниca %{page_input} од %{pages}"
|
22
|
+
|
23
|
+
items_selector_js: "Прикажи %{items_input} %{item_name} по страниcи"
|
data/lib/locales/sw.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# :one_other pluralization
|
2
|
+
|
3
|
+
sw:
|
4
|
+
pagy:
|
5
|
+
|
6
|
+
item_name:
|
7
|
+
one: "kifaa"
|
8
|
+
other: "vifaa"
|
9
|
+
|
10
|
+
nav:
|
11
|
+
prev: "‹ Awali"
|
12
|
+
next: "Ifuatayo ›"
|
13
|
+
gap: "…"
|
14
|
+
|
15
|
+
info:
|
16
|
+
no_items: "Hamna %{item_name} vilivyopatikana"
|
17
|
+
single_page: "Inaonyesha %{item_name} <b>%{count}</b>"
|
18
|
+
multiple_pages: "Inaonyesha %{item_name} <b>%{from}-%{to}</b> ya <b>%{count}</b> kwa jumla"
|
19
|
+
|
20
|
+
combo_nav_js: "Kurasa %{page_input} ya %{pages}"
|
21
|
+
|
22
|
+
items_selector_js: "Onyesha %{items_input} %{item_name} kwa kila ukurasa"
|
data/lib/locales/utils/p11n.rb
CHANGED
@@ -32,6 +32,13 @@ p11n = {
|
|
32
32
|
end
|
33
33
|
end,
|
34
34
|
|
35
|
+
west_slavic: lambda do |n|
|
36
|
+
if n == 1 ; 'one'
|
37
|
+
elsif [2, 3, 4].include?(n) ; 'few'
|
38
|
+
else ; 'other'
|
39
|
+
end
|
40
|
+
end,
|
41
|
+
|
35
42
|
one_two_other: lambda do |n|
|
36
43
|
if n == 1 ; 'one'
|
37
44
|
elsif n == 2 ; 'two'
|
@@ -60,19 +67,23 @@ p11n = {
|
|
60
67
|
# The default pluralization for locales not explicitly listed here
|
61
68
|
# is the :one_other pluralization proc (used for English)
|
62
69
|
plurals = Hash.new(p11n[:one_other]).tap do |hash|
|
70
|
+
hash['bs'] = p11n[:east_slavic]
|
71
|
+
hash['cs'] = p11n[:west_slavic]
|
63
72
|
hash['id'] = p11n[:other]
|
64
73
|
hash['fr'] = p11n[:one_upto_two_other]
|
74
|
+
hash['hr'] = p11n[:east_slavic]
|
65
75
|
hash['ja'] = p11n[:other]
|
76
|
+
hash['km'] = p11n[:other]
|
66
77
|
hash['ko'] = p11n[:other]
|
67
78
|
hash['pl'] = p11n[:polish]
|
68
79
|
hash['ru'] = p11n[:east_slavic]
|
80
|
+
hash['sr'] = p11n[:east_slavic]
|
69
81
|
hash['sv'] = p11n[:one_two_other]
|
70
82
|
hash['sv-SE'] = p11n[:one_two_other]
|
71
83
|
hash['tr'] = p11n[:other]
|
72
84
|
hash['zh-CN'] = p11n[:other]
|
73
85
|
hash['zh-HK'] = p11n[:other]
|
74
86
|
hash['zh-TW'] = p11n[:other]
|
75
|
-
hash['km'] = p11n[:other]
|
76
87
|
end
|
77
88
|
|
78
89
|
[ plurals, p11n ]
|
data/lib/pagy.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'pathname'
|
6
6
|
|
7
|
-
class Pagy ; VERSION = '3.
|
7
|
+
class Pagy ; VERSION = '3.13.0'
|
8
8
|
|
9
9
|
# Root pathname to get the path of Pagy files like templates or dictionaries
|
10
10
|
def self.root; @root ||= Pathname.new(__FILE__).dirname.freeze end
|
@@ -32,18 +32,31 @@ class Pagy ; VERSION = '3.8.3'
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
def series(size=@vars[:size])
|
36
|
+
return [] if size.empty?
|
37
|
+
raise VariableError.new(self), "expected 4 items >= 0 in :size; got #{size.inspect}" \
|
38
|
+
unless size.size == 4 && size.all?{ |num| num >= 0 rescue false }
|
39
|
+
# This algorithm (backported from pagy 4.3) is up to ~5x faster and ~2.3x lighter than the previous one
|
40
|
+
left_gap_start = 1 + size[0]
|
41
|
+
left_gap_end = @page - size[1] - 1
|
42
|
+
right_gap_start = @page + size[2] + 1
|
43
|
+
right_gap_end = @last - size[3]
|
44
|
+
left_gap_end = right_gap_end if left_gap_end > right_gap_end
|
45
|
+
right_gap_start = left_gap_start if left_gap_start > right_gap_start
|
46
|
+
series = []
|
47
|
+
start = 1
|
48
|
+
if (left_gap_end - left_gap_start) > 0
|
49
|
+
series.push(*start..(left_gap_start - 1), :gap)
|
50
|
+
start = left_gap_end + 1
|
46
51
|
end
|
52
|
+
if (right_gap_end - right_gap_start) > 0
|
53
|
+
series.push(*start..(right_gap_start - 1), :gap)
|
54
|
+
start = right_gap_end + 1
|
55
|
+
end
|
56
|
+
series.push(*start..@last)
|
57
|
+
series[series.index(@page)] = @page.to_s
|
58
|
+
series
|
59
|
+
end
|
47
60
|
|
48
61
|
end
|
49
62
|
|
data/lib/pagy/countless.rb
CHANGED
@@ -8,7 +8,7 @@ class Pagy
|
|
8
8
|
class Countless < Pagy
|
9
9
|
|
10
10
|
# Merge and validate the options, do some simple arithmetic and set a few instance variables
|
11
|
-
def initialize(vars={})
|
11
|
+
def initialize(vars={}) # rubocop:disable Lint/MissingSuper
|
12
12
|
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
|
13
13
|
{ items:1, outset:0, page:1 }.each do |k,min| # validate instance variables
|
14
14
|
(@vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min) \
|
data/lib/pagy/exceptions.rb
CHANGED
data/lib/pagy/extras/support.rb
CHANGED
@@ -15,15 +15,23 @@ class Pagy
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def pagy_prev_link(pagy, text = pagy_t('pagy.nav.prev'), link_extra = '')
|
18
|
-
pagy.prev ? %(<span class="page prev"><a href="#{
|
18
|
+
pagy.prev ? %(<span class="page prev"><a href="#{pagy_url_for(pagy.prev, pagy)}" rel="prev" aria-label="previous" #{pagy.vars[:link_extra]} #{link_extra}>#{text}</a></span>)
|
19
19
|
: %(<span class="page prev disabled">#{text}</span>)
|
20
20
|
end
|
21
21
|
|
22
22
|
def pagy_next_link(pagy, text = pagy_t('pagy.nav.next'), link_extra = '')
|
23
|
-
pagy.next ? %(<span class="page next"><a href="#{
|
23
|
+
pagy.next ? %(<span class="page next"><a href="#{pagy_url_for(pagy.next, pagy)}" rel="next" aria-label="next" #{pagy.vars[:link_extra]} #{link_extra}>#{text}</a></span>)
|
24
24
|
: %(<span class="page next disabled">#{text}</span>)
|
25
25
|
end
|
26
26
|
|
27
|
+
def pagy_prev_link_tag(pagy)
|
28
|
+
%(<link href="#{pagy_url_for(pagy.prev, pagy)}" rel="prev"/>) if pagy.prev
|
29
|
+
end
|
30
|
+
|
31
|
+
def pagy_next_link_tag(pagy)
|
32
|
+
%(<link href="#{pagy_url_for(pagy.next, pagy)}" rel="next"/>) if pagy.next
|
33
|
+
end
|
34
|
+
|
27
35
|
end
|
28
36
|
|
29
37
|
end
|
data/lib/pagy/frontend.rb
CHANGED
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: 3.
|
4
|
+
version: 3.13.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:
|
11
|
+
date: 2021-04-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,
|
@@ -22,14 +22,16 @@ files:
|
|
22
22
|
- LICENSE.txt
|
23
23
|
- lib/config/pagy.rb
|
24
24
|
- lib/javascripts/pagy.js
|
25
|
-
- lib/locales/README.md
|
26
25
|
- lib/locales/bg.yml
|
26
|
+
- lib/locales/bs.yml
|
27
27
|
- lib/locales/ca.yml
|
28
|
+
- lib/locales/cs.yml
|
28
29
|
- lib/locales/da.yml
|
29
30
|
- lib/locales/de.yml
|
30
31
|
- lib/locales/en.yml
|
31
32
|
- lib/locales/es.yml
|
32
33
|
- lib/locales/fr.yml
|
34
|
+
- lib/locales/hr.yml
|
33
35
|
- lib/locales/id.yml
|
34
36
|
- lib/locales/it.yml
|
35
37
|
- lib/locales/ja.yml
|
@@ -41,8 +43,10 @@ files:
|
|
41
43
|
- lib/locales/pt-BR.yml
|
42
44
|
- lib/locales/pt.yml
|
43
45
|
- lib/locales/ru.yml
|
46
|
+
- lib/locales/sr.yml
|
44
47
|
- lib/locales/sv-SE.yml
|
45
48
|
- lib/locales/sv.yml
|
49
|
+
- lib/locales/sw.yml
|
46
50
|
- lib/locales/tr.yml
|
47
51
|
- lib/locales/utils/i18n.rb
|
48
52
|
- lib/locales/utils/loader.rb
|
@@ -91,7 +95,6 @@ files:
|
|
91
95
|
- lib/templates/uikit_nav.html.erb
|
92
96
|
- lib/templates/uikit_nav.html.haml
|
93
97
|
- lib/templates/uikit_nav.html.slim
|
94
|
-
- pagy.gemspec
|
95
98
|
homepage: https://github.com/ddnexus/pagy
|
96
99
|
licenses:
|
97
100
|
- MIT
|
@@ -105,13 +108,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
108
|
- - ">="
|
106
109
|
- !ruby/object:Gem::Version
|
107
110
|
version: '1.9'
|
111
|
+
- - "<"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '3.0'
|
108
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
115
|
requirements:
|
110
116
|
- - ">="
|
111
117
|
- !ruby/object:Gem::Version
|
112
118
|
version: '0'
|
113
119
|
requirements: []
|
114
|
-
rubygems_version: 3.1.
|
120
|
+
rubygems_version: 3.1.6
|
115
121
|
signing_key:
|
116
122
|
specification_version: 4
|
117
123
|
summary: The Ultimate Pagination Ruby Gem
|
data/lib/locales/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Pagy locales
|
2
|
-
|
3
|
-
### Please, submit your translation!
|
4
|
-
|
5
|
-
If you find that some translation could be improved, please, create an issue.
|
6
|
-
|
7
|
-
If you are using pagy with some language missing from the dictionary files, please, submit your translation!
|
8
|
-
|
9
|
-
You can create a Pull Request for your language, and get all the help you need to correctly complete it. Here is a check list.
|
10
|
-
|
11
|
-
### Check list for a new dictionary file:
|
12
|
-
|
13
|
-
- [ ] Find the pluralization rule for your language
|
14
|
-
|
15
|
-
- [ ] Find the locale file you need in the [list of pluralizations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/pluralization) and check the pluralization rule in it. For example it is `::RailsI18n::Pluralization::OneOther.with_locale(:en)` for `en.rb`. Note the rule part i.e. `OneOther`. In pagy that translates to the symbol `:one_other`.
|
16
|
-
|
17
|
-
- [ ] If the pluralization rule of your language is not the `:one_other` default, confirm that the [p11n.rb](https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb) file already defines the pluralization rule of your dictionary file:
|
18
|
-
|
19
|
-
- [ ] If the rule is not defined, you can either: a) Add the rule as a new rule/lambda entry in the `p11n` variable hash and relative tests or b) Just create an issue requesting the addition to the rule/lambda entry and tests.
|
20
|
-
|
21
|
-
- [ ] Add your language to the `plurals` hash in the file.
|
22
|
-
|
23
|
-
- [ ] add/edit the first line comment in the language rule in your dictionary file (e.g. `# :one_other pluralization ...`
|
24
|
-
|
25
|
-
- [ ] The mandatory pluralized entry in the dictionary file is the `item_name`. Please, provide all the plurals needed by your language. E.g. if your language uses the `:east_slavic` you should provide the plurals for `one`, `few`, `many` and `other`, if it uses `:one_other`, you should provide `one` and `other` plurals. If it uses `:other` you should only provide a single value. Look into other dictionary files to get some example. Ask if in doubt.
|
26
|
-
|
27
|
-
- [ ] The other entries in the dictionary file don't need any plural variant in most languages since the pluralization of the `item_name` in the sentence is enough. However, in some language, a whole sentence might need to be written in different ways for different counts. In that case you should add the different plurals for the sentence and the `count` will trigger the one that applies.
|
28
|
-
|
29
|
-
Feel free to ask for help in your Pull Request.
|
30
|
-
|
31
|
-
### Useful Links
|
32
|
-
|
33
|
-
* [Pagy I18n Documentation](https://ddnexus.github.io/pagy/api/frontend#i18n)
|
34
|
-
* [I18n Extra](https://ddnexus.github.io/pagy/extras/i18n)
|
35
|
-
|
data/pagy.gemspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'pagy'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'pagy'
|
7
|
-
s.version = Pagy::VERSION
|
8
|
-
s.authors = ['Domizio Demichelis']
|
9
|
-
s.email = ['dd.nexus@gmail.com']
|
10
|
-
s.summary = 'The Ultimate Pagination Ruby Gem'
|
11
|
-
s.description = 'Agnostic pagination in plain ruby: it works with any framework, ORM and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays, JSON data... Easy, powerful, fast and light.'
|
12
|
-
s.homepage = 'https://github.com/ddnexus/pagy'
|
13
|
-
s.license = 'MIT'
|
14
|
-
s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy.gemspec', 'LICENSE') }
|
15
|
-
s.required_ruby_version = '>= 1.9' # rubocop:disable Gemspec/RequiredRubyVersion
|
16
|
-
end
|