kaminari 0.10.4 → 0.11.0

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 (55) hide show
  1. data/CHANGELOG +31 -0
  2. data/Gemfile +1 -30
  3. data/Gemfile.lock +66 -82
  4. data/README.rdoc +16 -0
  5. data/Rakefile +12 -2
  6. data/VERSION +1 -1
  7. data/app/views/kaminari/_first_page.html.erb +11 -0
  8. data/app/views/kaminari/_first_page.html.haml +9 -0
  9. data/app/views/kaminari/{_truncated_span.html.erb → _gap.html.erb} +2 -2
  10. data/app/views/kaminari/{_truncated_span.html.haml → _gap.html.haml} +2 -2
  11. data/app/views/kaminari/_last_page.html.erb +11 -0
  12. data/app/views/kaminari/_last_page.html.haml +9 -0
  13. data/app/views/kaminari/{_next_link.html.erb → _next_page.html.erb} +3 -3
  14. data/app/views/kaminari/{_next_link.html.haml → _next_page.html.haml} +3 -3
  15. data/app/views/kaminari/_page.html.erb +12 -0
  16. data/app/views/kaminari/_page.html.haml +10 -0
  17. data/app/views/kaminari/_paginator.html.erb +8 -14
  18. data/app/views/kaminari/_paginator.html.haml +8 -13
  19. data/app/views/kaminari/{_prev_link.html.erb → _prev_page.html.erb} +3 -3
  20. data/app/views/kaminari/_prev_page.html.haml +9 -0
  21. data/config/locales/kaminari.yml +4 -2
  22. data/kaminari.gemspec +88 -59
  23. data/lib/generators/kaminari/views_generator.rb +13 -9
  24. data/lib/kaminari.rb +1 -0
  25. data/lib/kaminari/helpers/action_view_extension.rb +5 -5
  26. data/lib/kaminari/helpers/paginator.rb +153 -0
  27. data/lib/kaminari/helpers/tags.rb +32 -200
  28. data/lib/kaminari/models/active_record_extension.rb +1 -8
  29. data/lib/kaminari/models/active_record_relation_methods.rb +8 -1
  30. data/lib/kaminari/models/mongoid_extension.rb +1 -0
  31. data/lib/kaminari/railtie.rb +1 -1
  32. data/lib/kaminari/version.rb +3 -0
  33. data/spec/acceptance/users_spec.rb +13 -4
  34. data/spec/fake_app.rb +34 -2
  35. data/spec/helpers/helpers_spec.rb +13 -4
  36. data/spec/helpers/tags_spec.rb +32 -50
  37. data/spec/models/active_record_relation_methods_spec.rb +18 -0
  38. data/spec/models/scopes_spec.rb +12 -1
  39. data/spec/spec_helper.rb +1 -0
  40. data/spec/support/database_cleaner.rb +13 -0
  41. metadata +248 -127
  42. data/app/views/kaminari/_current_page.html.erb +0 -9
  43. data/app/views/kaminari/_current_page.html.haml +0 -9
  44. data/app/views/kaminari/_first_page_link.html.erb +0 -12
  45. data/app/views/kaminari/_first_page_link.html.haml +0 -10
  46. data/app/views/kaminari/_last_page_link.html.erb +0 -12
  47. data/app/views/kaminari/_last_page_link.html.haml +0 -10
  48. data/app/views/kaminari/_next_span.html.erb +0 -8
  49. data/app/views/kaminari/_next_span.html.haml +0 -7
  50. data/app/views/kaminari/_page_link.html.erb +0 -12
  51. data/app/views/kaminari/_page_link.html.haml +0 -10
  52. data/app/views/kaminari/_prev_link.html.haml +0 -9
  53. data/app/views/kaminari/_prev_span.html.erb +0 -8
  54. data/app/views/kaminari/_prev_span.html.haml +0 -7
  55. data/lib/kaminari/helpers/helpers.rb +0 -75
