pagy 3.7.5 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1294620f428cf3807db1ab558bebf4bc01cc43d1e5d1fce668eec802b8a3088
4
- data.tar.gz: '094b895627f5bb472d952fbc8e078a23d9f830cc2f2b629945733853e83ef1ce'
3
+ metadata.gz: 76e3d9bead25964339d54c1cd73d9e907da2339e3f06b260f9cee31fa595deca
4
+ data.tar.gz: 6b4babd77239dee7f8d5bdc599fc621aeae42089fd7a2c0689010e1f5f8fafb4
5
5
  SHA512:
6
- metadata.gz: 1a041ca4fad15e46930d178ff9f86c20d66f60408d0ca270d127e615fca4ea29529a04e376905b45742405240b8d55438fbb4be4b60fe9c400171cce222eac64
7
- data.tar.gz: bd9f46987b98a2d83e8a03f3e16cf9f02272cbb9177d74e7a2b3e6eca30dcc20b1ed901d5d59a240a521decb0b359c9d5f5be21e10dbf1e970e67e5fc0499e21
6
+ metadata.gz: d52670d1b6b9e8145589ce948fbbc4332a946fbd955a3a2bdca3acbb591c33cb6e956e83a2a8b9c50545ccd80b709c4f0709296be6330e22031990cbd8e17116
7
+ data.tar.gz: 8e0c0a3ba6d655386de0a50a53e315c854a88319fdafa5792e94fd4f432be263eee420840f54bcbb206b505b26cbf850faa07db6eef66157f91391f5c43ff89f
@@ -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.7.5)
4
+ # Pagy initializer file (3.9.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.7.5';
5
+ Pagy.version = '3.9.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,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} ក្នុង ១ ទំព័រ"
@@ -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"
@@ -72,6 +72,7 @@ plurals = Hash.new(p11n[:one_other]).tap do |hash|
72
72
  hash['zh-CN'] = p11n[:other]
73
73
  hash['zh-HK'] = p11n[:other]
74
74
  hash['zh-TW'] = p11n[:other]
75
+ hash['km'] = p11n[:other]
75
76
  end
76
77
 
77
78
  [ plurals, p11n ]
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.7.5'
7
+ class Pagy ; VERSION = '3.9.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
@@ -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
@@ -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.7.5
4
+ version: 3.9.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-03-31 00:00:00.000000000 Z
11
+ date: 2020-10-21 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,
@@ -33,11 +33,13 @@ files:
33
33
  - lib/locales/id.yml
34
34
  - lib/locales/it.yml
35
35
  - lib/locales/ja.yml
36
+ - lib/locales/km.yml
36
37
  - lib/locales/ko.yml
37
38
  - lib/locales/nb.yml
38
39
  - lib/locales/nl.yml
39
40
  - lib/locales/pl.yml
40
41
  - lib/locales/pt-BR.yml
42
+ - lib/locales/pt.yml
41
43
  - lib/locales/ru.yml
42
44
  - lib/locales/sv-SE.yml
43
45
  - lib/locales/sv.yml
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  - !ruby/object:Gem::Version
110
112
  version: '0'
111
113
  requirements: []
112
- rubygems_version: 3.0.6
114
+ rubygems_version: 3.1.2
113
115
  signing_key:
114
116
  specification_version: 4
115
117
  summary: The Ultimate Pagination Ruby Gem