Module: Staticpress::Plugins::Pagination
- Defined in:
- lib/staticpress/plugins/pagination.rb
Instance Method Summary collapse
- #pagination_item(text, number, is_current) ⇒ Object
- #pagination_menu(current_number, menu_options = {}) ⇒ Object
Instance Method Details
#pagination_item(text, number, is_current) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/staticpress/plugins/pagination.rb', line 24 def pagination_item(text, number, is_current) tag :li do if is_current tag :span, :class => 'current-page' do text end else tag :a, :href => "/page/#{number}" do text end end end end |
#pagination_menu(current_number, menu_options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/staticpress/plugins/pagination.rb', line 5 def (current_number, = {}) tag :menu, { :type => :toolbar }.merge() do numbered_pages = Staticpress::Content::Index.published.map do |page| number = page.params[:number] pagination_item number, number, number == current_number end.join first_page = 1 last_page = Staticpress::Content::Index.published.count oldest_page = pagination_item 'Oldest', first_page, current_number == first_page older_page = pagination_item 'Older', current_number - 1, current_number <= first_page newer_page = pagination_item 'Newer', current_number + 1, current_number >= last_page newest_page = pagination_item 'Newest', last_page, current_number == last_page oldest_page + older_page + numbered_pages + newer_page + newest_page end end |