pagy 3.8.0 → 3.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a3ba0f375dbf0278f8701c8cd68b628c207543556da9779c195a441c8c92896
4
- data.tar.gz: 40656e0eaeb6b8bfe45126100242e6b89edd588e6723b98c1a120787e2ff77cb
3
+ metadata.gz: 9ce66549213b7c1a7f89755a31d5faec46f09372f5b854d7f7ede99fb329b5d0
4
+ data.tar.gz: 35071f34f9a15378e91efb38f060e1178ccc2d7609ff2bdc99b435f8f9242417
5
5
  SHA512:
6
- metadata.gz: d2e5fe320e18656b1c9e7fb0d36597ee6a4ad8fcb55579b269ea8f394b390975e7f7e1138484b158ee5099bccfa6ee16e6c780513c68866d0b08367aa77c8919
7
- data.tar.gz: 5b3c2c1deeb0f4131044e8b5830394080c31e5ddd49cb6c07e9124da5a14d5d15dfcf9c69e34775b7f9249193e6d6064c52316ce7703e9b53319b3c235b08adc
6
+ metadata.gz: d0a3520386cf1b796c5e26fe13c65ebc158d6fccbb24547a37bfcd5ef39ede686e1d3cb771c6ce23303d83529a075d03fc5e0288704b26bd0be17e0e641f1553
7
+ data.tar.gz: 7ef28712f3e38fc05fbbebb5445d25d7f0ec97d61bebbd0c1a45830345c4bd5ba1be202b5a7417bc23d8f822d85408cd0051d1d3de22d66e6c6ee10c49caedbd
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2019 Domizio Demichelis
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
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Pagy initializer file (3.8.0)
4
+ # Pagy initializer file (3.10.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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '3.8.0';
5
+ Pagy.version = '3.10.0';
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\b(?!&)|\b' + param + '=1&');
104
+ var re = new RegExp('[?&]' + param + '=1\\b(?!&)|\\b' + param + '=1&');
105
105
  return html.replace(re, '');
106
106
  };
@@ -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"
@@ -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: "&lsaquo;&nbsp;Anterior"
12
+ next: "Próximo&nbsp;&rsaquo;"
13
+ gap: "&hellip;"
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"
@@ -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,9 +67,11 @@ 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['cs'] = p11n[:west_slavic]
63
71
  hash['id'] = p11n[:other]
64
72
  hash['fr'] = p11n[:one_upto_two_other]
65
73
  hash['ja'] = p11n[:other]
74
+ hash['km'] = p11n[:other]
66
75
  hash['ko'] = p11n[:other]
67
76
  hash['pl'] = p11n[:polish]
68
77
  hash['ru'] = p11n[:east_slavic]
@@ -72,7 +81,6 @@ plurals = Hash.new(p11n[:one_other]).tap do |hash|
72
81
  hash['zh-CN'] = p11n[:other]
73
82
  hash['zh-HK'] = p11n[:other]
74
83
  hash['zh-TW'] = p11n[:other]
75
- hash['km'] = p11n[:other]
76
84
  end
77
85
 
78
86
  [ plurals, p11n ]
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.8.0'
7
+ class Pagy ; VERSION = '3.10.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
@@ -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
@@ -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
- def pagy_t_with_i18n(*args) ::I18n.t(*args) end
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
@@ -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-js pagination" role="navigation" aria-label="pager">)
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;">)
@@ -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="#{pagy_prev_url(pagy)}" rel="next" aria-label="next" #{pagy.vars[:link_extra]} #{link_extra}>#{text}</a></span>)
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="#{pagy_next_url(pagy)}" rel="next" aria-label="next" #{pagy.vars[:link_extra]} #{link_extra}>#{text}</a></span>)
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
@@ -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
@@ -68,6 +68,7 @@ class Pagy
68
68
  end
69
69
 
70
70
  # Similar to I18n.t: just ~18x faster using ~10x less memory
71
+ # (@pagy_locale explicitly initilized in order to avoid warning)
71
72
  def pagy_t(path, vars={}) Pagy::I18n.t(@pagy_locale||=nil, path, vars) end
72
73
 
73
74
  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: 3.8.0
4
+ version: 3.10.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: 2020-04-23 00:00:00.000000000 Z
11
+ date: 2020-11-25 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/cs.yml
28
29
  - lib/locales/da.yml
29
30
  - lib/locales/de.yml
30
31
  - lib/locales/en.yml
@@ -39,6 +40,7 @@ files:
39
40
  - lib/locales/nl.yml
40
41
  - lib/locales/pl.yml
41
42
  - lib/locales/pt-BR.yml
43
+ - lib/locales/pt.yml
42
44
  - lib/locales/ru.yml
43
45
  - lib/locales/sv-SE.yml
44
46
  - lib/locales/sv.yml
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
114
  requirements: []
113
- rubygems_version: 3.0.6
115
+ rubygems_version: 3.1.2
114
116
  signing_key:
115
117
  specification_version: 4
116
118
  summary: The Ultimate Pagination Ruby Gem