@@ -1,9 +0,0 @@
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
- -%>
9
- <span class="page current"><%= page %></span>
@@ -1,9 +0,0 @@
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
- %span.page.current
9
- = page
@@ -1,12 +0,0 @@
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
9
- -%>
10
- <span class="page first">
11
- <%= link_to page, url, :remote => remote %>
12
- </span>
@@ -1,10 +0,0 @@
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
9
- %span.page.first
10
- = link_to page, url, :remote => remote
@@ -1,12 +0,0 @@
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
9
- -%>
10
- <span class="page last">
11
- <%= link_to page, url, :remote => remote %>
12
- </span>
@@ -1,10 +0,0 @@
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
9
- %span.page.last
10
- = link_to page, url, :remote => remote
@@ -1,8 +0,0 @@
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
7
- -%>
8
- <span class="next"></span>
@@ -1,7 +0,0 @@
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
7
- %span.next
@@ -1,12 +0,0 @@
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
9
- -%>
10
- <span class="page">
11
- <%= link_to page, url, :remote => remote %>
12
- </span>
@@ -1,10 +0,0 @@
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
9
- %span.page
10
- = link_to page, url, :remote => remote
@@ -1,9 +0,0 @@
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
8
- %span.prev
9
- = link_to raw(t 'views.pagination.previous'), url, :class => 'prev', :rel => 'prev', :remote => remote
@@ -1,8 +0,0 @@
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
7
- -%>
8
- <span class="prev"></span>
@@ -1,7 +0,0 @@
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
7
- %span.prev
@@ -1,75 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'tags')
2
-
3
- module Kaminari
4
- module Helpers
5
- # Wraps the template context and helps each tag render itselves
6
- class TemplateWrapper
7
- attr_reader :options, :params
8
- delegate :render, :url_for, :to => :@template
9
-
10
- def initialize(template, options) #:nodoc:
11
- @template, @options = template, options
12
- @params = options[:params] ? template.params.merge(options.delete :params) : template.params
13
- end
14
-
15
- def partial_exists?(name) #:nodoc:
16
- resolver = context.instance_variable_get('@view_paths').first
17
- resolver.find_all(*args_for_lookup(name)).present?
18
- end
19
-
20
- private
21
- def context
22
- @template.instance_variable_get('@lookup_context')
23
- end
24
-
25
- def args_for_lookup(name)
26
- if (method = context.method :args_for_lookup).arity == 3
27
- # 3.0
28
- method.call name, 'kaminari', true
29
- else
30
- # 3.1
31
- method.call name, ['kaminari'], true, []
32
- end
33
- end
34
- end
35
-
36
- # The main class that controlls the whole process
37
- class PaginationRenderer
38
- def initialize(template, options) #:nodoc:
39
- @window_options = {}.tap do |h|
40
- h[:window] = options.delete(:window) || options.delete(:inner_window) || 4
41
- outer_window = options.delete(:outer_window)
42
- h[:left] = options.delete(:left) || outer_window || 1
43
- h[:right] = options.delete(:right) || outer_window || 1
44
- end
45
- @template = TemplateWrapper.new(template, options)
46
- end
47
-
48
- def to_s #:nodoc:
49
- suppress_logging_render_partial do
50
- Paginator.new(@template, @window_options).to_s
51
- end
52
- end
53
-
54
- private
55
- # dirty hack
56
- def suppress_logging_render_partial(&blk)
57
- if subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
58
- class << subscriber
59
- alias_method :render_partial_with_logging, :render_partial
60
- # do nothing
61
- def render_partial(event); end
62
- end
63
- ret = blk.call
64
- class << subscriber
65
- alias_method :render_partial, :render_partial_with_logging
66
- undef :render_partial_with_logging
67
- end
68
- ret
69
- else
70
- blk.call
71
- end
72
- end
73
- end
74
- end
75
- end