pagy 4.6.0 → 4.7.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: ef235bc480391503c4c4c9c0af67f8bf10f62aad86270fc0ae67e1bdd76a0044
4
- data.tar.gz: 18c74230a1e88d4875340b4bff63c181fb95998e63ebf83aac51016e5d16bb68
3
+ metadata.gz: eaccfe046308ce3c557a15667281d10a5ba7e9764a172d89327ae6a0bcdabf36
4
+ data.tar.gz: 1645173e3c7f86034890f86d3a043a46068df6018111d439dc5be3ca4a4b5799
5
5
  SHA512:
6
- metadata.gz: add32ab56092596d562d5e90abfeb87a4c66eb2e4c1f0d3b923e0ffc53c20b03a4edba020ebb8a15efd5e089a9d59b059d0bc4f6496c8836eaa5908e4bb2de68
7
- data.tar.gz: 268a59ed232635bcf2e41140380b2751bec2bb1ddba2a388ff095f5d8aceda6b455474f46cf069569a83f544c7c983358e9723bdd14c0160ae1b08ba3197be9b
6
+ metadata.gz: 243dd49c86053bf02eec713e8d78dbba391c3c0f8f62858a9e9924e3328dc0a44b6718fd3dfd95260ffd41c5c0b7d24256ad11f44f46eeff414dcfd6b95c566f
7
+ data.tar.gz: c112e2f1f94337bea11c0707014fd7d98f8623844aabfc5ccdc8c0b0ff09cb0c9466801e7cf052ca9dfcb63f5767f98cbafe0b240a98ec7ba10d6fdc0f3f0683
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (4.6.0)
3
+ # Pagy initializer file (4.7.0)
4
4
  # Customize only what you really need and notice that Pagy works also without any of the following lines.
5
5
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
6
6
 
@@ -2,18 +2,18 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '4.6.0'
5
+ Pagy.version = '4.7.0'
6
6
 
7
7
  Pagy.delay = 100
8
8
 
9
9
  Pagy.init =
10
10
  function(arg) {
11
11
  var target = arg instanceof Event || arg === undefined ? document : arg,
12
- jsonTags = target.getElementsByClassName('pagy-json')
13
- for (var i = 0, len = jsonTags.length; i < len; i++) {
14
- var args = JSON.parse(jsonTags[i].innerHTML),
12
+ elements = target.querySelectorAll('[data-pagy-json]')
13
+ for (var i = 0, len = elements.length; i < len; i++) {
14
+ var args = JSON.parse(elements[i].getAttribute('data-pagy-json')),
15
15
  fname = args.shift()
16
- args.unshift(jsonTags[i].previousSibling)
16
+ args.unshift(elements[i])
17
17
  Pagy[fname].apply(null, args)
18
18
  }
19
19
  }
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ uk:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "запис"
8
+ few: "записів"
9
+ many: "записів"
10
+ other: "записів"
11
+
12
+ nav:
13
+ prev: "&lsaquo;&nbsp;Назад"
14
+ next: "Далі&nbsp;&rsaquo;"
15
+ gap: "&hellip;"
16
+
17
+ info:
18
+ no_items: "Більше %{item_name} немає"
19
+ single_page: "<b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Загалом <b>%{count}</b> %{item_name}, показані з <b>%{from}</b> по <b>%{to}</b>"
21
+
22
+ combo_nav_js: "<label>Сторінка %{page_input}</label> з %{pages}"
23
+
24
+ items_selector_js: "<label>Показати %{items_input} %{item_name} на сторінці</label>"
@@ -85,6 +85,7 @@ plurals = Hash.new(p11n[:one_other]).tap do |hash|
85
85
  hash['sv'] = p11n[:one_two_other]
86
86
  hash['sv-SE'] = p11n[:one_two_other]
87
87
  hash['tr'] = p11n[:other]
88
+ hash['uk'] = p11n[:east_slavic]
88
89
  hash['zh-CN'] = p11n[:other]
89
90
  hash['zh-HK'] = p11n[:other]
90
91
  hash['zh-TW'] = p11n[:other]
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # main class
7
7
  class Pagy
8
- VERSION = '4.6.0'
8
+ VERSION = '4.7.0'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -35,8 +35,7 @@ class Pagy
35
35
  'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t 'pagy.nav.gap'}</a></li>),
36
36
  'after' => %(#{pagy_bootstrap_next_html pagy, link}</ul>) }
37
37
 
38
- html = %(<nav#{p_id} class="pagy-njs pagy-bootstrap-nav-js" aria-label="pager"></nav>)
39
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
38
+ %(<nav#{p_id} class="pagy-njs pagy-bootstrap-nav-js" aria-label="pager" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></nav>)
40
39
  end
41
40
 
42
41
  # Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -48,7 +47,9 @@ class Pagy
48
47
  p_pages = pagy.pages
49
48
  input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" class="text-primary" style="padding: 0; border: none; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
50
49
 
51
- %(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" aria-label="pager"><div class="btn-group" role="group">#{
50
+ %(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" aria-label="pager"><div class="btn-group" role="group" #{
51
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
52
+ }>#{
52
53
  if (p_prev = pagy.prev)
53
54
  link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous" class="prev btn btn-primary"'
54
55
  else
@@ -60,9 +61,7 @@ class Pagy
60
61
  else
61
62
  %(<a class="next btn btn-primary disabled" href="#">#{pagy_t 'pagy.nav.next' }</a>)
62
63
  end
63
- }</div></nav>#{
64
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
65
- })
64
+ }</div></nav>)
66
65
  end
67
66
 
68
67
  private
@@ -34,8 +34,7 @@ class Pagy
34
34
  'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.nav.gap' }</span></li>),
