def navigation(limit = 8)
g = Ramaze::Gestalt.new
g.div :class => :pager do
if first_page?
g.span(:class => 'first grey'){ h('<<') }
g.span(:class => 'previous grey'){ h('<') }
else
link(g, 1, '<<', :class => :first)
link(g, prev_page, '<', :class => :previous)
end
lower = limit ? (current_page - limit) : 1
lower = lower < 1 ? 1 : lower
(lower...current_page).each do |n|
link(g, n)
end
link(g, current_page, current_page, :class => :current)
if last_page?
g.span(:class => 'next grey'){ h('>') }
g.span(:class => 'last grey'){ h('>>') }
elsif next_page
higher = limit ? (next_page + limit) : page_count
higher = [higher, page_count].min
(next_page..higher).each do |n|
link(g, n)
end
link(g, next_page, '>', :class => :next)
link(g, page_count, '>>', :class => :last)
end
end
g.to_s
end