pagy 0.4.0 → 0.4.1
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 +1 -1
- data/lib/pagy.rb +8 -8
- data/lib/pagy/backend.rb +2 -2
- data/lib/pagy/frontend.rb +71 -63
- data/lib/templates/bootstrap.html.erb +7 -15
- data/lib/templates/bootstrap.html.haml +7 -7
- data/lib/templates/bootstrap.html.slim +7 -7
- data/lib/templates/default.html.erb +3 -12
- data/lib/templates/default.html.haml +2 -2
- data/lib/templates/default.html.slim +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45ce91ee38e0d07518e33c4f2a16cc19c65c2848193ad545fbec38ebee5be5d9
|
4
|
+
data.tar.gz: b340e01c042fbefd0874c88395a5c9a93e020dc422725d700a21ea996287b907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3639fa6a75f4204277281c49e0579dc02304a3e11d32029508b81e624dba6a494ad90af1440d15db884e84015282e61bd2e3497c7cb2354197dda95e037f452
|
7
|
+
data.tar.gz: b406ef5bad8f0bd50d2065ffce5c04673ad0858eb293337bdaa03057aa80abef014550279db963a27e757e1393de13fa7f77e8a350bb7a8c04d00c4784afe8c3
|
data/lib/locales/pagy.yml
CHANGED
@@ -18,7 +18,7 @@ en:
|
|
18
18
|
zero: "No %{item_name} found"
|
19
19
|
one: "Displaying <b>1</b> %{item_name}"
|
20
20
|
other: "Displaying <b>all %{count}</b> %{item_name}"
|
21
|
-
multiple_pages: "Displaying %{item_name} <b>%{from}-%{to}</b> of <b>%{count}</b>"
|
21
|
+
multiple_pages: "Displaying %{item_name} <b>%{from}-%{to}</b> of <b>%{count}</b> in total"
|
22
22
|
item:
|
23
23
|
zero: "items"
|
24
24
|
one: "item"
|
data/lib/pagy.rb
CHANGED
@@ -7,7 +7,7 @@ require 'ostruct'
|
|
7
7
|
# Notice that it doesn't actually do any pagination, nor navigation... that is
|
8
8
|
# done with a few helpers in the Pagy::Backend and Pagy::Frontend modules.
|
9
9
|
|
10
|
-
class Pagy ; VERSION = '0.4.
|
10
|
+
class Pagy ; VERSION = '0.4.1'
|
11
11
|
|
12
12
|
autoload :Backend, 'pagy/backend'
|
13
13
|
autoload :Frontend, 'pagy/frontend'
|
@@ -37,7 +37,7 @@ class Pagy ; VERSION = '0.4.0'
|
|
37
37
|
instance_variable_set(:"@#{k}", @opts.delete(k)) # set all the metrics variables
|
38
38
|
end
|
39
39
|
@pages = @last = [(@count.to_f / @limit).ceil, 1].max # cardinal and ordinal meanings
|
40
|
-
(1..@last).cover?(@page) || raise(OutOfRangeError, "expected :page in 1..#{last}; got #{@page.inspect}")
|
40
|
+
(1..@last).cover?(@page) || raise(OutOfRangeError, "expected :page in 1..#{@last}; got #{@page.inspect}")
|
41
41
|
@offset += @limit * (@page - 1) # initial offset + offset for pagination
|
42
42
|
@limit = @count % @limit if @page == @last # adjust limit for last page (for pre-limit(ed) collection)
|
43
43
|
@from = @count.zero? ? 0 : @offset+1 # page begins from item
|
@@ -46,15 +46,15 @@ class Pagy ; VERSION = '0.4.0'
|
|
46
46
|
@next = (@page+1 unless @page == @last) # nil if no next page
|
47
47
|
@series = [] # e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
48
48
|
all = (0..@last+1) # page range with boundaries
|
49
|
-
|
50
|
-
row = (all.first(@initial+1) |
|
49
|
+
around = ([@page-@before, 1].max .. [@page+@after, @last].min).to_a # before..after pages
|
50
|
+
row = (all.first(@initial+1) | around | all.last(@final+1)).sort # row of pages with boundaries
|
51
51
|
row.each_cons(2) do |a, b| # loop in consecutive pairs
|
52
52
|
if a+1 == b; @series.push(a) # no gap -> no additions
|
53
|
-
elsif a+2 == b; @series.push(a, a+1) # 1 page gap -> fill with
|
54
|
-
else @series.push(a, :gap) #
|
55
|
-
end # skip the
|
53
|
+
elsif a+2 == b; @series.push(a, a+1) # 1 page gap -> fill with missing page
|
54
|
+
else @series.push(a, :gap) # n page gap -> add :gap
|
55
|
+
end # skip the end-boundary (last+1)
|
56
56
|
end
|
57
|
-
@series.shift # remove the
|
57
|
+
@series.shift # remove the start-boundary (0)
|
58
58
|
@series[@series.index(@page)] = @page.to_s # convert the current page to String
|
59
59
|
end
|
60
60
|
|
data/lib/pagy/backend.rb
CHANGED
@@ -4,11 +4,11 @@ class Pagy
|
|
4
4
|
# #pagy method, but it does not add any functionality on its own.
|
5
5
|
#
|
6
6
|
# Using the module allows you to have a predefined method and a few sub-methods
|
7
|
-
# (i.e. methods called only by the
|
7
|
+
# (i.e. methods called only by the predefined method) handy if you need to override
|
8
8
|
# some aspect of the predefined #pagy method.
|
9
9
|
#
|
10
10
|
# However, you can just explicitly write your own pagy method in just a couple of
|
11
|
-
# lines
|
11
|
+
# lines, specially if you need to override two or more methods. For example:
|
12
12
|
#
|
13
13
|
# def pagy(scope, opts={})
|
14
14
|
# pagy = Pagy.new scope.count, page: params[:page], **opts
|
data/lib/pagy/frontend.rb
CHANGED
@@ -5,82 +5,53 @@ class Pagy
|
|
5
5
|
# in order to fit its behavior with your app needs (e.g.: removing and adding some param or
|
6
6
|
# allowing fancy routes, etc.)
|
7
7
|
#
|
8
|
-
# All the code has been optimized for
|
9
|
-
#
|
10
|
-
# that can be used in place of the equivalent (but general-purpose) framework helpers,
|
11
|
-
# in order to dramatically boost speed and reduce memory usage.
|
12
|
-
#
|
13
|
-
# For example if you use the rails link_to in order to link each page in the pagination bar,
|
14
|
-
# you will call 10 or 20 times the same method that has to do a lot of things again and again
|
15
|
-
# just to get you (almost) the same string repeated with just the page number replaced.
|
16
|
-
# Since pagination is a very specialized process, it is possible to do the same by using
|
17
|
-
# a one-line proc that uses just one single string interpolation. Compared to the general-purpose
|
18
|
-
# link_to method, the pagy_link_proc benchmark gives a 20 times faster score and 12 times less memory.
|
19
|
-
#
|
20
|
-
# Notice: The code in this module may not look very pretty (as most code dealing with many long strings),
|
21
|
-
# but its performance makes it very sexy! ;)
|
22
|
-
|
8
|
+
# All the code here has been optimized for performance: it may not look very pretty
|
9
|
+
# (as most code dealing with many long strings), but its performance makes it very sexy! ;)
|
23
10
|
module Frontend
|
24
11
|
|
25
|
-
# Notice: Each long tag-string of the nav methods is written on one single line with a long
|
26
|
-
# interpolation in the middle for performance and... (hard to believe) readability reasons.
|
27
|
-
#
|
28
|
-
# Performance:
|
29
|
-
# using the '%' method like in the following example:
|
30
|
-
#
|
31
|
-
# case item
|
32
|
-
# when Integer; '<span class="page">%s</span>' % link.call(item)
|
33
|
-
# when String ; '<span class="page active">%s</span>' % item
|
34
|
-
# when :gap ; '<span class="page gap">%s</span>' % pagy_t('pagy.nav.gap')
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# would look a lot better but the benchmark really sucks! :/
|
38
|
-
#
|
39
|
-
# Readability:
|
40
|
-
# If you disable soft-wrapping in your editor, you can focus on the very simple ruby logic
|
41
|
-
# unfolding at the beginning of the lines, without any string-distraction.
|
42
|
-
# For the strings: each tag-string has only one interpolation, so at the end they are
|
43
|
-
# simple to deal with, even if they look a bit ugly.
|
44
|
-
|
45
12
|
# Generic pagination: it returns the html with the series of links to the pages
|
46
13
|
def pagy_nav(pagy, opts=nil)
|
47
|
-
pagy.opts.merge
|
14
|
+
opts = opts ? pagy.opts.merge(opts) : pagy.opts
|
15
|
+
link = pagy_link_proc(pagy)
|
16
|
+
tags = []
|
48
17
|
|
49
18
|
tags << (pagy.prev ? %(<span class="page prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), 'aria-label="previous"'.freeze}</span>)
|
50
19
|
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev'.freeze)}</span>))
|
51
20
|
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
52
21
|
tags << case item
|
53
|
-
when Integer; %(<span class="page">#{link.call item}</span>)
|
22
|
+
when Integer; %(<span class="page">#{link.call item}</span>) # page link
|
54
23
|
when String ; %(<span class="page active">#{item}</span>) # current page
|
55
24
|
when :gap ; %(<span class="page gap">#{pagy_t('pagy.nav.gap'.freeze)}</span>) # page gap
|
56
25
|
end
|
57
26
|
end
|
58
27
|
tags << (pagy.next ? %(<span class="page next">#{link.call pagy.next, pagy_t('pagy.nav.next'.freeze), 'aria-label="next"'.freeze}</span>)
|
59
28
|
: %(<span class="page next disabled">#{pagy_t('pagy.nav.next'.freeze)}</span>))
|
60
|
-
%(<nav class="#{
|
29
|
+
%(<nav class="#{opts[:class]||'pagination'.freeze}" role="navigation" aria-label="pager">#{tags.join(opts[:separator]||' '.freeze)}</nav>)
|
61
30
|
end
|
62
31
|
|
63
32
|
|
64
33
|
# Pagination for bootstrap: it returns the html with the series of links to the pages
|
65
34
|
def pagy_nav_bootstrap(pagy, opts=nil)
|
66
|
-
pagy.opts.merge
|
35
|
+
opts = opts ? pagy.opts.merge(opts) : pagy.opts
|
36
|
+
link = pagy_link_proc(pagy, 'class="page-link"'.freeze)
|
37
|
+
tags = []
|
67
38
|
|
68
|
-
tags << (pagy.prev ? %(<li class="page-item prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), '
|
39
|
+
tags << (pagy.prev ? %(<li class="page-item prev">#{link.call pagy.prev, pagy_t('pagy.nav.prev'.freeze), 'aria-label="previous"'.freeze}</li>)
|
69
40
|
: %(<li class="page-item prev disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.prev'.freeze)}</a></li>))
|
70
41
|
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
71
42
|
tags << case item
|
72
|
-
when Integer; %(<li class="page-item">#{link.call item
|
73
|
-
when String ; %(<li class="page-item active">#{link.call item
|
43
|
+
when Integer; %(<li class="page-item">#{link.call item}</li>) # page link
|
44
|
+
when String ; %(<li class="page-item active">#{link.call item}</li>) # active page
|
74
45
|
when :gap ; %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.gap'.freeze)}</a></li>) # page gap
|
75
46
|
end
|
76
47
|
end
|
77
|
-
tags << (pagy.next ? %(<li class="page-item next">#{link.call pagy.next, pagy_t('pagy.nav.next'.freeze), '
|
48
|
+
tags << (pagy.next ? %(<li class="page-item next">#{link.call pagy.next, pagy_t('pagy.nav.next'.freeze), 'aria-label="next"'.freeze}</li>)
|
78
49
|
: %(<li class="page-item next disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.next'.freeze)}</a></li>))
|
79
|
-
%(<nav class="#{
|
50
|
+
%(<nav class="#{opts[:class]||'pagination'.freeze}" role="navigation" aria-label="pager"><ul class="pagination">#{tags.join}</ul></nav>)
|
80
51
|
end
|
81
52
|
|
82
53
|
|
83
|
-
# return examples: "Displaying items 41-60 of 324" or "Displaying Products 41-60 of 324"
|
54
|
+
# return examples: "Displaying items 41-60 of 324 in total" or "Displaying Products 41-60 of 324 in total"
|
84
55
|
def pagy_info(pagy, vars=nil)
|
85
56
|
name = vars && vars[:item_name] || pagy_t(pagy.opts[:i18n_key] || 'pagy.info.item'.freeze, count: pagy.count)
|
86
57
|
name = pagy_t('pagy.info.item'.freeze, count: pagy.count) if name.start_with?('translation missing:'.freeze)
|
@@ -100,7 +71,7 @@ class Pagy
|
|
100
71
|
# not needed (for example when your application is a single-locale app, e.g. only 'en', or only 'fr'...).
|
101
72
|
#
|
102
73
|
# It implements only the very basic functionality of the I18n.t method
|
103
|
-
# but it
|
74
|
+
# but it's still good enough for the limited Pagy's needs and it is faster.
|
104
75
|
#
|
105
76
|
# You can still use this method with a pluralization different than English
|
106
77
|
# (i.e. not 'zero', 'one', 'other' plurals). In that case you should define the
|
@@ -111,14 +82,14 @@ class Pagy
|
|
111
82
|
# and add your translations to the I18n usual locales files
|
112
83
|
|
113
84
|
hash = YAML.load_file Opts.i18n_file || Pagy.root.join('locales', 'pagy.yml')
|
114
|
-
|
85
|
+
I18N = hash[hash.keys.first].freeze
|
115
86
|
|
116
87
|
# Similar to I18n.t for interpolation and pluralization, with the following constraints:
|
117
88
|
# - the path/keys option is supported only in dot-separated string or symbol format
|
118
89
|
# - the :scope and :default options are not supported
|
119
90
|
# - no exception are raised: the errors are returned as translated strings
|
120
91
|
def pagy_t(path, vars={})
|
121
|
-
value =
|
92
|
+
value = I18N.dig(*path.to_s.split('.'.freeze))
|
122
93
|
if value.is_a?(Hash)
|
123
94
|
vars.has_key?(:count) or return value
|
124
95
|
plural = (Opts.i18n_plurals ||= -> (c) {c==0 && 'zero' || c==1 && 'one' || 'other'}).call(vars[:count])
|
@@ -129,26 +100,63 @@ class Pagy
|
|
129
100
|
sprintf value, Hash.new{|h,k| "%{#{k}}"}.merge!(vars) # interpolation
|
130
101
|
end
|
131
102
|
|
132
|
-
# This method
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
103
|
+
# NOTICE: This method is used internally, so you need to know about it only if you
|
104
|
+
# are going to override a *_nav helper or a template AND changing the link tags.
|
105
|
+
#
|
106
|
+
# You call this method in order to get a proc that you will call to produce the page links.
|
107
|
+
# The reasaon it is a 2 step process instead of a single method call is performance.
|
108
|
+
#
|
109
|
+
# Call the method to get the proc (once):
|
110
|
+
# link = pagy_link_proc( pagy [, extra_attributes_string ])
|
111
|
+
#
|
112
|
+
# Call the proc to get the links (multiple times):
|
113
|
+
# link.call( page_number [, label [, extra_attributes_string ]])
|
114
|
+
#
|
115
|
+
# You can pass extra attribute strings to get inserted in the link tags at many different levels.
|
116
|
+
# Depending by the scope you want your attributes to be added, (from wide to narrow) you can:
|
117
|
+
#
|
118
|
+
# 1. For all pagy objects: set the global option :link_extra:
|
119
|
+
#
|
120
|
+
# Pagy::Opts.extra_link = 'data-remote="true"'
|
121
|
+
# link.call(page_number=2)
|
122
|
+
# #=> <a href="...?page=2" data-remote="true">2</a>
|
123
|
+
#
|
124
|
+
# 2. For one pagy object: pass a :link_extra option to a pagy constructor (Pagy.new or pagy controller method):
|
125
|
+
#
|
126
|
+
# @pagy, @records = pagy(my_scope, extra_link: 'data-remote="true"')
|
127
|
+
# link.call(page_number)
|
128
|
+
# #=> <a href="...?page=2" data-remote="true">2</a>
|
129
|
+
#
|
130
|
+
# 3. For one pagy_nav render: pass a :link_extra option to a *_nav method:
|
131
|
+
#
|
132
|
+
# pagy_nav(@pagy, extra_link: 'data-remote="true"') #
|
133
|
+
# link.call(page_number)
|
134
|
+
# #=> <a href="...?page=2" data-remote="true">2</a>
|
135
|
+
#
|
136
|
+
# 4. For all the calls to the returned pagy_link_proc: pass an extra attributes string when you get the proc:
|
137
|
+
#
|
138
|
+
# link = pagy_link_proc(pagy, 'class="page-link"')
|
139
|
+
# link.call(page_number)
|
140
|
+
# #=> <a href="...?page=2" data-remote="true" class="page-link">2</a>
|
141
|
+
#
|
142
|
+
# 5. For a single link.call: pass an extra attributes string when you call the proc:
|
136
143
|
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
# :link_extra => 'data-remote="true" class="special"'
|
144
|
+
# link.call(page_number, 'aria-label="my-label"')
|
145
|
+
# #=> <a href="...?page=2" data-remote="true" class="page-link" aria-label="my-label">2</a>
|
140
146
|
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
# Tricky but very fast!
|
147
|
+
# WARNING: since we use only strings for performance, the attribute strings get concatenated, not merged!
|
148
|
+
# Be careful not to pass the same attribute at different levels multiple times. That would generate a duplicated
|
149
|
+
# attribute which is illegal html (although handled by all mayor browsers by ignoring all the duplicates but the first)
|
145
150
|
|
146
151
|
MARKER = "-pagy-#{'pagy'.hash}-".freeze
|
147
152
|
|
148
|
-
def pagy_link_proc(pagy)
|
149
|
-
|
150
|
-
a, b = %(<a href="#{pagy_url_for(MARKER)}" #{
|
151
|
-
-> (n,
|
153
|
+
def pagy_link_proc(pagy, lx=''.freeze) # link extra
|
154
|
+
p_prev, p_next, p_lx = pagy.prev, pagy.next, pagy.opts[:link_extra]
|
155
|
+
a, b = %(<a href="#{pagy_url_for(MARKER)}"#{p_lx ? %( #{p_lx}) : ''.freeze}#{lx.empty? ? lx : %( #{lx})}).split(MARKER)
|
156
|
+
-> (n, text=n, x=''.freeze) { "#{a}#{n}#{b}#{ if n == p_prev; ' rel="prev"'.freeze
|
157
|
+
elsif n == p_next; ' rel="next"'.freeze
|
158
|
+
else ''.freeze
|
159
|
+
end }#{x.empty? ? x : %( #{x})}>#{text}</a>" }
|
152
160
|
end
|
153
161
|
|
154
162
|
end
|
@@ -2,39 +2,31 @@
|
|
2
2
|
This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
3
3
|
calls with the actual strings ("‹ Prev", "Next ›", "…").
|
4
4
|
|
5
|
-
|
6
|
-
Usage: link.call(page_number[,
|
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
7
|
-%>
|
8
|
-
<% link = pagy_link_proc(pagy)
|
9
|
-
|
8
|
+
<% link = pagy_link_proc(pagy, 'class="page-link"') -%>
|
10
9
|
<nav aria-label="pager" class="pagination" role="navigation">
|
11
10
|
<ul class="pagination">
|
12
|
-
|
13
11
|
<% if pagy.prev -%>
|
14
|
-
<li class="page-item prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), '
|
12
|
+
<li class="page-item prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></li>
|
15
13
|
<% else -%>
|
16
14
|
<li class="page-item prev disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.prev') %></a></li>
|
17
15
|
<% end -%>
|
18
|
-
|
19
16
|
<% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
|
20
17
|
<% case item
|
21
18
|
when Integer # page link -%>
|
22
|
-
<li class="page-item"><%== link.call(item
|
23
|
-
|
19
|
+
<li class="page-item"><%== link.call(item) %></li>
|
24
20
|
<% when String # current page -%>
|
25
|
-
<li class="page-item active"><%== link.call(item
|
26
|
-
|
21
|
+
<li class="page-item active"><%== link.call(item) %></li>
|
27
22
|
<% when :gap # page gap -%>
|
28
23
|
<li class="page-item disabled gap"><a href="#" class="page-link"><%== pagy_t('pagy.nav.gap') %></a></li>
|
29
|
-
|
30
24
|
<% end -%>
|
31
25
|
<% end -%>
|
32
|
-
|
33
26
|
<% if pagy.next -%>
|
34
|
-
<li class="page-item next"><%== link.call(pagy.next, pagy_t('pagy.nav.next'), '
|
27
|
+
<li class="page-item next"><%== link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"') %></li>
|
35
28
|
<% else -%>
|
36
29
|
<li class="page-item next disabled"><a href="#" class="page-link"><%== pagy_t('pagy.nav.next') %></a></li>
|
37
30
|
<% end -%>
|
38
|
-
|
39
31
|
</ul>
|
40
32
|
</nav>
|
@@ -1,17 +1,17 @@
|
|
1
1
|
-# This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
2
|
-# calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
3
|
|
4
|
-
-#
|
5
|
-
-# Usage: link.call(page_number[,
|
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
6
|
|
7
|
-
- link = pagy_link_proc(pagy)
|
7
|
+
- link = pagy_link_proc(pagy, 'class="page-link"')
|
8
8
|
|
9
9
|
%nav.pagination{"aria-label" => "pager", :role => "navigation"}
|
10
10
|
|
11
11
|
%ul.pagination
|
12
12
|
|
13
13
|
- if pagy.prev
|
14
|
-
%li.page-item.prev!= link.call(pagy.prev, pagy_t('pagy.nav.prev'), '
|
14
|
+
%li.page-item.prev!= link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
15
15
|
- else
|
16
16
|
%li.page-item.prev.disabled
|
17
17
|
%a.page-link{:href => '#'}!= pagy_t('pagy.nav.prev')
|
@@ -19,17 +19,17 @@
|
|
19
19
|
- pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
20
20
|
- case item
|
21
21
|
- when Integer # page link
|
22
|
-
%li.page-item!= link.call(item
|
22
|
+
%li.page-item!= link.call(item)
|
23
23
|
|
24
24
|
- when String # current page
|
25
|
-
%li.page-item.active!= link.call(item
|
25
|
+
%li.page-item.active!= link.call(item)
|
26
26
|
|
27
27
|
- when :gap # page gap
|
28
28
|
%li.page-item.disabled.gap
|
29
29
|
%a.page-link{:href => "#"}!= pagy_t('pagy.nav.gap')
|
30
30
|
|
31
31
|
- if pagy.next
|
32
|
-
%li.page-item.next!= link.call(pagy.next, pagy_t('pagy.nav.next'), '
|
32
|
+
%li.page-item.next!= link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
|
33
33
|
- else
|
34
34
|
%li.page-item.next.disabled
|
35
35
|
%a.page-link{:href => '#'}!= pagy_t('pagy.nav.next')
|
@@ -1,17 +1,17 @@
|
|
1
1
|
/ This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
2
|
/ calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
3
|
|
4
|
-
/
|
5
|
-
/ Usage: link.call(page_number[,
|
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
6
|
|
7
|
-
- link = pagy_link_proc(pagy)
|
7
|
+
- link = pagy_link_proc(pagy, 'class="page-link"')
|
8
8
|
|
9
9
|
nav.pagination role="navigation" aria-label="pager"
|
10
10
|
|
11
11
|
ul.pagination
|
12
12
|
|
13
13
|
- if pagy.prev
|
14
|
-
li.page-item.prev == link.call(pagy.prev, pagy_t('pagy.nav.prev'), '
|
14
|
+
li.page-item.prev == link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')
|
15
15
|
- else
|
16
16
|
li.page-item.prev.disabled
|
17
17
|
a.page-link href="#" == pagy_t('pagy.nav.prev')
|
@@ -20,17 +20,17 @@ nav.pagination role="navigation" aria-label="pager"
|
|
20
20
|
- case item
|
21
21
|
|
22
22
|
- when Integer # page link
|
23
|
-
li.page-item == link.call(item
|
23
|
+
li.page-item == link.call(item)
|
24
24
|
|
25
25
|
- when String # current page
|
26
|
-
li.page-item.active == link.call(item
|
26
|
+
li.page-item.active == link.call(item)
|
27
27
|
|
28
28
|
- when :gap # page gap
|
29
29
|
li.page-item.disabled.gap
|
30
30
|
a.page-link href="#" == pagy_t('pagy.nav.gap')
|
31
31
|
|
32
32
|
- if pagy.next
|
33
|
-
li.page-item.next == link.call(pagy.next, pagy_t('pagy.nav.next'), '
|
33
|
+
li.page-item.next == link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
|
34
34
|
- else
|
35
35
|
li.page-item.next.disabled
|
36
36
|
a.page-link href="#" == pagy_t('pagy.nav.next')
|
@@ -2,38 +2,29 @@
|
|
2
2
|
This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
3
3
|
calls with the actual strings ("‹ Prev", "Next ›", "…").
|
4
4
|
|
5
|
-
|
6
|
-
Usage: link.call(page_number[,
|
7
|
-
-%>
|
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
8
|
<% link = pagy_link_proc(pagy) -%>
|
9
|
-
|
10
9
|
<nav aria-label="pager" class="pagination" role="navigation">
|
11
|
-
|
12
10
|
<% if pagy.prev -%>
|
13
11
|
<span class="page prev"><%== link.call(pagy.prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"') %></span>
|
14
12
|
<% else -%>
|
15
13
|
<span class="page prev disabled"><%== pagy_t('pagy.nav.prev') %></span>
|
16
14
|
<% end -%>
|
17
|
-
|
18
15
|
<% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
|
19
16
|
<% case item
|
20
|
-
|
21
17
|
when Integer # page link -%>
|
22
18
|
<span class="page"><%== link.call(item) %></span>
|
23
|
-
|
24
19
|
<% when String # current page -%>
|
25
20
|
<span class="page current"><%= item %></span>
|
26
|
-
|
27
21
|
<% when :gap # page gap -%>
|
28
22
|
<span class="page gap"><%== pagy_t('pagy.nav.gap') %></span>
|
29
|
-
|
30
23
|
<% end -%>
|
31
24
|
<% end -%>
|
32
|
-
|
33
25
|
<% if pagy.next -%>
|
34
26
|
<span class="page next"><%== link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"') %></span>
|
35
27
|
<% else -%>
|
36
28
|
<span class="page next disabled"><%== pagy_t('pagy.nav.next') %></span>
|
37
29
|
<% end -%>
|
38
|
-
|
39
30
|
</nav>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
-# This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
2
|
-# calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
3
|
|
4
|
-
-#
|
5
|
-
-# Usage: link.call(page_number[,
|
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
6
|
|
7
7
|
- link = pagy_link_proc(pagy)
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/ This template is i18n-ready: if you don't use i18n, then you can replace the pagy_t
|
2
2
|
/ calls with the actual strings ("‹ Prev", "Next ›", "…").
|
3
3
|
|
4
|
-
/
|
5
|
-
/ Usage: link.call(page_number[,
|
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
6
|
|
7
7
|
- link = pagy_link_proc(pagy)
|
8
8
|
|
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.
|
4
|
+
version: 0.4.1
|
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-02-
|
11
|
+
date: 2018-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|