Skip to content

Commit

Permalink
normalization of indentation and empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernie Chiu authored and ddnexus committed Jun 19, 2018
1 parent 9afa9d9 commit 4449c95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib/pagy/extras/responsive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def pagy_nav_responsive(pagy, id=caller(1,1)[0].hash)
%(<nav id="pagy-nav-#{id}" class="pagy-nav-responsive pagination" role="navigation" aria-label="pager"></nav>#{script})
end


# Responsive pagination for bootstrap: it returns the html with the series of links to the pages
# we build the tags as a json object string and render them with the PagyResponsive javascript
def pagy_nav_bootstrap_responsive(pagy, id=caller(1,1)[0].hash)
Expand Down
10 changes: 3 additions & 7 deletions lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,32 @@ def pagy_nav(pagy)
tags << (p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
tags << if item.is_a?(Integer); %(<span class="page">#{link.call item}</span> ) # page link
elsif item.is_a?(String) ; %(<span class="page active">#{item}</span> ) # current page
elsif item == :gap ; %(<span class="page gap">#{pagy_t('pagy.nav.gap')}</span> ) # page gap
tags << if item.is_a?(Integer); %(<span class="page">#{link.call item}</span> ) # page link
elsif item.is_a?(String) ; %(<span class="page active">#{item}</span> ) # current page
elsif item == :gap ; %(<span class="page gap">#{pagy_t('pagy.nav.gap')}</span> ) # page gap
end
end
tags << (p_next ? %(<span class="page next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</span>)
: %(<span class="page next disabled">#{pagy_t('pagy.nav.next')}</span>))
%(<nav class="pagy-nav pagination" role="navigation" aria-label="pager">#{tags}</nav>)
end


# Return examples: "Displaying items 41-60 of 324 in total" or "Displaying Products 41-60 of 324 in total"
def pagy_info(pagy)
name = pagy_t(pagy.vars[:item_path], count: pagy.count)
path = pagy.pages == 1 ? 'pagy.info.single_page' : 'pagy.info.multiple_pages'
pagy_t(path, item_name: name, count: pagy.count, from: pagy.from, to: pagy.to)
end


# this works with all Rack-based frameworks (Sinatra, Padrino, Rails, ...)
def pagy_url_for(page, pagy)
p_vars = pagy.vars; params = request.GET.merge(p_vars[:page_param] => page, **p_vars[:params])
"#{request.path}?#{Rack::Utils.build_nested_query(pagy_get_params(params))}#{p_vars[:anchor]}"
end


# Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
def pagy_get_params(params) params end


MARKER = "-pagy-#{'pagy'.hash}-"

# Returns a performance optimized proc to generate the HTML links
Expand Down

0 comments on commit 4449c95

Please sign in to comment.