module PaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
def link(text, target, attributes = {})
attributes["data-remote"] = true if @options[:remote]
super
end
def pagination
items = @options[:page_links] ? windowed_page_numbers : []
items.unshift :first_page, :previous_page
items.push :next_page, :last_page
end
# The container_attributes method must be overridden to prevent custom options being output as HTML attributes for the pagination container.
def container_attributes
super.except(:first_label, :last_label)
end
# A first_page method that handles the generation of HTML for the first page link.
def first_page
previous_or_next_page(current_page == 1 ? nil : 1, @options[:first_label], "first_page")
end
# A last_page method that handles the generation of HTML for the last page link.
def last_page
previous_or_next_page(current_page == total_pages ? nil : total_pages, @options[:last_label], "last_page")
end
end
end