pagy 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/locales/pagy.yml +3 -0
- data/lib/pagy.rb +16 -17
- data/lib/pagy/frontend.rb +10 -28
- data/lib/templates/nav.html.erb +1 -1
- data/lib/templates/nav.html.haml +1 -1
- data/lib/templates/nav.html.slim +1 -1
- data/pagy.gemspec +1 -1
- metadata +2 -10
- data/README.md +0 -93
- data/images/efficiency-table.png +0 -0
- data/images/ips-chart.png +0 -0
- data/images/memory-chart.png +0 -0
- data/images/objects-chart.png +0 -0
- data/lib/templates/nav_bootstrap.html.erb +0 -24
- data/lib/templates/nav_bootstrap.html.haml +0 -34
- data/lib/templates/nav_bootstrap.html.slim +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1f0144a6fd3d7656796cc0811c275402fa66db024bd9dfd08a2f76853b33b3d
|
4
|
+
data.tar.gz: '09ea67fbafb73195fd9efe1470860884f317800c455a40150ce533b2b1a74574'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ce6bb16a1ac0cb961cdbabcdf41065fdecdbccc4d6293b18fd345e34ffba60fd40a1855f4e77036420c46be848d6c4ae614a351418549854cefc51fab63ee7
|
7
|
+
data.tar.gz: 56f0b36c864d625775bf39ed574ea1996d1bb608a918ba57ef46082b8ae10fc927588fda1955e8b129a68fd97089a32ff3f47ce1abce202a7f037d6710a0b300
|
data/lib/locales/pagy.yml
CHANGED
data/lib/pagy.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
-
class Pagy ; VERSION = '0.
|
5
|
+
class Pagy ; VERSION = '0.6.0'
|
6
6
|
|
7
7
|
autoload :Backend, 'pagy/backend'
|
8
8
|
autoload :Frontend, 'pagy/frontend'
|
@@ -13,7 +13,7 @@ class Pagy ; VERSION = '0.5.0'
|
|
13
13
|
def self.root; Pathname.new(__FILE__).dirname end
|
14
14
|
|
15
15
|
# default core vars
|
16
|
-
VARS = { items:20, outset:0,
|
16
|
+
VARS = { items:20, outset:0, size:[1,4,4,1] }
|
17
17
|
|
18
18
|
# default I18n vars
|
19
19
|
I18N = { file: Pagy.root.join('locales', 'pagy.yml').to_s, plurals: -> (c) {c==0 && 'zero' || c==1 && 'one' || 'other'} }
|
@@ -23,11 +23,11 @@ class Pagy ; VERSION = '0.5.0'
|
|
23
23
|
|
24
24
|
# merge and validate the options, do some simple aritmetic and set the instance variables
|
25
25
|
def initialize(vars)
|
26
|
-
@vars
|
26
|
+
@vars = VARS.merge(vars) # default vars + instance vars
|
27
27
|
@vars[:page] = (@vars[:page]||1).to_i # set page to 1 if nil
|
28
|
-
{count:0, items:1, outset:0,
|
28
|
+
{ count:0, items:1, outset:0, page:1 }.each do |k,min| # validate core variables
|
29
29
|
@vars[k] >= min rescue nil || raise(ArgumentError, "expected :#{k} >= #{min}; got #{@vars[k].inspect}")
|
30
|
-
instance_variable_set(:"@#{k}", @vars.delete(k)) # set
|
30
|
+
instance_variable_set(:"@#{k}", @vars.delete(k)) # set instance variables
|
31
31
|
end
|
32
32
|
@pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
|
33
33
|
(1..@last).cover?(@page) || raise(OutOfRangeError, "expected :page in 1..#{@last}; got #{@page.inspect}")
|
@@ -40,18 +40,17 @@ class Pagy ; VERSION = '0.5.0'
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
43
|
-
def series
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
end
|
43
|
+
def series(size=@vars[:size])
|
44
|
+
(0..3).each{|i| size[i]>=0 rescue nil || raise(ArgumentError, "expected 4 items in :size >= 0; got #{size.inspect}")}
|
45
|
+
series = []
|
46
|
+
[*0..size[0], *@page-size[1]..@page+size[2], *@last-size[3]+1..@last+1].sort!.each_cons(2) do |a, b|
|
47
|
+
if a<0 || a==b || a>@last # skip out of range and duplicates
|
48
|
+
elsif a+1 == b; series.push(a) # no gap -> no additions
|
49
|
+
elsif a+2 == b; series.push(a, a+1) # 1 page gap -> fill with missing page
|
50
|
+
else series.push(a, :gap) # n page gap -> add :gap
|
51
|
+
end # skip the end boundary (last+1)
|
52
|
+
end # shift the start boundary (0) and
|
53
|
+
series.tap{|s| s.shift; s[s.index(@page)] = @page.to_s} # convert the current page to String
|
55
54
|
end
|
56
55
|
|
57
56
|
end
|
data/lib/pagy/frontend.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# See Pagy::Frontend API documentation: https://ddnexus.github.io/pagy/api/frontend
|
2
2
|
|
3
|
-
# this file will get autoloaded, so environment constants like ::I18n will be already set
|
4
|
-
require 'yaml'
|
5
3
|
class Pagy
|
6
4
|
|
7
5
|
# All the code here has been optimized for performance: it may not look very pretty
|
@@ -10,37 +8,19 @@ class Pagy
|
|
10
8
|
|
11
9
|
# Generic pagination: it returns the html with the series of links to the pages
|
12
10
|
def pagy_nav(pagy)
|
13
|
-
tags =
|
11
|
+
tags = ''; link = pagy_link_proc(pagy)
|
14
12
|
|
15
|
-
tags << (pagy.prev ? %(<span class="page prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), 'aria-label="previous"'.freeze}</span>)
|
16
|
-
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev'.freeze)}</span>))
|
13
|
+
tags << (pagy.prev ? %(<span class="page prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), 'aria-label="previous"'.freeze}</span> )
|
14
|
+
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev'.freeze)}</span> ))
|
17
15
|
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
18
|
-
tags << if item.is_a?(Integer); %(<span class="page">#{link.call item}</span>) # page link
|
19
|
-
elsif item.is_a?(String) ; %(<span class="page active">#{item}</span>) # current page
|
20
|
-
elsif item == :gap ; %(<span class="page gap">#{pagy_t('pagy.nav.gap'.freeze)}</span>) # page gap
|
16
|
+
tags << if item.is_a?(Integer); %(<span class="page">#{link.call item}</span> ) # page link
|
17
|
+
elsif item.is_a?(String) ; %(<span class="page active">#{item}</span> ) # current page
|
18
|
+
elsif item == :gap ; %(<span class="page gap">#{pagy_t('pagy.nav.gap'.freeze)}</span> ) # page gap
|
21
19
|
end
|
22
20
|
end
|
23
21
|
tags << (pagy.next ? %(<span class="page next">#{link.call pagy.next, pagy_t('pagy.nav.next'.freeze), 'aria-label="next"'.freeze}</span>)
|
24
22
|
: %(<span class="page next disabled">#{pagy_t('pagy.nav.next'.freeze)}</span>))
|
25
|
-
%(<nav class="pagination" role="navigation" aria-label="pager">#{tags
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
# Pagination for bootstrap: it returns the html with the series of links to the pages
|
30
|
-
def pagy_nav_bootstrap(pagy)
|
31
|
-
tags = []; link = pagy_link_proc(pagy, 'class="page-link"'.freeze)
|
32
|
-
|
33
|
-
tags << (pagy.prev ? %(<li class="page-item prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), 'aria-label="previous"'.freeze}</li>)
|
34
|
-
: %(<li class="page-item prev disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.prev'.freeze)}</a></li>))
|
35
|
-
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
36
|
-
tags << if item.is_a?(Integer); %(<li class="page-item">#{link.call item}</li>) # page link
|
37
|
-
elsif item.is_a?(String) ; %(<li class="page-item active">#{link.call item}</li>) # active page
|
38
|
-
elsif item == :gap ; %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.gap'.freeze)}</a></li>) # page gap
|
39
|
-
end
|
40
|
-
end
|
41
|
-
tags << (pagy.next ? %(<li class="page-item next">#{link.call pagy.next, pagy_t('pagy.nav.next'.freeze), 'aria-label="next"'.freeze}</li>)
|
42
|
-
: %(<li class="page-item next disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.next'.freeze)}</a></li>))
|
43
|
-
%(<nav class="pagination" role="navigation" aria-label="pager"><ul class="pagination">#{tags.join}</ul></nav>)
|
23
|
+
%(<nav class="pagy-nav pagination" role="navigation" aria-label="pager">#{tags}</nav>)
|
44
24
|
end
|
45
25
|
|
46
26
|
|
@@ -77,10 +57,12 @@ class Pagy
|
|
77
57
|
|
78
58
|
|
79
59
|
# define #pagy_t depending on I18N[:gem] and I18n
|
60
|
+
# this file will get autoloaded, so environment constants like ::I18n will be already set
|
80
61
|
if I18N[:gem] || I18N[:gem].nil? && defined?(I18n)
|
81
62
|
I18n.load_path << I18N[:file]
|
82
|
-
def pagy_t(*a)
|
63
|
+
def pagy_t(*a) I18n.t(*a) end
|
83
64
|
else
|
65
|
+
require 'yaml'
|
84
66
|
# load data from the first locale in the file
|
85
67
|
I18N_DATA = YAML.load_file(I18N[:file]).first[1].freeze
|
86
68
|
# Similar to I18n.t for interpolation and pluralization but without translation
|
data/lib/templates/nav.html.erb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
Usage: link.call( page_number [, text [, extra_attributes_string ]])
|
7
7
|
-%>
|
8
8
|
<% link = pagy_link_proc(pagy) -%>
|
9
|
-
<%# -%><nav aria-label="pager" class="
|
9
|
+
<%# -%><nav aria-label="pager" class="pagy_nav agination" role="navigation">
|
10
10
|
<% if pagy.prev -%> <span class="page prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></span>
|
11
11
|
<% else -%> <span class="page prev disabled"><%== pagy_t('pagy.nav.prev') %></span>
|
12
12
|
<% end -%>
|
data/lib/templates/nav.html.haml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
- link = pagy_link_proc(pagy)
|
8
8
|
|
9
|
-
%nav.pagination{"aria-label" => "pager", :role => "navigation"}
|
9
|
+
%nav.pagy_nav.pagination{"aria-label" => "pager", :role => "navigation"}
|
10
10
|
|
11
11
|
- if pagy.prev
|
12
12
|
%span.page.prev!= link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
data/lib/templates/nav.html.slim
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
- link = pagy_link_proc(pagy)
|
8
8
|
|
9
|
-
nav.pagination role="navigation" aria-label="pager"
|
9
|
+
nav.pagy_nav.pagination role="navigation" aria-label="pager"
|
10
10
|
|
11
11
|
- if pagy.prev
|
12
12
|
span.page.prev ==> link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
data/pagy.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.license = 'MIT'
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy.gemspec', 'LICENSE'
|
20
|
+
s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy.gemspec', 'LICENSE') }
|
21
21
|
|
22
22
|
|
23
23
|
s.add_development_dependency 'bundler', '~> 1.16'
|
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: 0.
|
4
|
+
version: 0.6.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: 2018-
|
11
|
+
date: 2018-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -133,11 +133,6 @@ extensions: []
|
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
135
|
- LICENSE.txt
|
136
|
-
- README.md
|
137
|
-
- images/efficiency-table.png
|
138
|
-
- images/ips-chart.png
|
139
|
-
- images/memory-chart.png
|
140
|
-
- images/objects-chart.png
|
141
136
|
- lib/locales/pagy.yml
|
142
137
|
- lib/pagy.rb
|
143
138
|
- lib/pagy/backend.rb
|
@@ -145,9 +140,6 @@ files:
|
|
145
140
|
- lib/templates/nav.html.erb
|
146
141
|
- lib/templates/nav.html.haml
|
147
142
|
- lib/templates/nav.html.slim
|
148
|
-
- lib/templates/nav_bootstrap.html.erb
|
149
|
-
- lib/templates/nav_bootstrap.html.haml
|
150
|
-
- lib/templates/nav_bootstrap.html.slim
|
151
143
|
- pagy.gemspec
|
152
144
|
homepage: https://github.com/ddnexus/pagy
|
153
145
|
licenses:
|
data/README.md
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
# Pagy
|
2
|
-
|
3
|
-
Pagy is the ultimate pagination gem that outperforms the others in each and every benchmark and comparison.
|
4
|
-
|
5
|
-
### Benchmarks
|
6
|
-
|
7
|
-
The best way to quickly get an idea about its features is comparing it to the other well known gems.
|
8
|
-
|
9
|
-
The values shown in the charts below have been recorded while each gem was producing the exact same output: same environment conditions, same task, just different gems _(see the complete [Gems Comparison](http://ddnexus.github.io/pagination-comparison/gems.html))_
|
10
|
-
|
11
|
-
#### Pagy is a lot faster
|
12
|
-
|
13
|
-
![IPS Chart](images/ips-chart.png)
|
14
|
-
|
15
|
-
#### Pagy uses a lot less memory
|
16
|
-
|
17
|
-
![Memory Chart](images/memory-chart.png)
|
18
|
-
|
19
|
-
#### Pagy is a lot simpler
|
20
|
-
|
21
|
-
![Objects Chart](images/objects-chart.png)
|
22
|
-
|
23
|
-
#### Pagy is a lot more efficient
|
24
|
-
|
25
|
-
![Efficiency Table](images/efficiency-table.png)
|
26
|
-
|
27
|
-
_The [IPS/Kb ratio](http://ddnexus.github.io/pagination-comparison/gems.html#efficiency-ratio) is calculated out of speed (IPS) and Memory (Kb): it shows how well each gem uses any Kb of memory it allocates/consumes._
|
28
|
-
|
29
|
-
#### Pagy does not suffer the typical limitations of the other gems:
|
30
|
-
|
31
|
-
- it works with collections/scopes that already used `limit` and `offset`
|
32
|
-
- it works with both helpers or templates (your choice)
|
33
|
-
- it raises real `Pagy::OutOfRangeError` exceptions that you can rescue from
|
34
|
-
- it does not impose any difficult-to-override logic or output
|
35
|
-
|
36
|
-
### Features
|
37
|
-
|
38
|
-
#### Straightforward code
|
39
|
-
|
40
|
-
- Pagy is just ~120 lines of simple ruby, organized in 3 flat modules very easy to understand and use
|
41
|
-
- it produces its own HTML, URLs, pluralization and interpolation with its own specialized and fast code
|
42
|
-
- 100% of its methods are public API, accessible and overridable **right where you use them** (no need of monkey patching or subclassing)
|
43
|
-
|
44
|
-
#### Totally agnostic
|
45
|
-
|
46
|
-
- it doesn't need to know anything about your models, ORM or Storage, so it doesn't add any code to them
|
47
|
-
- it works with all kind of collections, even pre-paginated, records, Arrays, JSON data... and just whatever you can count
|
48
|
-
- it works with all Rack frameworks (Rails, Sinatra, Padrino, ecc.) out of the box
|
49
|
-
- it works with any possible non-Rack envoronment by just overriding one or two one-liner methods
|
50
|
-
|
51
|
-
#### Simple Usage
|
52
|
-
|
53
|
-
You can use pagy in a quite familiar way:
|
54
|
-
|
55
|
-
Paginate your collection in some controller:
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
@pagy, @records = pagy(Product.some_scope)
|
59
|
-
```
|
60
|
-
|
61
|
-
Render the navigation links with a super-fast helper in some view:
|
62
|
-
|
63
|
-
```HTML+ERB
|
64
|
-
<%= pagy_nav(@pagy) %>
|
65
|
-
```
|
66
|
-
|
67
|
-
Or - if you prefer - render the navigation links with a template:
|
68
|
-
|
69
|
-
```HTML+ERB
|
70
|
-
<%= render 'pagy/nav', locals: {pagy: @pagy} %>
|
71
|
-
```
|
72
|
-
|
73
|
-
## Support, Comments and Feature Requests
|
74
|
-
|
75
|
-
[![Join the chat at https://gitter.im/ruby-pagy/Lobby](https://badges.gitter.im/ruby-pagy/Lobby.svg)](https://gitter.im/ruby-pagy/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
76
|
-
|
77
|
-
## Useful Links
|
78
|
-
|
79
|
-
- [Documentation](https://ddnexus.github.io/pagy/index)
|
80
|
-
- [Pagination Comparison App](http://github.com/ddnexus/pagination-comparison)
|
81
|
-
|
82
|
-
## Help Wanted
|
83
|
-
|
84
|
-
Pagy is a fresh project and your help would be great. If you like it, you have a few options to contribute:
|
85
|
-
|
86
|
-
- write a tutorial or a post or even just a tweet (pagy is young and needs to be known)
|
87
|
-
- write a "How To" topic (the documentation is covering the basics and there is a lot of space for additions)
|
88
|
-
- submit a pull request to make pagy even faster, save more memory or improve its usability
|
89
|
-
- create an issue if anything should be improved/fixed
|
90
|
-
|
91
|
-
## License
|
92
|
-
|
93
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/images/efficiency-table.png
DELETED
Binary file
|
data/images/ips-chart.png
DELETED
Binary file
|
data/images/memory-chart.png
DELETED
Binary file
|
data/images/objects-chart.png
DELETED
Binary file
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
3
|
-
calls with the actual strings ("‹ Prev", "Next ›", "…").
|
4
|
-
|
5
|
-
The link variable is set to a proc that returns the link tag.
|
6
|
-
Usage: link.call( page_number [, text [, extra_attributes_string ]])
|
7
|
-
-%>
|
8
|
-
<% link = pagy_link_proc(pagy, 'class="page-link"') -%>
|
9
|
-
<%# -%><nav aria-label="pager" class="pagination" role="navigation">
|
10
|
-
<%# -%> <ul class="pagination">
|
11
|
-
<% if pagy.prev -%> <li class="page-item prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></li>
|
12
|
-
<% else -%> <li class="page-item prev disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.prev') %></a></li>
|
13
|
-
<% end -%>
|
14
|
-
<% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
|
15
|
-
<% if item.is_a?(Integer) -%> <li class="page-item"><%== link.call(item) %></li>
|
16
|
-
<% elsif item.is_a?(String) -%> <li class="page-item active"><%== link.call(item) %></li>
|
17
|
-
<% elsif item == :gap -%> <li class="page-item disabled gap"><a href="#" class="page-link"><%== pagy_t('pagy.nav.gap') %></a></li>
|
18
|
-
<% end -%>
|
19
|
-
<% end -%>
|
20
|
-
<% if pagy.next -%> <li class="page-item next"><%== link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"') %></li>
|
21
|
-
<% else -%> <li class="page-item next disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.next') %></a></li>
|
22
|
-
<% end -%>
|
23
|
-
<%# -%> </ul>
|
24
|
-
<%# -%></nav>
|
@@ -1,34 +0,0 @@
|
|
1
|
-
-# This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
|
-
-# calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
|
-
|
4
|
-
-# The link variable is set to a proc that returns the link tag.
|
5
|
-
-# Usage: link.call( page_number [, text [, extra_attributes_string ]])
|
6
|
-
|
7
|
-
- link = pagy_link_proc(pagy, 'class="page-link"')
|
8
|
-
|
9
|
-
%nav.pagination{"aria-label" => "pager", :role => "navigation"}
|
10
|
-
|
11
|
-
%ul.pagination
|
12
|
-
|
13
|
-
- if pagy.prev
|
14
|
-
%li.page-item.prev!= link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
15
|
-
- else
|
16
|
-
%li.page-item.prev.disabled
|
17
|
-
%a.page-link{:href => '#'}!= pagy_t('pagy.nav.prev')
|
18
|
-
|
19
|
-
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
20
|
-
- if item.is_a?(Integer) # page link
|
21
|
-
%li.page-item!= link.call(item)
|
22
|
-
|
23
|
-
- elsif item.is_a?(String) # current page
|
24
|
-
%li.page-item.active!= link.call(item)
|
25
|
-
|
26
|
-
- elsif item == :gap # page gap
|
27
|
-
%li.page-item.disabled.gap
|
28
|
-
%a.page-link{:href => "#"}!= pagy_t('pagy.nav.gap')
|
29
|
-
|
30
|
-
- if pagy.next
|
31
|
-
%li.page-item.next!= link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
|
32
|
-
- else
|
33
|
-
%li.page-item.next.disabled
|
34
|
-
%a.page-link{:href => '#'}!= pagy_t('pagy.nav.next')
|
@@ -1,34 +0,0 @@
|
|
1
|
-
/ This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
|
-
/ calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
|
-
|
4
|
-
/ The link variable is set to a proc that returns the link tag.
|
5
|
-
/ Usage: link.call( page_number [, text [, extra_attributes_string ]])
|
6
|
-
|
7
|
-
- link = pagy_link_proc(pagy, 'class="page-link"')
|
8
|
-
|
9
|
-
nav.pagination role="navigation" aria-label="pager"
|
10
|
-
|
11
|
-
ul.pagination
|
12
|
-
|
13
|
-
- if pagy.prev
|
14
|
-
li.page-item.prev == link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
15
|
-
- else
|
16
|
-
li.page-item.prev.disabled
|
17
|
-
a.page-link href="#" == pagy_t('pagy.nav.prev')
|
18
|
-
|
19
|
-
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
20
|
-
- if item.is_a?(Integer) # page link
|
21
|
-
li.page-item == link.call(item)
|
22
|
-
|
23
|
-
- elsif item.is_a?(String) # current page
|
24
|
-
li.page-item.active == link.call(item)
|
25
|
-
|
26
|
-
- elsif item == :gap # page gap
|
27
|
-
li.page-item.disabled.gap
|
28
|
-
a.page-link href="#" == pagy_t('pagy.nav.gap')
|
29
|
-
|
30
|
-
- if pagy.next
|
31
|
-
li.page-item.next == link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
|
32
|
-
- else
|
33
|
-
li.page-item.next.disabled
|
34
|
-
a.page-link href="#" == pagy_t('pagy.nav.next')
|