kaminari 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kaminari might be problematic. Click here for more details.

Files changed (58) hide show
  1. data/VERSION +1 -1
  2. data/app/views/kaminari/_current_page.html.erb +7 -7
  3. data/app/views/kaminari/_current_page.html.haml +7 -7
  4. data/app/views/kaminari/_first_page_link.html.erb +9 -8
  5. data/app/views/kaminari/_first_page_link.html.haml +9 -8
  6. data/app/views/kaminari/_last_page_link.html.erb +9 -8
  7. data/app/views/kaminari/_last_page_link.html.haml +9 -8
  8. data/app/views/kaminari/_next_link.html.erb +8 -7
  9. data/app/views/kaminari/_next_link.html.haml +8 -7
  10. data/app/views/kaminari/_next_span.html.erb +6 -5
  11. data/app/views/kaminari/_next_span.html.haml +6 -5
  12. data/app/views/kaminari/_page_link.html.erb +9 -8
  13. data/app/views/kaminari/_page_link.html.haml +9 -8
  14. data/app/views/kaminari/_paginator.html.erb +6 -5
  15. data/app/views/kaminari/_paginator.html.haml +6 -5
  16. data/app/views/kaminari/_prev_link.html.erb +8 -7
  17. data/app/views/kaminari/_prev_link.html.haml +8 -7
  18. data/app/views/kaminari/_prev_span.html.erb +6 -5
  19. data/app/views/kaminari/_prev_span.html.haml +6 -5
  20. data/app/views/kaminari/_truncated_span.html.erb +6 -5
  21. data/app/views/kaminari/_truncated_span.html.haml +6 -5
  22. data/app/views/kaminari/github/_current_page.html.erb +0 -8
  23. data/app/views/kaminari/github/_current_page.html.haml +0 -7
  24. data/app/views/kaminari/github/_next_link.html.erb +1 -8
  25. data/app/views/kaminari/github/_next_link.html.haml +1 -7
  26. data/app/views/kaminari/github/_next_span.html.erb +0 -6
  27. data/app/views/kaminari/github/_next_span.html.haml +0 -5
  28. data/app/views/kaminari/github/_page_link.html.erb +0 -8
  29. data/app/views/kaminari/github/_page_link.html.haml +0 -7
  30. data/app/views/kaminari/github/_paginator.html.erb +0 -6
  31. data/app/views/kaminari/github/_paginator.html.haml +0 -5
  32. data/app/views/kaminari/github/_prev_link.html.erb +1 -8
  33. data/app/views/kaminari/github/_prev_link.html.haml +1 -7
  34. data/app/views/kaminari/github/_prev_span.html.erb +0 -6
  35. data/app/views/kaminari/github/_prev_span.html.haml +0 -5
  36. data/app/views/kaminari/github/_truncated_span.html.erb +0 -6
  37. data/app/views/kaminari/github/_truncated_span.html.haml +0 -5
  38. data/app/views/kaminari/google/_current_page.html.erb +0 -8
  39. data/app/views/kaminari/google/_current_page.html.haml +0 -7
  40. data/app/views/kaminari/google/_next_link.html.erb +1 -8
  41. data/app/views/kaminari/google/_next_link.html.haml +1 -7
  42. data/app/views/kaminari/google/_next_span.html.erb +0 -6
  43. data/app/views/kaminari/google/_next_span.html.haml +0 -5
  44. data/app/views/kaminari/google/_page_link.html.erb +1 -9
  45. data/app/views/kaminari/google/_page_link.html.haml +1 -8
  46. data/app/views/kaminari/google/_paginator.html.erb +0 -6
  47. data/app/views/kaminari/google/_paginator.html.haml +0 -5
  48. data/app/views/kaminari/google/_prev_link.html.erb +1 -8
  49. data/app/views/kaminari/google/_prev_link.html.haml +1 -7
  50. data/app/views/kaminari/google/_prev_span.html.erb +0 -6
  51. data/app/views/kaminari/google/_prev_span.html.haml +0 -5
  52. data/app/views/kaminari/google/_truncated_span.html.erb +0 -6
  53. data/app/views/kaminari/google/_truncated_span.html.haml +0 -5
  54. data/kaminari.gemspec +3 -1
  55. data/lib/kaminari/helpers.rb +17 -6
  56. data/lib/kaminari/tags.rb +67 -28
  57. data/spec/helpers/tags_spec.rb +26 -0
  58. metadata +5 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 0.9.4