35
35
  'after' => '</ul>' }
36
36
 
37
- html = %(<nav#{p_id} class="pagy-njs pagy-bulma-nav-js pagination is-centered" aria-label="pagination"></nav>)
38
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
37
+ %(<nav#{p_id} class="pagy-njs pagy-bulma-nav-js pagination is-centered" aria-label="pagination" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></nav>)
39
38
  end
40
39
 
41
40
  # Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -47,7 +46,9 @@ class Pagy
47
46
  p_pages = pagy.pages
48
47
  input = %(<input class="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; margin:0 0.3rem;">)
49
48
 
50
- %(<nav#{p_id} class="pagy-bulma-combo-nav-js" aria-label="pagination"><div class="field is-grouped is-grouped-centered" role="group">#{
49
+ %(<nav#{p_id} class="pagy-bulma-combo-nav-js" aria-label="pagination"><div class="field is-grouped is-grouped-centered" role="group" #{
50
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
51
+ }>#{
51
52
  if (p_prev = pagy.prev)
52
53
  %(<p class="control">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'class="button" aria-label="previous page"'}</p>)
53
54
  else
@@ -59,9 +60,7 @@ class Pagy
59
60
  else
60
61
  %(<p class="control"><a class="button" disabled>#{pagy_t 'pagy.nav.next'}</a></p>)
61
62
  end
62
- }</div></nav>#{
63
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
64
- })
63
+ }</div></nav>)
65
64
  end
66
65
 
67
66
  private
@@ -35,8 +35,7 @@ class Pagy
35
35
  'gap' => %(<li class="ellipsis gap" aria-hidden="true"></li>),
36
36
  'after' => %(#{pagy_foundation_next_html pagy, link}</ul>) }
37
37
 
38
- html = %(<nav#{p_id} class="pagy-njs pagy-foundation-nav-js" aria-label="Pagination"></nav>)
39
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
38
+ %(<nav#{p_id} class="pagy-njs pagy-foundation-nav-js" aria-label="Pagination" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></nav>)
40
39
  end
41
40
 
42
41
  # Javascript combo pagination for Foundation: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -48,7 +47,9 @@ class Pagy
48
47
  p_pages = pagy.pages
49
48
  input = %(<input class="input-group-field cell shrink" type="number" min="1" max="#{p_pages}" value="#{p_page}" style="width: #{p_pages.to_s.length+1}rem; padding: 0 0.3rem; margin: 0 0.3rem;">)
50
49
 
51
- %(<nav#{p_id} class="pagy-foundation-combo-nav-js" aria-label="Pagination"><div class="input-group">#{
50
+ %(<nav#{p_id} class="pagy-foundation-combo-nav-js" aria-label="Pagination"><div class="input-group" #{
51
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
52
+ }>#{
52
53
  if (p_prev = pagy.prev)
53
54
  link.call p_prev, pagy_t('pagy.nav.prev'), 'style="margin-bottom: 0" aria-label="previous" class="prev button primary"'
54
55
  else
@@ -60,9 +61,7 @@ class Pagy
60
61
  else
61
62
  %(<a style="margin-bottom: 0" class="next button primary disabled" href="#">#{pagy_t 'pagy.nav.next'}</a>)
62
63
  end
63
- }</div></nav>#{
64
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
65
- })
64
+ }</div></nav>)
66
65
  end
67
66
 
68
67
  private
