pagy 3.7.4 → 3.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +2 -2
- data/lib/locales/README.md +9 -2
- data/lib/locales/da.yml +22 -0
- data/lib/locales/km.yml +19 -0
- data/lib/locales/pt.yml +22 -0
- data/lib/locales/utils/p11n.rb +1 -0
- data/lib/pagy.rb +1 -1
- data/lib/pagy/extras/elasticsearch_rails.rb +2 -2
- data/lib/pagy/extras/i18n.rb +8 -1
- data/lib/pagy/extras/navs.rb +1 -1
- data/lib/pagy/extras/support.rb +1 -1
- data/lib/pagy/frontend.rb +2 -2
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5914b35c8067b8d14845b7d9436f7ca4790175d177eef5762f69e436add1f3c
|
4
|
+
data.tar.gz: e3215ee3eea2b59db1af94ff525e7b1643ba64c55564c7e19971b54f5a2c05b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ce505f853364f27a64088497d70b0c4a4c4621cb060d719200e76a5f623bcfc4c182b9b716a2ba6005670caf512e717dcf51be13cb181b7b112b2cfc4e95b6
|
7
|
+
data.tar.gz: 2401ef28c166a69a83567d5fa4f92587be93d2ded49f8261d582acb4df62dff41f5a7773da48a37d26faedf50f7f6da39585beac0fd22fc9ee5419e32c8d1a99
|
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.8.3)
|
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
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
function Pagy(){}
|
4
4
|
|
5
|
-
Pagy.version = '3.
|
5
|
+
Pagy.version = '3.8.3';
|
6
6
|
|
7
7
|
Pagy.init = function(arg){
|
8
8
|
var target = arg instanceof Event || arg === undefined ? document : arg,
|
@@ -101,6 +101,6 @@ Pagy.addInputEventListeners = function(input, handler){
|
|
101
101
|
};
|
102
102
|
|
103
103
|
Pagy.trim = function(html, param){
|
104
|
-
var re = new RegExp('[?&]' + param + '=1
|
104
|
+
var re = new RegExp('[?&]' + param + '=1\\b(?!&)|\\b' + param + '=1&');
|
105
105
|
return html.replace(re, '');
|
106
106
|
};
|
data/lib/locales/README.md
CHANGED
@@ -11,13 +11,20 @@ You can create a Pull Request for your language, and get all the help you need t
|
|
11
11
|
### Check list for a new dictionary file:
|
12
12
|
|
13
13
|
- [ ] Find the pluralization rule for your language
|
14
|
-
|
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.
|
15
22
|
|
16
23
|
- [ ] add/edit the first line comment in the language rule in your dictionary file (e.g. `# :one_other pluralization ...`
|
17
24
|
|
18
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.
|
19
26
|
|
20
|
-
- [ ] 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,
|
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.
|
21
28
|
|
22
29
|
Feel free to ask for help in your Pull Request.
|
23
30
|
|
data/lib/locales/da.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
da:
|
4
|
+
pagy:
|
5
|
+
|
6
|
+
item_name:
|
7
|
+
one: "resultat"
|
8
|
+
other: "resultater"
|
9
|
+
|
10
|
+
nav:
|
11
|
+
prev: "‹ Forrige"
|
12
|
+
next: "Næste ›"
|
13
|
+
gap: "…"
|
14
|
+
|
15
|
+
info:
|
16
|
+
no_items: "Ingen %{item_name} fundet"
|
17
|
+
single_page: "Viser <b>%{count}</b> %{item_name}"
|
18
|
+
multiple_pages: "Viser %{item_name} <b>%{from}-%{to}</b> til <b>%{count}</b> totalt"
|
19
|
+
|
20
|
+
combo_nav_js: "Side %{page_input} of %{pages}"
|
21
|
+
|
22
|
+
items_selector_js: "Antal %{items_input} %{item_name} per side"
|
data/lib/locales/km.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# :other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
km:
|
4
|
+
pagy:
|
5
|
+
item_name: "ធាតុ"
|
6
|
+
|
7
|
+
nav:
|
8
|
+
prev: "‹ មុន"
|
9
|
+
next: "បន្ទាប់ ›"
|
10
|
+
gap: "…"
|
11
|
+
|
12
|
+
info:
|
13
|
+
no_items: "មិនមាន %{item_name} ទេ"
|
14
|
+
single_page: "បង្ហាញ <b>%{count}</b> %{item_name}"
|
15
|
+
multiple_pages: "បង្ហាញ %{item_name} <b>%{from}-%{to}</b> នៃ <b>%{count}</b> ជាចំនួនសរុប"
|
16
|
+
|
17
|
+
combo_nav_js: "ទំព័រ %{page_input} នៃ %{pages}"
|
18
|
+
|
19
|
+
items_selector_js: "បង្ហាញ %{items_input} %{item_name} ក្នុង ១ ទំព័រ"
|
data/lib/locales/pt.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
|
2
|
+
|
3
|
+
pt:
|
4
|
+
pagy:
|
5
|
+
|
6
|
+
item_name:
|
7
|
+
one: "item"
|
8
|
+
other: "itens"
|
9
|
+
|
10
|
+
nav:
|
11
|
+
prev: "‹ Anterior"
|
12
|
+
next: "Próximo ›"
|
13
|
+
gap: "…"
|
14
|
+
|
15
|
+
info:
|
16
|
+
no_items: "Sem resultados"
|
17
|
+
single_page: "Mostrando %{count} %{item_name}"
|
18
|
+
multiple_pages: "Mostrando %{item_name} %{from}-%{to} de um total de %{count}"
|
19
|
+
|
20
|
+
combo_nav_js: "Página %{page_input} de %{pages}"
|
21
|
+
|
22
|
+
items_selector_js: "Mostrar %{items_input} %{item_name} por página"
|
data/lib/locales/utils/p11n.rb
CHANGED
data/lib/pagy.rb
CHANGED
@@ -13,7 +13,7 @@ class Pagy
|
|
13
13
|
def self.new_from_elasticsearch_rails(response, vars={})
|
14
14
|
vars[:items] = response.search.options[:size] || 10
|
15
15
|
vars[:page] = (response.search.options[:from] || 0) / vars[:items] + 1
|
16
|
-
total = response.raw_response['hits']['total']
|
16
|
+
total = response.respond_to?(:raw_response) ? response.raw_response['hits']['total'] : response.response['hits']['total']
|
17
17
|
vars[:count] = total.is_a?(Hash) ? total['value'] : total
|
18
18
|
new(vars)
|
19
19
|
end
|
@@ -28,7 +28,7 @@ class Pagy
|
|
28
28
|
search_args[-1][:size] = vars[:items]
|
29
29
|
search_args[-1][:from] = vars[:items] * (vars[:page] - 1)
|
30
30
|
response = model.search(*search_args)
|
31
|
-
total = response.raw_response['hits']['total']
|
31
|
+
total = response.respond_to?(:raw_response) ? response.raw_response['hits']['total'] : response.response['hits']['total']
|
32
32
|
vars[:count] = total.is_a?(Hash) ? total['value'] : total
|
33
33
|
pagy = Pagy.new(vars)
|
34
34
|
# with :last_page overflow we need to re-run the method in order to get the hits
|
data/lib/pagy/extras/i18n.rb
CHANGED
@@ -11,7 +11,14 @@ class Pagy
|
|
11
11
|
Pagy::I18n.clear.instance_eval { undef :load; undef :t } # unload the pagy default constant for efficiency
|
12
12
|
|
13
13
|
alias_method :pagy_without_i18n, :pagy_t
|
14
|
-
|
14
|
+
if Gem::Version.new(::I18n::VERSION) < Gem::Version.new('1.6.0')
|
15
|
+
def pagy_t_with_i18n(*args) ::I18n.t(*args) end
|
16
|
+
else
|
17
|
+
# keep 1.9 compatibility by hiding 2.0+ syntax in string
|
18
|
+
module_eval <<-RUBY
|
19
|
+
def pagy_t_with_i18n(key, **opts) ::I18n.t(key, **opts) end
|
20
|
+
RUBY
|
21
|
+
end
|
15
22
|
alias_method :pagy_t, :pagy_t_with_i18n
|
16
23
|
|
17
24
|
end
|
data/lib/pagy/extras/navs.rb
CHANGED
@@ -24,7 +24,7 @@ class Pagy
|
|
24
24
|
def pagy_combo_nav_js(pagy, id=pagy_id)
|
25
25
|
link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
|
26
26
|
|
27
|
-
html = EMPTY + %(<nav id="#{id}" class="pagy-combo-nav-js
|
27
|
+
html = EMPTY + %(<nav id="#{id}" class="pagy-combo-nav-js pagination" role="navigation" aria-label="pager">)
|
28
28
|
html << (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
|
29
29
|
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
|
30
30
|
input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
|
data/lib/pagy/extras/support.rb
CHANGED
@@ -15,7 +15,7 @@ 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="#{pagy_prev_url(pagy)}" rel="
|
18
|
+
pagy.prev ? %(<span class="page prev"><a href="#{pagy_prev_url(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
|
|
data/lib/pagy/frontend.rb
CHANGED
@@ -50,11 +50,11 @@ class Pagy
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# Return examples: "Displaying items 41-60 of 324 in total" of "Displaying Products 41-60 of 324 in total"
|
53
|
-
def pagy_info(pagy)
|
53
|
+
def pagy_info(pagy, item_name=nil)
|
54
54
|
path = if (count = pagy.count) == 0 ; 'pagy.info.no_items'
|
55
55
|
else pagy.pages == 1 ? 'pagy.info.single_page' : 'pagy.info.multiple_pages'
|
56
56
|
end
|
57
|
-
pagy_t(path, item_name: pagy_t(pagy.vars[:i18n_key], count: count), count: count, from: pagy.from, to: pagy.to)
|
57
|
+
pagy_t(path, item_name: item_name || pagy_t(pagy.vars[:i18n_key], count: count), count: count, from: pagy.from, to: pagy.to)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Returns a performance optimized proc to generate the HTML links
|
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.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-23 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,
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/locales/README.md
|
26
26
|
- lib/locales/bg.yml
|
27
27
|
- lib/locales/ca.yml
|
28
|
+
- lib/locales/da.yml
|
28
29
|
- lib/locales/de.yml
|
29
30
|
- lib/locales/en.yml
|
30
31
|
- lib/locales/es.yml
|
@@ -32,11 +33,13 @@ files:
|
|
32
33
|
- lib/locales/id.yml
|
33
34
|
- lib/locales/it.yml
|
34
35
|
- lib/locales/ja.yml
|
36
|
+
- lib/locales/km.yml
|
35
37
|
- lib/locales/ko.yml
|
36
38
|
- lib/locales/nb.yml
|
37
39
|
- lib/locales/nl.yml
|
38
40
|
- lib/locales/pl.yml
|
39
41
|
- lib/locales/pt-BR.yml
|
42
|
+
- lib/locales/pt.yml
|
40
43
|
- lib/locales/ru.yml
|
41
44
|
- lib/locales/sv-SE.yml
|
42
45
|
- lib/locales/sv.yml
|
@@ -108,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
111
|
- !ruby/object:Gem::Version
|
109
112
|
version: '0'
|
110
113
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.1.2
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
117
|
summary: The Ultimate Pagination Ruby Gem
|