@@ -1,9 +1,9 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ <%# The current page
2
+ - available local variables
3
+ page: the page number of this page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
8
  -%>
9
9
  <span class="page current"><%= page %></span>
@@ -1,9 +1,9 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ -# The current page
2
+ - available local variables
3
+ page: the page number of this page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
8
8
  %span.page.current
9
9
  = page
@@ -1,11 +1,12 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ <%# Link with page number that appears at the leftmost
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  -%>
9
10
  <span class="page first">
10
- <%= link_to page, page_url, :remote => remote %>
11
+ <%= link_to page, url, :remote => remote %>
11
12
  </span>
@@ -1,9 +1,10 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ -# Link with page number that appears at the leftmost
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  %span.page.first
9
- = link_to page, page_url, :remote => remote
10
+ = link_to page, url, :remote => remote
@@ -1,11 +1,12 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ <%# Link with page number that appears at the rightmost
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  -%>
9
10
  <span class="page last">
10
- <%= link_to page, page_url, :remote => remote %>
11
+ <%= link_to page, url, :remote => remote %>
11
12
  </span>
@@ -1,9 +1,10 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ -# Link with page number that appears at the rightmost
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  %span.page.last
9
- = link_to page, page_url, :remote => remote
10
+ = link_to page, url, :remote => remote
@@ -1,10 +1,11 @@
1
- <%# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
1
+ <%# "Next" with link
2
+ - available local variables
3
+ url: url to the next page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
7
8
  -%>
8
9
  <span class="next">
9
- <%= link_to raw('Next &raquo;'), next_url, :class => 'next', :rel => 'next', :remote => remote %>
10
+ <%= link_to raw('Next &raquo;'), url, :class => 'next', :rel => 'next', :remote => remote %>
10
11
  </span>
@@ -1,8 +1,9 @@
1
- -# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
1
+ -# "Next" with link
2
+ - available local variables
3
+ url: url to the next page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
7
8
  %span.next
8
- = link_to raw('Next &raquo;'), next_url, :class => 'next', :rel => 'next', :remote => remote
9
+ = link_to raw('Next &raquo;'), url, :class => 'next', :rel => 'next', :remote => remote
@@ -1,7 +1,8 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ <%# "Next" without link
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  -%>
7
8
  <span class="next"></span>
@@ -1,6 +1,7 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ -# "Next" without link
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  %span.next
@@ -1,11 +1,12 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ <%# Link showing page number
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  -%>
9
10
  <span class="page">
10
- <%= link_to page, page_url, :remote => remote %>
11
+ <%= link_to page, url, :remote => remote %>
11
12
  </span>
@@ -1,9 +1,10 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
1
+ -# Link showing page number
2
+ - available local variables
3
+ page: the page number of this page
4
+ url: url to this page
5
+ current_page: the page number of currently displayed page
6
+ num_pages: total number of pages
7
+ per_page: number of items to fetch per page
8
+ remote: data-remote
8
9
  %span.page
9
- = link_to page, page_url, :remote => remote
10
+ = link_to page, url, :remote => remote
@@ -1,8 +1,9 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ <%# The container tag
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  -%>
7
8
  <nav class='pagination'>
8
9
  <%= content_for :kaminari_paginator_tags %>
@@ -1,7 +1,8 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ -# The container tag
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  %nav.pagination
7
8
  = content_for :kaminari_paginator_tags
@@ -1,10 +1,11 @@
1
- <%# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
1
+ <%# "Previous" with link
2
+ - available local variables
3
+ url: url to the previous page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
7
8
  -%>
8
9
  <span class="prev">
9
- <%= link_to raw('&laquo; Prev'), prev_url, :class => 'prev', :rel => 'prev', :remote => remote %>
10
+ <%= link_to raw('&laquo; Prev'), url, :class => 'prev', :rel => 'prev', :remote => remote %>
10
11
  </span>