@@ -40,12 +40,12 @@ class Pagy
40
40
  link = pagy_marked_link(pagy_link_proc(pagy, link_extra: link_extra))
41
41
  p_vars[:items] = p_items # restore the items
42
42
 
43
- html = %(<span#{p_id} class="pagy-items-selector-js">)
43
+ html = %(<span#{p_id} class="pagy-items-selector-js" #{pagy_json_attr pagy, :items_selector, pagy.from, link}>)
44
44
  input = %(<input type="number" min="1" max="#{p_vars[:max_items]}" value="#{p_items}" style="padding: 0; text-align: center; width: #{p_items.to_s.length+1}rem;">)
45
45
  html << pagy_t('pagy.items_selector_js', item_name: item_name || pagy_t(i18n_key || p_vars[:i18n_key], count: p_items),
46
46
  items_input: input,
47
47
  count: p_items)
48
- html << %(</span>#{pagy_json_tag pagy, :items_selector, pagy.from, link})
48
+ html << %(</span>)
49
49
  end
50
50
 
51
51
  end
@@ -36,8 +36,7 @@ class Pagy
36
36
  'gap' => %(<li class="gap disabled"><a href="#">#{pagy_t 'pagy.nav.gap'}</a></li>),
37
37
  'after' => %(#{pagy_materialize_next_html pagy, link}</ul>) }
38
38
 
39
- html = %(<div#{p_id} class="pagy-njs pagy-materialize-nav-js" role="navigation" aria-label="pager"></div>)
40
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
39
+ %(<div#{p_id} class="pagy-njs pagy-materialize-nav-js" role="navigation" aria-label="pager" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></div>)
41
40
  end
42
41
 
43
42
  # Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -50,15 +49,15 @@ class Pagy
50
49
  style = ' style="vertical-align: middle;"'
51
50
  input = %(<input type="number" class="browser-default" min="1" max="#{p_pages}" value="#{p_page}" style="padding: 2px; border: none; border-radius: 2px; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
52
51
 
53
- %(<div#{p_id} class="pagy-materialize-combo-nav-js pagination" role="navigation" aria-label="pager"><div class="pagy-compact-chip" role="group" style="height: 35px; border-radius: 18px; background: #e4e4e4; display: inline-block;"><ul class="pagination" style="margin: 0">#{
52
+ %(<div#{p_id} class="pagy-materialize-combo-nav-js pagination" role="navigation" aria-label="pager"><div class="pagy-compact-chip" role="group" style="height: 35px; border-radius: 18px; background: #e4e4e4; display: inline-block;"><ul class="pagination" style="margin: 0" #{
53
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
54
+ }>#{
54
55
  pagy_materialize_prev_html pagy, link, style
55
56
  }<div class="pagy-combo-input btn-flat" style="cursor: default; padding: 0px">#{
56
57
  pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
57
58
  }</div>#{
58
59
  pagy_materialize_next_html pagy, link, style
59
- }</ul></div>#{
60
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
61
- })
60
+ }</ul></div>)
62
61
  end
63
62
 
64
63
  private
@@ -17,8 +17,7 @@ class Pagy
17
17
  'gap' => %(<span class="page gap">#{pagy_t 'pagy.nav.gap'}</span> ),
18
18
  'after' => pagy_nav_next_html(pagy, link) }
19
19
 
20
- html = %(<nav#{p_id} class="pagy-njs pagy-nav-js pagination" aria-label="pager"></nav>)
21
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
20
+ %(<nav#{p_id} class="pagy-njs pagy-nav-js pagination" aria-label="pager" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></nav>)
22
21
  end
23
22
 
24
23
  # Javascript combo pagination: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -30,15 +29,15 @@ class Pagy
30
29
  p_pages = pagy.pages
31
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;">)
32
31
 
33
- %(<nav#{p_id} class="pagy-combo-nav-js pagination" aria-label="pager">#{
32
+ %(<nav#{p_id} class="pagy-combo-nav-js pagination" aria-label="pager" #{
33
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
34
+ }>#{
34
35
  pagy_nav_prev_html pagy, link
35
36
  }<span class="pagy-combo-input" style="margin: 0 0.6rem;">#{
36
37
  pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
37
38
  }</span> #{
38
39
  pagy_nav_next_html pagy, link
39
- }</nav>#{
40
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
41
- })
40
+ }</nav>)
42
41
  end
43
42
 
44
43
  private
@@ -35,8 +35,7 @@ class Pagy
35
35
  'gap' => %(<div class="disabled item">#{pagy_t('pagy.nav.gap')}</div>),
36
36
  'after' => pagy_semantic_next_html(pagy, link) }
