/usr/lib/ruby/1.8/ramaze/helper/sequel.rb is in libramaze-ruby1.8 2010.06.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.
module Ramaze
module Helper::Sequel
# Very crude paginator, may contain serious bugs, please fix :)
# pass it the result of YourModel.paginate, target is where links point to.
def paginator(paginated, target)
page_count = paginated.page_count
prev_page = paginated.prev_page
current_page = paginated.current_page
next_page = paginated.next_page
lower = (current_page - 3).abs
lower = lower == 0 ? 1 : lower
out = ['<div class="paginator">']
if prev_page
out << %(<a class="paginator_prev" href="#{Rs(target, prev_page)}">< Prev</a>)
else
out << %(<span class="paginator_prev">< Prev</span>)
end
if current_page > 3
out << %(<a class="paginator_page" href="#{Rs(target, 1)}">#{1}</a> ... )
end
lower.upto(current_page) do |pc|
next if pc == current_page
out << %(<a class="paginator_page" href="#{Rs(target, pc)}">#{pc}</a>)
end
out << %(<span class="paginator_current">#{current_page}</span>)
current_page.upto([page_count, current_page + 3].min) do |pc|
next if pc == current_page
out << %(<a class="paginator_page" href="#{Rs(target, pc)}">#{pc}</a>)
end
if current_page < (page_count - 3)
out << %(.. <a class="paginator_page" href="#{Rs(target, page_count)}">#{page_count}</a>)
end
if next_page
out << %(<a class="paginator_next" href="#{Rs(target, next_page)}">Next ></a>)
else
out << %(<span class="paginator_next">Next ></span>)
end
out << '</div>'
out.join(" ")
end
end
end
|