@@ -1,8 +1,9 @@
1
- -# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
1
+ -# "Previous" with link
2
+ - available local variables
3
+ url: url to the previous page
4
+ current_page: the page number of currently displayed page
5
+ num_pages: total number of pages
6
+ per_page: number of items to fetch per page
7
+ remote: data-remote
7
8
  %span.prev
8
- = link_to raw('&laquo; Prev'), prev_url, :class => 'prev', :rel => 'prev', :remote => remote
9
+ = link_to raw('&laquo; Prev'), url, :class => 'prev', :rel => 'prev', :remote => remote
@@ -1,7 +1,8 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ <%# "Previous" without link
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  -%>
7
8
  <span class="prev"></span>
@@ -1,6 +1,7 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ -# "Previous" without link
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  %span.prev
@@ -1,7 +1,8 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ <%# Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  -%>
7
8
  <span class="page">...</span>
@@ -1,7 +1,8 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
1
+ -# Non-link tag that stands for skipped pages...
2
+ - available local variables
3
+ current_page: the page number of currently displayed page
4
+ num_pages: total number of pages
5
+ per_page: number of items to fetch per page
6
+ remote: data-remote
6
7
  %span.page
7
8
  \...
@@ -1,9 +1 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
- -%>
9
1
  <%# EMPTY! %>
@@ -1,8 +1 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
1
  -# EMPTY!
@@ -1,8 +1 @@
1
- <%# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- -%>
8
- <%= link_to raw('Older &raquo;'), next_url, :remote => remote -%>
1
+ <%= link_to raw('Older &raquo;'), url, :remote => remote -%>
@@ -1,7 +1 @@
1
- -# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- ~ link_to raw('Older &raquo;'), next_url, :remote => remote
1
+ ~ link_to raw('Older &raquo;'), url, :remote => remote
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <span class="disabled">Older &raquo;</span>
@@ -1,6 +1 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  <span class="disabled">Older &raquo;</span>
@@ -1,9 +1 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
- -%>
9
1
  <%# EMPTY! %>
@@ -1,8 +1 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
1
  -# EMPTY!
@@ -1,9 +1,3 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <style>
8
2
  .pagination{padding:.3em;margin:.3em; font: 13.34px helvetica,arial,freesans,clean,sans-serif;}
9
3
  .pagination a{padding:.1em .3em;margin:.2em;border:1px solid #aad;text-decoration:none;color:#369;}
@@ -1,8 +1,3 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  :css
7
2
  .pagination{padding:.3em;margin:.3em; font: 13.34px helvetica,arial,freesans,clean,sans-serif;}
8
3
  .pagination a{padding:.1em .3em;margin:.2em;border:1px solid #aad;text-decoration:none;color:#369;}
@@ -1,8 +1 @@
1
- <%# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- -%>
8
- <%= link_to raw('&laquo; Newer'), prev_url, :remote => remote -%>
1
+ <%= link_to raw('&laquo; Newer'), url, :remote => remote -%>
@@ -1,7 +1 @@
1
- -# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- ~ link_to raw('&laquo; Newer'), prev_url, :remote => remote
1
+ ~ link_to raw('&laquo; Newer'), url, :remote => remote
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <%= content_tag :span, raw('&laquo; Newer'), :class => 'disabled' -%>
@@ -1,6 +1 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  ~ content_tag :span, raw('&laquo; Newer'), :class => 'disabled'
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <%# EMPTY! %>
@@ -1,6 +1 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  -# EMPTY!
@@ -1,9 +1 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
- -%>
9
1
  <td class="cur"><span class="csb" style="background-position:-53px 0;width:20px"></span><%= page %></td>
@@ -1,10 +1,3 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
1
  %td.cur
9
2
  %span.csb{:style => 'background-position:-53px 0;width:20px'}
10
3
  = page
@@ -1,8 +1 @@
1
- <%# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- -%>
8
- <td class="b"><%= link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), next_url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote %></td>
1
+ <td class="b"><%= link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote %></td>
@@ -1,8 +1,2 @@
1
- -# available local variables:
2
- next_url: url to the next page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
1
  %td.b
8
- = link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), next_url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote
2
+ = link_to raw('<span class="csb ch" style="background-position:-96px 0;width:71px"></span><span style="display:block;margin-left:53px;text-decoration:underline">Next</span>'), url, :class => 'pn knavi', :id => 'pnnext', :style => 'text-align:left;text-decoration:none', :remote => remote
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <td class="b"><span class="csb" style="background-position:-96px 0;width:45px"></span></td>
@@ -1,7 +1,2 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  %td.b
7
2
  %span.csb{:style => 'background-position:-96px 0;width:45px'}
