pagy 3.13.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +1,42 @@
1
1
  # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/metadata
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  class Pagy
6
5
  # Add a specialized backend method for pagination metadata
7
- module Backend ; private
6
+ module Backend
7
+ private
8
8
 
9
- METADATA = [ :scaffold_url, :first_url, :prev_url, :page_url, :next_url, :last_url,
10
- :count, :page, :items, :vars, :pages, :last, :from, :to, :prev, :next, :series ]
11
- METADATA << :sequels if VARS.key?(:steps) # :steps gets defined along with the #sequels method
9
+ METADATA = %i[ scaffold_url first_url prev_url page_url next_url last_url
10
+ count page items vars pages last from to prev next series
11
+ ].tap do |metadata|
12
+ metadata << :sequels if VARS.key?(:steps) # :steps gets defined along with the #sequels method
13
+ end.freeze
12
14
 
13
15
  VARS[:metadata] = METADATA.dup
14
16
 
15
17
  include Helpers
16
18
 
17
- def pagy_metadata(pagy, url=false)
18
- names = pagy.vars[:metadata]
19
- (unknown = names - METADATA).empty? or raise(VariableError.new(pagy), "unknown metadata #{unknown.inspect}")
20
- scaffold_url = pagy_url_for(PAGE_PLACEHOLDER, pagy, url)
21
- metadata = {}
22
- names.each do |key|
23
- metadata[key] = case key
24
- when :scaffold_url ; scaffold_url
25
- when :first_url ; scaffold_url.sub(PAGE_PLACEHOLDER, 1.to_s)
26
- when :prev_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.prev.to_s)
27
- when :page_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.page.to_s)
28
- when :next_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.next.to_s)
29
- when :last_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.last.to_s)
30
- else pagy.send(key)
31
- end
19
+ def pagy_metadata(pagy, deprecated_url=nil, absolute: nil)
20
+ absolute = Pagy.deprecated_arg(:url, deprecated_url, :absolute, absolute) if deprecated_url
21
+ names = pagy.vars[:metadata]
22
+ unknown = names - METADATA
23
+ raise VariableError.new(pagy), "unknown metadata #{unknown.inspect}" \
24
+ unless unknown.empty?
25
+
26
+ scaffold_url = pagy_url_for(pagy, PAGE_PLACEHOLDER, absolute: absolute)
27
+ {}.tap do |metadata|
28
+ names.each do |key|
29
+ metadata[key] = case key
30
+ when :scaffold_url then scaffold_url
31
+ when :first_url then scaffold_url.sub(PAGE_PLACEHOLDER, 1.to_s)
32
+ when :prev_url then scaffold_url.sub(PAGE_PLACEHOLDER, pagy.prev.to_s)
33
+ when :page_url then scaffold_url.sub(PAGE_PLACEHOLDER, pagy.page.to_s)
34
+ when :next_url then scaffold_url.sub(PAGE_PLACEHOLDER, pagy.next.to_s)
35
+ when :last_url then scaffold_url.sub(PAGE_PLACEHOLDER, pagy.last.to_s)
36
+ else pagy.send(key)
37
+ end
38
+ end
32
39
  end
33
- metadata
34
40
  end
35
41
 
36
42
  end
@@ -1,5 +1,4 @@
1
1
  # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/navs
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  require 'pagy/extras/shared'
@@ -8,31 +7,57 @@ class Pagy
8
7
  module Frontend
9
8
 
10
9
  # Javascript pagination: it returns a nav and a JSON tag used by the Pagy.nav javascript
