diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb index 5951579..2fb9642 100644 --- a/app/views/kaminari/_first_page.html.erb +++ b/app/views/kaminari/_first_page.html.erb @@ -7,5 +7,5 @@ remote: data-remote -%> - <%= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :rel => (current_page == 2) ? 'start prev':'start', :remote => remote %> + <%= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :remote => remote %> diff --git a/app/views/kaminari/_first_page.html.haml b/app/views/kaminari/_first_page.html.haml index 7ec6648..e40501d 100644 --- a/app/views/kaminari/_first_page.html.haml +++ b/app/views/kaminari/_first_page.html.haml @@ -6,4 +6,4 @@ per_page: number of items to fetch per page remote: data-remote %span{:class => "first#{' disabled' if current_page == 1}"} - = link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :rel => (current_page == 2) ? 'start prev':'start', :remote => remote + = link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :remote => remote diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb index 5a4f80d..5791bf0 100644 --- a/app/views/kaminari/_last_page.html.erb +++ b/app/views/kaminari/_last_page.html.erb @@ -7,6 +7,5 @@ remote: data-remote -%> - <% opts = {:remote => remote}; opts[:rel] = 'next' if current_page == num_pages - 1 %> - <%= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, opts %> + <%= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote} %> diff --git a/app/views/kaminari/_last_page.html.haml b/app/views/kaminari/_last_page.html.haml index 1e5f6e4..971b051 100644 --- a/app/views/kaminari/_last_page.html.haml +++ b/app/views/kaminari/_last_page.html.haml @@ -6,6 +6,4 @@ per_page: number of items to fetch per page remote: data-remote %span{:class => "last#{' disabled' if current_page == num_pages}"} - - opts = {:remote => remote}; - - opts[:rel] = 'next' if current_page == num_pages - 1 - = link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, opts + = link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote} diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb index 40709de..ff3cec5 100644 --- a/app/views/kaminari/_page.html.erb +++ b/app/views/kaminari/_page.html.erb @@ -8,11 +8,5 @@ remote: data-remote -%> - <% - opts = {:remote => remote} - opts[:rel] = 'start' if page.first? - opts[:rel] = 'next' if page.number == current_page + 1 - opts[:rel] = opts[:rel].nil? ? 'prev' : opts[:rel] + ' prev' if page.number == current_page - 1 - %> - <%= link_to_unless page.current?, page, url, opts %> + <%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> diff --git a/app/views/kaminari/_page.html.haml b/app/views/kaminari/_page.html.haml index 37c0063..5f78fed 100644 --- a/app/views/kaminari/_page.html.haml +++ b/app/views/kaminari/_page.html.haml @@ -6,10 +6,5 @@ num_pages: total number of pages per_page: number of items to fetch per page remote: data-remote - %span{:class => "page#{' current' if page.current?}"} - - opts = {:remote => remote} - - opts[:rel] = 'start' if page.first? - - opts[:rel] = 'next' if page.number == current_page + 1 - - opts[:rel] = opts[:rel].nil? ? 'prev' : opts[:rel] + ' prev' if page.number == current_page - 1 - = link_to_unless page.current?, page, url, opts + = link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb index f489438..c412cc3 100644 --- a/app/views/kaminari/_prev_page.html.erb +++ b/app/views/kaminari/_prev_page.html.erb @@ -7,5 +7,5 @@ remote: data-remote -%> - <%= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => (current_page == 2) ? 'start prev':'prev', :remote => remote %> + <%= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %> diff --git a/app/views/kaminari/_prev_page.html.haml b/app/views/kaminari/_prev_page.html.haml index 7988a66..0d7e24b 100644 --- a/app/views/kaminari/_prev_page.html.haml +++ b/app/views/kaminari/_prev_page.html.haml @@ -6,4 +6,4 @@ per_page: number of items to fetch per page remote: data-remote %span{:class => "prev#{' disabled' if current_page == 1}"} - = link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => (current_page == 2) ? 'start prev':'prev', :remote => remote + = link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote diff --git a/lib/kaminari/helpers/tags.rb b/lib/kaminari/helpers/tags.rb index 6629f4c..b32125c 100644 --- a/lib/kaminari/helpers/tags.rb +++ b/lib/kaminari/helpers/tags.rb @@ -134,6 +134,16 @@ module Kaminari @page == @options[:num_pages] end + # the previous page or not + def prev? + @page == @options[:current_page] - 1 + end + + # the next page or not + def next? + @page == @options[:current_page] + 1 + end + # within the left outer window or not def left_outer? @page <= @options[:left]