@@ -1,9 +1 @@
1
- <%# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
- -%>
9
- <td><%= link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), page_url, :class => 'fl', :remote => remote %></td>
1
+ <td><%= link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), url, :class => 'fl', :remote => remote %></td>
@@ -1,9 +1,2 @@
1
- -# available local variables:
2
- page: the page number of this page
3
- page_url: url to this page
4
- current_page: the page number of currently displayed page
5
- num_pages: total number of pages
6
- per_page: number of items to fetch per page
7
- remote: data-remote
8
1
  %td
9
- = link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), page_url, :class => 'fl', :remote => remote
2
+ = link_to raw(%Q[<span class="csb ch" style="background-position:-74px 0;width:20px"></span>#{page}]), url, :class => 'fl', :remote => remote
@@ -1,9 +1,3 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <style>
8
2
  #nav a{display:block}
9
3
  #nav td{padding:0;text-align:center}
@@ -1,8 +1,3 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  :css
7
2
  #nav a{display:block}
8
3
  #nav td{padding:0;text-align:center}
@@ -1,8 +1 @@
1
- <%# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
- -%>
8
- <td class="b"><%= link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), prev_url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote %></td>
1
+ <td class="b"><%= link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote %></td>
@@ -1,8 +1,2 @@
1
- -# available local variables:
2
- prev_url: url to the previous page
3
- current_page: the page number of currently displayed page
4
- num_pages: total number of pages
5
- per_page: number of items to fetch per page
6
- remote: data-remote
7
1
  %td.b
8
- = link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), prev_url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote
2
+ = link_to raw('<span class="csb ch" style="background-position:0 0;float:right;width:53px"></span><span style="display:block;margin-right:35px;clear:right;text-decoration:underline">Previous</span>'), url, :class => 'pn knavi', :id => 'pnprev', :style => 'text-decoration:none', :remote => remote
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <td class="b"><span class="csb" style="background-position:-24px 0;width:28px"></span></td>
@@ -1,7 +1,2 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  %td.b
7
2
  %span.csb{:style => 'background-position:-24px 0;width:28px'}
@@ -1,7 +1 @@
1
- <%# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
- -%>
7
1
  <%# Nothing! -%>
@@ -1,6 +1 @@
1
- -# available local variables:
2
- current_page: the page number of currently displayed page
3
- num_pages: total number of pages
4
- per_page: number of items to fetch per page
5
- remote: data-remote
6
1
  -# Nothing!
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kaminari}
8
- s.version = "0.9.3"
8
+ s.version = "0.9.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Akira Matsuda"]
@@ -92,6 +92,7 @@ Gem::Specification.new do |s|
92
92
  "spec/acceptance/support/paths.rb",
93
93
  "spec/acceptance/users_spec.rb",
94
94
  "spec/helpers/helpers_spec.rb",
95
+ "spec/helpers/tags_spec.rb",
95
96
  "spec/models/scopes_spec.rb",
96
97
  "spec/spec_helper.rb",
97
98
  "spec/support/20110128122508_create_users.rb",
@@ -110,6 +111,7 @@ Gem::Specification.new do |s|
110
111
  "spec/acceptance/support/paths.rb",
111
112
  "spec/acceptance/users_spec.rb",
112
113
  "spec/helpers/helpers_spec.rb",
114
+ "spec/helpers/tags_spec.rb",
113
115
  "spec/models/scopes_spec.rb",
114
116
  "spec/spec_helper.rb",
115
117
  "spec/support/20110128122508_create_users.rb",
@@ -35,12 +35,9 @@ module Kaminari
35
35
  tags << (num_pages > current_page ? NextLink.new(self) : NextSpan.new(self))
36
36
  end
37
37
 