11
- def pagy_nav_js(pagy, id=pagy_id)
12
- link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next
13
- tags = { 'before' => p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
14
- : %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ),
10
+ def pagy_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '', steps: nil)
11
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
12
+ p_id = %( id="#{pagy_id}") if pagy_id
13
+ link = pagy_link_proc(pagy, link_extra: link_extra)
14
+ tags = { 'before' => pagy_nav_prev_html(pagy, link),
15
15
  'link' => %(<span class="page">#{link.call(PAGE_PLACEHOLDER)}</span> ),
16
16
  'active' => %(<span class="page active">#{pagy.page}</span> ),
17
- 'gap' => %(<span class="page gap">#{pagy_t('pagy.nav.gap')}</span> ),
18
- 'after' => p_next ? %(<span class="page next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</span>)
19
- : %(<span class="page next disabled">#{pagy_t('pagy.nav.next')}</span>) }
20
- %(<nav id="#{id}" class="pagy-nav-js pagination" role="navigation" aria-label="pager"></nav>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
17
+ 'gap' => %(<span class="page gap">#{pagy_t 'pagy.nav.gap'}</span> ),
18
+ 'after' => pagy_nav_next_html(pagy, link) }
19
+
20
+ html = %(<nav#{p_id} class="pagy-njs pagy-nav-js pagination" role="navigation" aria-label="pager"></nav>)
21
+ html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
21
22
  end
22
23
 
23
24
  # Javascript combo pagination: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
24
- def pagy_combo_nav_js(pagy, id=pagy_id)
25
- link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
26
-
27
- html = EMPTY + %(<nav id="#{id}" class="pagy-combo-nav-js pagination" role="navigation" aria-label="pager">)
28
- html << (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
29
- : %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
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;">)
31
- html << %(<span class="pagy-combo-input" style="margin: 0 0.6rem;">#{pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)}</span> )
32
- html << (p_next ? %(<span class="page next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</span>)
33
- : %(<span class="page next disabled">#{pagy_t('pagy.nav.next')}</span>))
34
- html << %(</nav>#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(TRIM) && pagy.vars[:page_param])})
25
+ def pagy_combo_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '')
26
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
27
+ p_id = %( id="#{pagy_id}") if pagy_id
28
+ link = pagy_link_proc(pagy, link_extra: link_extra)
29
+ p_page = pagy.page
30
+ p_pages = pagy.pages
31
+ 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
+
33
+ %(<nav#{p_id} class="pagy-combo-nav-js pagination" role="navigation" aria-label="pager">#{
34
+ pagy_nav_prev_html pagy, link
35
+ }<span class="pagy-combo-input" style="margin: 0 0.6rem;">#{
36
+ pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
37
+ }</span> #{
38
+ pagy_nav_next_html pagy, link
39
+ }</nav>#{
40
+ pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
41
+ })
35
42
  end
36
43
 
44
+ private
45
+
46
+ def pagy_nav_prev_html(pagy, link)
47
+ if (p_prev = pagy.prev)
48
+ %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
49
+ else
50
+ %(<span class="page prev disabled">#{pagy_t 'pagy.nav.prev'}</span> )
51
+ end
52
+ end
53
+
54
+ def pagy_nav_next_html(pagy, link)
55
+ if (p_next = pagy.next)
56
+ %(<span class="page next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</span>)
57
+ else
58
+ %(<span class="page next disabled">#{pagy_t 'pagy.nav.next'}</span>)
59
+ end
60
+ end
61
+
37
62
  end
38
63
  end
@@ -1,71 +1,73 @@
1
1
  # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/overflow
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  class Pagy
6
5
 
7
- OVERFLOW = true
6
+ module UseOverflowExtra
7
+ VARS[:overflow] = :empty_page
8
8
 
9
- VARS[:overflow] = :empty_page
9
+ def overflow? = @overflow
10
10
 
11
- def overflow?; @overflow end
12
-
13
- alias_method :initialize_without_overflow, :initialize
14
- def initialize_with_overflow(vars)
15
- @overflow ||= false # don't override if :last_page re-run the method after an overflow
16
- initialize_without_overflow(vars)
17
- rescue OverflowError
18
- @overflow = true # add the overflow flag
19
- case @vars[:overflow]
20
- when :exception
21
- raise # same as without the extra
22
- when :last_page
23
- initial_page = @vars[:page] # save the very initial page (even after re-run)
24
- initialize(vars.merge!(page: @last)) # re-run with the last page
25
- @vars[:page] = initial_page # restore the inital page
26
- when :empty_page
27
- @offset = @items = @from = @to = 0 # vars relative to the actual page
28
- @prev = @last # prev relative to the actual page
29
- extend(Series) # special series for :empty_page
30
- else
31
- raise VariableError.new(self), "expected :overflow variable in [:last_page, :empty_page, :exception]; got #{@vars[:overflow].inspect}"
11
+ def initialize(vars)
12
+ @overflow ||= false # don't override if :last_page re-run the method after an overflow
13
+ super
14
+ rescue OverflowError
15
+ @overflow = true # add the overflow flag
16
+ case @vars[:overflow]
17
+ when :exception
18
+ raise # same as without the extra
19
+ when :last_page
20
+ initial_page = @vars[:page] # save the very initial page (even after re-run)
21
+ initialize vars.merge!(page: @last) # re-run with the last page
22
+ @vars[:page] = initial_page # restore the inital page
23
+ when :empty_page
24
+ @offset = @items = @from = @to = 0 # vars relative to the actual page
25
+ @prev = @last # prev relative to the actual page
26
+ extend Series # special series for :empty_page
27
+ else
28
+ raise VariableError.new(self), "expected :overflow variable in [:last_page, :empty_page, :exception]; got #{@vars[:overflow].inspect}"
29
+ end
32
30
  end
33
- end
34
- alias_method :initialize, :initialize_with_overflow
35
31
 
36
- module Series
37
- def series(size=@vars[:size])
38
- @page = @last # series for last page
39
- super(size).tap do |s| # call original series
40
- s[s.index(@page.to_s)] = @page # string to integer (i.e. no current page)
41
- @page = @vars[:page] # restore the actual page
32
+ module Series
33
+ def series(size=@vars[:size])
34
+ @page = @last # series for last page
35
+ super(size).tap do |s| # call original series
36
+ s[s.index(@page.to_s)] = @page # string to integer (i.e. no current page)
37
+ @page = @vars[:page] # restore the actual page
38
+ end
42
39
  end
43
40
  end
41
+
44
42
  end
43
+ prepend UseOverflowExtra
45
44
 
46
45
 
47
46
  # support for Pagy::Countless
48
47
  if defined?(Pagy::Countless)
49
48
  class Countless
50
49
 
51
- alias_method :finalize_without_overflow, :finalize
52
- def finalize_with_overflow(items)
53
- @overflow = false
54
- finalize_without_overflow(items)
55
- rescue OverflowError
56
- @overflow = true # add the overflow flag
57
- case @vars[:overflow]
58
- when :exception
59
- raise # same as without the extra
60
- when :empty_page
61
- @offset = @items = @from = @to = 0 # vars relative to the actual page
62
- @vars[:size] = [] # no page in the series
63
- self
64
- else
65
- raise VariableError.new(self), "expected :overflow variable in [:empty_page, :exception]; got #{@vars[:overflow].inspect}"
50
+ module UseOverflowExtra
51
+
52
+ def finalize(items)
53
+ @overflow = false
54
+ super
55
+ rescue OverflowError
56
+ @overflow = true # add the overflow flag
57
+ case @vars[:overflow]
58
+ when :exception
59
+ raise # same as without the extra
60
+ when :empty_page
61
+ @offset = @items = @from = @to = 0 # vars relative to the actual page
62
+ @vars[:size] = [] # no page in the series
63
+ self
64
+ else
65
+ raise VariableError.new(self), "expected :overflow variable in [:empty_page, :exception]; got #{@vars[:overflow].inspect}"
66
+ end
66
67
  end
68
+
67
69
  end
68
- alias_method :finalize, :finalize_with_overflow
70
+ prepend UseOverflowExtra
69
71
 
70
72
  end
71
73
  end
@@ -1,13 +1,21 @@
1
1
  # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/searchkick
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
- require 'pagy/extras/pagy_search'
6
-
7
4
  class Pagy
8
5
 
9
- # used by the items extra
10
- SEARCHKICK = true
6
+ VARS[:searchkick_search_method] ||= :pagy_search
7
+
8
+ module Searchkick
9
+ # returns an array used to delay the call of #search
10
+ # after the pagination variables are merged to the options
11
+ # it also pushes to the same array an eventually called method
12
+ def pagy_searchkick(term = '*', **options, &block)
13
+ [self, term, options, block].tap do |args|
14
+ args.define_singleton_method(:method_missing){|*a| args += a}
15
+ end
16
+ end
17
+ alias_method VARS[:searchkick_search_method], :pagy_searchkick
18
+ end
11
19
 
12
20
  # create a Pagy object from a Searchkick::Results object
13
21
  def self.new_from_searchkick(results, vars={})
@@ -18,27 +26,30 @@ class Pagy
18
26
  end
19
27
 
20
28
  # Add specialized backend methods to paginate Searchkick::Results
21
- module Backend ; private
29
+ module Backend
30
+ private
22
31
 
23
32
  # Return Pagy object and results
24
33
  def pagy_searchkick(pagy_search_args, vars={})
25
- model, search_args, block, *called = pagy_search_args
26
- vars = pagy_searchkick_get_vars(nil, vars)
27
- search_args[-1][:per_page] = vars[:items]
28
- search_args[-1][:page] = vars[:page]
29
- results = model.search(*search_args, &block)
30
- vars[:count] = results.total_count
34
+ model, term, options, block, *called = pagy_search_args
35
+ vars = pagy_searchkick_get_vars(nil, vars)
36
+ options[:per_page] = vars[:items]
37
+ options[:page] = vars[:page]
38
+ results = model.search(term, **options, &block)
39
+ vars[:count] = results.total_count
40
+
31
41
  pagy = Pagy.new(vars)
32
42
  # with :last_page overflow we need to re-run the method in order to get the hits
33
- if defined?(OVERFLOW) && pagy.overflow? && pagy.vars[:overflow] == :last_page
34
- return pagy_searchkick(pagy_search_args, vars.merge(page: pagy.page))
35
- end
36
- return pagy, called.empty? ? results : results.send(*called)
43
+ return pagy_searchkick(pagy_search_args, vars.merge(page: pagy.page)) \
44
+ if defined?(Pagy::UseOverflowExtra) && pagy.overflow? && pagy.vars[:overflow] == :last_page
45
+
46
+ [ pagy, called.empty? ? results : results.send(*called) ]
37
47
  end
38
48
 
39
49
  # Sub-method called only by #pagy_searchkick: here for easy customization of variables by overriding
40
50
  # the _collection argument is not available when the method is called
41
51
  def pagy_searchkick_get_vars(_collection, vars)
52
+ pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
42
53
  vars[:items] ||= VARS[:items]
43
54
  vars[:page] ||= (params[ vars[:page_param] || VARS[:page_param] ] || 1).to_i
44
55
  vars
@@ -1,5 +1,4 @@
1
1
  # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/semantic
2
- # encoding: utf-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  require 'pagy/extras/shared'
@@ -8,48 +7,75 @@ class Pagy
8
7
  module Frontend
9
8
 
10
9
  # Pagination for semantic: it returns the html with the series of links to the pages
11
- def pagy_semantic_nav(pagy)
12
- link, p_prev, p_next = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next
10
+ def pagy_semantic_nav(pagy, pagy_id: nil, link_extra: '')
11
+ p_id = %( id="#{pagy_id}") if pagy_id
12
+ link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}"))
13
13
 
14
- html = EMPTY + (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
15
- : %(<div class="item disabled"><i class="left small chevron icon"></i></div>))
14
+ html = +%(<div#{p_id} class="pagy-semantic-nav ui pagination menu" aria-label="pager">)
15
+ html << pagy_semantic_prev_html(pagy, link)
16
16
  pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
17
- html << if item.is_a?(Integer); %(#{link.call item}) # page link
18
- elsif item.is_a?(String) ; %(<a class="item active">#{item}</a>) # current page
19
- elsif item == :gap ; %(<div class="disabled item">...</div>) # page gap
17
+ html << case item
18
+ when Integer then link.call item # page link
19
+ when String then %(<a class="item active">#{item}</a>) # current page
20
+ when :gap then %(<div class="disabled item">#{pagy_t 'pagy.nav.gap'}</div>) # page gap
20
21
  end
21
22
  end
22
- html << (p_next ? %(#{link.call p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"'})
23
- : %(<div class="item disabled"><i class="right small chevron icon"></i></div>))
24
- %(<div class="pagy-semantic-nav ui pagination menu" aria-label="pager">#{html}</div>)
23
+ html << pagy_semantic_next_html(pagy, link)
24
+ html << %(</div>)
25
25
  end
26
26
 
27
27
  # Javascript pagination for semantic: it returns a nav and a JSON tag used by the Pagy.nav javascript
28
- def pagy_semantic_nav_js(pagy, id=pagy_id)
29
- link, p_prev, p_next = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next
30
- tags = { 'before' => (p_prev ? %(#{link.call(p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"')})
31
- : %(<div class="item disabled"><i class="left small chevron icon"></i></div>)),
32
- 'link' => %(#{link.call(PAGE_PLACEHOLDER)}),
28
+ def pagy_semantic_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '', steps: nil)
29
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
30
+ p_id = %( id="#{pagy_id}") if pagy_id
31
+ link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
32
+ tags = { 'before' => pagy_semantic_prev_html(pagy, link),
33
+ 'link' => link.call(PAGE_PLACEHOLDER),
33
34
  'active' => %(<a class="item active">#{pagy.page}</a>),
34
35
  'gap' => %(<div class="disabled item">#{pagy_t('pagy.nav.gap')}</div>),
35
- 'after' => (p_next ? %(#{link.call(p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"')})
36
- : %(<div class="item disabled"><i class="right small chevron icon"></i></div>)) }
37
- %(<div id="#{id}" class="pagy-semantic-nav-js ui pagination menu" role="navigation" aria-label="pager"></div>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
36
+ 'after' => pagy_semantic_next_html(pagy, link) }
37
+
38
+ html = %(<div#{p_id} class="pagy-njs pagy-semantic-nav-js ui pagination menu" role="navigation" aria-label="pager"></div>)
39
+ html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
38
40
  end
39
41
 
40
42
  # Combo pagination for semantic: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
41
- def pagy_semantic_combo_nav_js(pagy, id=pagy_id)
42
- link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next, pagy.page, pagy.pages
43
-
44
- html = EMPTY + %(<div id="#{id}" class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" aria-label="pager">)
45
- html << (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
46
- : %(<div class="item disabled"><i class="left small chevron icon"></i></div>))
47
- 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">)
48
- html << %(<div class="pagy-combo-input item">#{pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)}</div> )
49
- html << (p_next ? %(#{link.call p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"'})
50
- : %(<div class="item disabled"><i class="right small chevron icon"></i></div>))
51
- html << %(</div>#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(TRIM) && pagy.vars[:page_param])})
43
+ def pagy_semantic_combo_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '')
44
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
45
+ p_id = %( id="#{pagy_id}") if pagy_id
46
+ link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
47
+ p_page = pagy.page
48
+ p_pages = pagy.pages
49
+ 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
+
51
+ %(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" aria-label="pager">#{
52
+ pagy_semantic_prev_html pagy, link
53
+ }<div class="pagy-combo-input item">#{
54
+ pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
55
+ }</div> #{
56
+ pagy_semantic_next_html pagy, link
57
+ }</div>#{
58
+ pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
59
+ })
52
60
  end
53
61
 
62
+ private
63
+
64
+ def pagy_semantic_prev_html(pagy, link)
65
+ if (p_prev = pagy.prev)
66
+ link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'
67
+ else
68
+ +%(<div class="item disabled"><i class="left small chevron icon"></i></div>)
69
+ end
70
+ end
71
+
72
+ def pagy_semantic_next_html(pagy, link)
73
+ if (p_next = pagy.next)
74
+ link.call p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"'
75
+ else
76
+ +%(<div class="item disabled"><i class="right small chevron icon"></i></div>)
77
+ end
78
+ end
79
+
54
80
  end
55
81
  end