From 4beef97cea509207712c6d7b1da41ad7d9bcd99c Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 25 Feb 2011 10:35:21 +0900 Subject: [PATCH] fixes #28 a page can be both current and first or last merge _current_page, _first_page_link, _last_page_link and _page_link into one _page partial --- app/views/kaminari/_current_page.html.erb | 9 --- app/views/kaminari/_current_page.html.haml | 9 --- app/views/kaminari/_first_page_link.html.erb | 12 --- app/views/kaminari/_first_page_link.html.haml | 10 --- app/views/kaminari/_last_page_link.html.erb | 12 --- app/views/kaminari/_last_page_link.html.haml | 10 --- .../{_page_link.html.erb => _page.html.erb} | 4 +- .../{_page_link.html.haml => _page.html.haml} | 4 +- app/views/kaminari/_paginator.html.erb | 12 +-- app/views/kaminari/_paginator.html.haml | 11 +-- lib/kaminari/helpers/tags.rb | 75 ++++++++----------- spec/helpers/tags_spec.rb | 24 ++---- 12 files changed, 44 insertions(+), 148 deletions(-) delete mode 100644 app/views/kaminari/_current_page.html.erb delete mode 100644 app/views/kaminari/_current_page.html.haml delete mode 100644 app/views/kaminari/_first_page_link.html.erb delete mode 100644 app/views/kaminari/_first_page_link.html.haml delete mode 100644 app/views/kaminari/_last_page_link.html.erb delete mode 100644 app/views/kaminari/_last_page_link.html.haml rename app/views/kaminari/{_page_link.html.erb => _page.html.erb} (64%) rename app/views/kaminari/{_page_link.html.haml => _page.html.haml} (65%) diff --git a/app/views/kaminari/_current_page.html.erb b/app/views/kaminari/_current_page.html.erb deleted file mode 100644 index 2ad52b1..0000000 --- a/app/views/kaminari/_current_page.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%# The current page - - available local variables - page: the page number of this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote --%> -<%= page %> diff --git a/app/views/kaminari/_current_page.html.haml b/app/views/kaminari/_current_page.html.haml deleted file mode 100644 index ff94f26..0000000 --- a/app/views/kaminari/_current_page.html.haml +++ /dev/null @@ -1,9 +0,0 @@ --# The current page - - available local variables - page: the page number of this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote -%span.page.current - = page diff --git a/app/views/kaminari/_first_page_link.html.erb b/app/views/kaminari/_first_page_link.html.erb deleted file mode 100644 index 0314b8f..0000000 --- a/app/views/kaminari/_first_page_link.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Link with page number that appears at the leftmost - - available local variables - page: the page number of this page - url: url to this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote --%> - - <%= link_to page, url, :remote => remote %> - diff --git a/app/views/kaminari/_first_page_link.html.haml b/app/views/kaminari/_first_page_link.html.haml deleted file mode 100644 index 418388a..0000000 --- a/app/views/kaminari/_first_page_link.html.haml +++ /dev/null @@ -1,10 +0,0 @@ --# Link with page number that appears at the leftmost - - available local variables - page: the page number of this page - url: url to this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote -%span.page.first - = link_to page, url, :remote => remote diff --git a/app/views/kaminari/_last_page_link.html.erb b/app/views/kaminari/_last_page_link.html.erb deleted file mode 100644 index c9800bf..0000000 --- a/app/views/kaminari/_last_page_link.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%# Link with page number that appears at the rightmost - - available local variables - page: the page number of this page - url: url to this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote --%> - - <%= link_to page, url, :remote => remote %> - diff --git a/app/views/kaminari/_last_page_link.html.haml b/app/views/kaminari/_last_page_link.html.haml deleted file mode 100644 index 138a6d5..0000000 --- a/app/views/kaminari/_last_page_link.html.haml +++ /dev/null @@ -1,10 +0,0 @@ --# Link with page number that appears at the rightmost - - available local variables - page: the page number of this page - url: url to this page - current_page: the page number of currently displayed page - num_pages: total number of pages - per_page: number of items to fetch per page - remote: data-remote -%span.page.last - = link_to page, url, :remote => remote diff --git a/app/views/kaminari/_page_link.html.erb b/app/views/kaminari/_page.html.erb similarity index 64% rename from app/views/kaminari/_page_link.html.erb rename to app/views/kaminari/_page.html.erb index a6deffb..6a00dae 100644 --- a/app/views/kaminari/_page_link.html.erb +++ b/app/views/kaminari/_page.html.erb @@ -7,6 +7,6 @@ per_page: number of items to fetch per page remote: data-remote -%> - - <%= link_to page, url, :remote => remote %> + + <%= link_to_unless page == current_page, page, url, :remote => remote %> diff --git a/app/views/kaminari/_page_link.html.haml b/app/views/kaminari/_page.html.haml similarity index 65% rename from app/views/kaminari/_page_link.html.haml rename to app/views/kaminari/_page.html.haml index f3dda88..2fda729 100644 --- a/app/views/kaminari/_page_link.html.haml +++ b/app/views/kaminari/_page.html.haml @@ -6,5 +6,5 @@ num_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%span.page - = link_to page, url, :remote => remote +%span{:class => "page#{' first' if page.first?}#{' last' if page.last?}#{' current' if page.current?}"} + = link_to_unless page == current_page, page, url, :remote => remote diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index 195fe5c..5b50206 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -10,16 +10,8 @@