38
- def context #:nodoc:
39
- @template.instance_variable_get('@lookup_context')
40
- end
41
-
42
- def resolver #:nodoc:
43
- context.instance_variable_get('@view_paths').first
38
+ def partial_exists?(name) #:nodoc:
39
+ resolver = context.instance_variable_get('@view_paths').first
40
+ resolver.find_all(*args_for_lookup(name)).present?
44
41
  end
45
42
 
46
43
  def to_s #:nodoc:
@@ -52,6 +49,20 @@ module Kaminari
52
49
  end
53
50
 
54
51
  private
52
+ def context
53
+ @template.instance_variable_get('@lookup_context')
54
+ end
55
+
56
+ def args_for_lookup(name)
57
+ if (method = context.method :args_for_lookup).arity == 3
58
+ # 3.0
59
+ method.call name, 'kaminari', true
60
+ else
61
+ # 3.1
62
+ method.call name, 'kaminari', true, []
63
+ end
64
+ end
65
+
55
66
  def method_missing(meth, *args, &blk)
56
67
  @template.send meth, *args, &blk
57
68
  end
@@ -17,10 +17,6 @@ module Kaminari
17
17
  # template will be used.
18
18
  # e.g.) Paginator -> $GEM_HOME/kaminari-x.x.x/app/views/kaminari/_paginator.html.erb
19
19
  class Tag
20
- def self.template_filename #:nodoc:
21
- name.demodulize.underscore
22
- end
23
-
24
20
  def initialize(renderer, options = {}) #:nodoc:
25
21
  @renderer, @options = renderer, renderer.options.merge(options)
26
22
  end
@@ -36,80 +32,123 @@ module Kaminari
36
32
  # 2. a template for its parent class from app/views
37
33
  # 3. the default one inside the engine
38
34
  def find_template(klass = self.class)
39
- if @renderer.resolver.find_all(*args_for_lookup(klass)).present?
35
+ if @renderer.partial_exists? klass.template_filename
40
36
  "kaminari/#{klass.template_filename}"
41
- elsif (parent = klass.ancestors[1]) == Tag
37
+ elsif (parent = klass.ancestors[1]) == Renderable
42
38
  "kaminari/#{self.class.template_filename}"
43
39
  else
44
40
  find_template parent
45
41
  end
46
42
  end
47
43
 
48
- def args_for_lookup(klass)
49
- if (method = @renderer.context.method :args_for_lookup).arity == 3
50
- # 3.0
51
- method.call klass.template_filename, 'kaminari', true
52
- else
53
- # 3.1
54
- method.call klass.template_filename, 'kaminari', true, []
44
+ def page_url_for(page)
45
+ @renderer.url_for @renderer.params.merge(:page => (page <= 1 ? nil : page))
46
+ end
47
+ end
48
+
49
+ module Renderable #:nodoc:
50
+ def self.included(base) #:nodoc:
51
+ base.extend ClassMethods
52
+ end
53
+ module ClassMethods #:nodoc:
54
+ def template_filename #:nodoc:
55
+ name.demodulize.underscore
56
+ end
57
+ def included(base) #:nodoc:
58
+ base.extend Renderable::ClassMethods
55
59
  end
56
60
  end
61
+ end
57
62
 
58
- def page_url_for(page)
59
- @renderer.url_for @renderer.params.merge(:page => (page <= 1 ? nil : page))
63
+ # Tag that contains a link
64
+ module Link
65
+ include Renderable
66
+ def url
67
+ raise 'Override url with the actual url value to be a Link.'
68
+ end
69
+ def to_s(locals = {}) #:nodoc:
70
+ super locals.merge(:url => url)
71
+ end
72
+ end
73
+
74
+ # Tag that doesn't contain a link
75
+ module NonLink
76
+ include Renderable
77
+ end
78
+
79
+ # Tag for a page
80
+ module Page
81
+ def page
82
+ raise 'Override page with the actual page value to be a Page.'
83
+ end
84
+ def to_s(locals = {}) #:nodoc:
85
+ super locals.merge(:page => page)
60
86
  end
61
87
  end
62
88
 
63
89
  # "Previous" without link
64
90
  class PrevSpan < Tag
91
+ include NonLink
65
92
  end