37
37
 
38
- html = %(<div#{p_id} class="pagy-njs pagy-semantic-nav-js ui pagination menu" role="navigation"></div>)
39
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
38
+ %(<div#{p_id} class="pagy-njs pagy-semantic-nav-js ui pagination menu" role="navigation" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></div>)
40
39
  end
41
40
 
42
41
  # Combo pagination for semantic: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -48,15 +47,15 @@ class Pagy
48
47
  p_pages = pagy.pages
49
48
  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; margin: 0 0.3rem">)
50
49
 
51
- %(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation">#{
50
+ %(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" #{
51
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
52
+ }>#{
52
53
  pagy_semantic_prev_html pagy, link
53
54
  }<div class="pagy-combo-input item">#{
54
55
  pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
55
56
  }</div> #{
56
57
  pagy_semantic_next_html pagy, link
57
- }</div>#{
58
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
59
- })
58
+ }</div>)
60
59
  end
61
60
 
62
61
  private
@@ -29,16 +29,16 @@ class Pagy
29
29
 
30
30
  if defined?(Oj)
31
31
  # it returns a script tag with the JSON-serialized args generated with the faster oj gem
32
- def pagy_json_tag(pagy, *args)
32
+ def pagy_json_attr(pagy, *args)
33
33
  args << pagy.vars[:page_param] if pagy.vars[:enable_trim_extra]
34
- %(<script type="application/json" class="pagy-json">#{Oj.dump(args, mode: :strict)}</script>)
34
+ %(data-pagy-json="#{Oj.dump(args, mode: :strict).gsub('"', '&quot;')}")
35
35
  end
36
36
  else
37
37
  require 'json'
38
38
  # it returns a script tag with the JSON-serialized args generated with the slower to_json
39
- def pagy_json_tag(pagy, *args)
39
+ def pagy_json_attr(pagy, *args)
40
40
  args << pagy.vars[:page_param] if pagy.vars[:enable_trim_extra]
41
- %(<script type="application/json" class="pagy-json">#{args.to_json}</script>)
41
+ %(data-pagy-json="#{args.to_json.gsub('"', '&quot;')}")
42
42
  end
43
43
  end
44
44
 
@@ -34,8 +34,7 @@ class Pagy
34
34
  'gap' => %(<li class="uk-disabled"><span>#{pagy_t 'pagy.nav.gap'}</span></li>),
35
35
  'after' => pagy_uikit_next_html(pagy, link) }
36
36
 
37
- html = %(<ul#{p_id} class="pagy-njs pagy-uikit-nav-js uk-pagination uk-flex-center"></ul>)
38
- html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
37
+ %(<ul#{p_id} class="pagy-njs pagy-uikit-nav-js uk-pagination uk-flex-center" #{pagy_json_attr(pagy, :nav, tags, pagy.sequels(steps))}></ul>)
39
38
  end
40
39
 
41
40
  # Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
@@ -47,7 +46,9 @@ class Pagy
47
46
  p_pages = pagy.pages
48
47
  input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" class="uk-input" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
49
48
 
50
- %(<div#{p_id} class="pagy-uikit-combo-nav-js uk-button-group">#{
49
+ %(<div#{p_id} class="pagy-uikit-combo-nav-js uk-button-group" #{
50
+ pagy_json_attr pagy, :combo_nav, p_page, pagy_marked_link(link)
51
+ }>#{
51
52
  if (p_prev = pagy.prev)
52
53
  link.call p_prev, pagy_t('pagy.nav.prev'), 'class="uk-button uk-button-default"'
53
54
  else
@@ -61,9 +62,7 @@ class Pagy
61
62
  else
62
63
  %(<button class="uk-button uk-button-default" disabled>#{pagy_t 'pagy.nav.next'}</button>)
63
64
  end
64
- }</div>#{
65
- pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
66
- })
65
+ }</div>)
67
66
  end
68
67
 
69
68
 
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: 4.6.0
4
+ version: 4.7.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: 2021-05-09 00:00:00.000000000 Z
11
+ date: 2021-05-12 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,
@@ -48,6 +48,7 @@ files:
48
48
  - lib/locales/sv.yml
49
49
  - lib/locales/sw.yml
50
50
  - lib/locales/tr.yml
51
+ - lib/locales/uk.yml
51
52
  - lib/locales/utils/i18n.rb
52
53
  - lib/locales/utils/loader.rb
53
54
  - lib/locales/utils/p11n.rb