diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index e356926..4671500 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -12,7 +12,13 @@ <% if page.current? -%> <%= current_page_tag %> <% elsif page.left_outer? || page.right_outer? || page.inside_window? -%> - <%= page_link_tag %> + <% if page.first? -%> + <%= first_page_link_tag %> + <% elsif page.last? -%> + <%= last_page_link_tag %> + <% else -%> + <%= page_link_tag %> + <% end -%> <% elsif !page.was_truncated? -%> <%= truncated_span_tag %> <% end -%> diff --git a/app/views/kaminari/_paginator.html.haml b/app/views/kaminari/_paginator.html.haml index 1c6e481..cb62fca 100644 --- a/app/views/kaminari/_paginator.html.haml +++ b/app/views/kaminari/_paginator.html.haml @@ -11,7 +11,12 @@ - if page.current? = current_page_tag - elsif page.left_outer? || page.right_outer? || page.inside_window? - = page_link_tag + - if page.first? + = first_page_link_tag + - elsif page.last? + = last_page_link_tag + - else + = page_link_tag - elsif !page.was_truncated? = truncated_span_tag = num_pages > current_page ? next_link_tag : next_span_tag diff --git a/lib/kaminari/helpers.rb b/lib/kaminari/helpers.rb index 7531c90..4d7496b 100644 --- a/lib/kaminari/helpers.rb +++ b/lib/kaminari/helpers.rb @@ -13,19 +13,12 @@ module Kaminari @left, @window, @right = (options[:left] || options[:outer_window] || 1), (options[:window] || options[:inner_window] || 4), (options[:right] || options[:outer_window] || 1) end - def current_page_tag - @last = CurrentPage.new self, :page => @page - end - - def page_link_tag - @last = case @page - when 1 - FirstPageLink - when @options[:num_pages] - LastPageLink - else - PageLink - end.new self, :page => @page + %w[current_page first_page_link last_page_link page_link].each do |tag| + eval <<-DEF + def #{tag}_tag + @last = #{tag.classify}.new self, :page => @page + end + DEF end %w[prev_link prev_span next_link next_span truncated_span].each do |tag| @@ -109,6 +102,14 @@ module Kaminari @page == @renderer.options[:current_page] end + def first? + @page == 1 + end + + def last? + @page == @renderer.options[:num_pages] + end + def left_outer? @page <= @renderer.left + 1 end