66
93
 
67
94
  # "Previous" with link
68
95
  class PrevLink < Tag
69
- def to_s #:nodoc:
70
- super :prev_url => page_url_for(@options[:current_page] - 1)
96
+ include Link
97
+ def url #:nodoc:
98
+ page_url_for @options[:current_page] - 1
71
99
  end
72
100
  end
73
101
 
74
102
  # "Next" without link
75
103
  class NextSpan < Tag
104
+ include NonLink
76
105
  end
77
106
 
78
107
  # "Next" with link
79
108
  class NextLink < Tag
80
- def to_s #:nodoc:
81
- super :next_url => page_url_for(@options[:current_page] + 1)
109
+ include Link
110
+ def url #:nodoc:
111
+ page_url_for @options[:current_page] + 1
82
112
  end
83
113
  end
84
114
 
85
- # A link showing page number
115
+ # Link showing page number
86
116
  class PageLink < Tag
87
- def to_s #:nodoc:
88
- super :page_url => page_url_for(@options[:page])
117
+ include Page
118
+ include Link
119
+ def page #:nodoc:
120
+ @options[:page]
121
+ end
122
+ def url #:nodoc:
123
+ page_url_for page
89
124
  end
90
125
  end
91
126
 
92
- # A non-link tag showing the current page number
127
+ # Non-link tag showing the current page number
93
128
  class CurrentPage < Tag
94
- def to_s #:nodoc:
95
- super :page_url => page_url_for(@options[:page])
129
+ include Page
130
+ include NonLink
131
+ def page #:nodoc:
132
+ @options[:page]
96
133
  end
97
134
  end
98
135
 
99
- # A link with page number that appears at the leftmost
136
+ # Link with page number that appears at the leftmost
100
137
  class FirstPageLink < PageLink
101
138
  end
102
139
 
103
- # A link with page number that appears at the rightmost
140
+ # Link with page number that appears at the rightmost
104
141
  class LastPageLink < PageLink
105
142
  end
106
143
 
107
- # A non-link tag that stands for skipped pages...
144
+ # Non-link tag that stands for skipped pages...
108
145
  class TruncatedSpan < Tag
146
+ include NonLink
109
147
  end
110
148
 
111
149
  # The container tag
112
150
  class Paginator < Tag
151
+ include Renderable
113
152
  end
114
153
  end
115
154
  end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+ include Kaminari::Helpers
3
+
4
+ describe 'Kaminari::Helpers' do
5
+ let :renderer do
6
+ stub(r = Object.new) do
7
+ render.with_any_args
8
+ options { {} }
9
+ params { {} }
10
+ partial_exists?.with_any_args {|a| puts a; false }
11
+ url_for {|h| "/foo?page=#{h[:page]}"}
12
+ end
13
+ r
14
+ end
15
+ describe 'PageLink' do
16
+ subject { PageLink.new renderer, :page => 3 }
17
+ its('class.template_filename') { should == 'page_link' }
18
+ describe 'template lookup rule' do
19
+ before do
20
+ pending "spies doesn't work on RSpec 2 ATM: https://github.com/btakita/rr/issues#issue/45"
21
+ subject.to_s
22
+ end
23
+ specify { renderer.should have_received.partial_exists? PageLink }
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaminari
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 3
10
- version: 0.9.3
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akira Matsuda
@@ -318,6 +318,7 @@ files:
318
318
  - spec/acceptance/support/paths.rb
319
319
  - spec/acceptance/users_spec.rb
320
320
  - spec/helpers/helpers_spec.rb
321
+ - spec/helpers/tags_spec.rb
321
322
  - spec/models/scopes_spec.rb
322
323
  - spec/spec_helper.rb
323
324
  - spec/support/20110128122508_create_users.rb
@@ -364,6 +365,7 @@ test_files:
364
365
  - spec/acceptance/support/paths.rb
365
366
  - spec/acceptance/users_spec.rb
366
367
  - spec/helpers/helpers_spec.rb
368
+ - spec/helpers/tags_spec.rb
367
369
  - spec/models/scopes_spec.rb
368
370
  - spec/spec_helper.rb
369
371
  - spec/support/20110128122508_create_users.rb