kaminari 0.5.0 → 0.6.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.

data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.0
2
+
3
+ * Hamlized paginator templates
4
+
1
5
  == 0.5.0
2
6
 
3
7
  * reset content_for :kaminari_paginator_tags before rendering #1 [hsbt]
@@ -12,7 +12,7 @@ Does not globally pollute Array, Hash, Object or AR::Base.
12
12
  Just bundle the gem, then your models are ready to be paginated. No configuration. Don't have to define anything in your models or helpers.
13
13
 
14
14
  * Scope based simple API
15
- Everything is method chainable. No Hash for the query. You know, that's the Rails 3 way.
15
+ Everything is method chainable with less Hasheritis. You know, that's the Rails 3 way.
16
16
  No special collection class or something for the paginated values but uses a general AR::Relation instance. So, of course you can chain any other conditions before or after the paginator scope.
17
17
 
18
18
  * Engine based customizable helper
@@ -35,23 +35,29 @@ Then bundle:
35
35
 
36
36
  == Usage
37
37
 
38
+ === Query Basics
39
+
38
40
  * Fetch the 7th page of the users (per_page = 25 by default)
39
41
 
40
- @users = User.page(7)
42
+ User.page(7)
41
43
 
42
44
  * Show a lot more users per each page (change the per_page value)
43
45
 
44
- @users = User.page(7).per(50)
46
+ User.page(7).per(50)
47
+
48
+ === Controllers
45
49
 
46
50
  * Typically, your controller code will look like this:
47
51
 
48
- @users = User.page params[:page]
52
+ @users = User.order(:name).page params[:page]
49
53
 
50
- * In your view
54
+ === Views
55
+
56
+ * Just call the "paginate" helper
51
57
 
52
58
  <%= paginate @users %>
53
59
 
54
- * Specify the "window" size
60
+ * Specifing the "window" size
55
61
 
56
62
  # "inner window" (4 by default)
57
63
 
@@ -65,11 +71,19 @@ Then bundle:
65
71
 
66
72
  <%= paginate @users, :left => 0, :right => 2 %>
67
73
 
68
- * Customize the pagination helper
74
+ === Customizing the pagination helper
75
+
76
+ * The generator
69
77
 
70
78
  % rails g kaminari:views
71
79
  Then edit the partials in your app's app/views/kaminari/ directory.
72
80
 
81
+ * For Haml users
82
+
83
+ Haml templates generator is also available by adding "-e haml" option.
84
+
85
+ % rails g kaminari:views -e haml
86
+
73
87
 
74
88
  == Contributing to Kaminari
75
89
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -0,0 +1,2 @@
1
+ %span.page.current
2
+ = page
@@ -0,0 +1,2 @@
1
+ %span.page.first
2
+ = link_to page, page_url
@@ -0,0 +1,2 @@
1
+ %span.page.last
2
+ = link_to page, page_url
@@ -0,0 +1,2 @@
1
+ %span.next
2
+ = link_to_if (current_page < num_pages), raw('Next &raquo;'), next_url, :class => 'next', :rel => 'next'
@@ -0,0 +1 @@
1
+ %span.next
@@ -0,0 +1,2 @@
1
+ %span.page
2
+ = link_to page, page_url
@@ -0,0 +1,2 @@
1
+ .pagination
2
+ = content_for :kaminari_paginator_tags
@@ -0,0 +1,2 @@
1
+ %span.prev
2
+ = link_to_if (current_page > 1), raw('&laquo; Prev'), prev_url, :class => 'prev', :rel => 'prev'
@@ -0,0 +1 @@
1
+ %span.prev
@@ -0,0 +1,2 @@
1
+ %span.page
2
+ \...
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kaminari}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
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"]
@@ -28,15 +28,25 @@ Gem::Specification.new do |s|
28
28
  "TODO.txt",
29
29
  "VERSION",
30
30
  "app/views/kaminari/_current_page.html.erb",
31
+ "app/views/kaminari/_current_page.html.haml",
31
32
  "app/views/kaminari/_first_page_link.html.erb",
33
+ "app/views/kaminari/_first_page_link.html.haml",
32
34
  "app/views/kaminari/_last_page_link.html.erb",
35
+ "app/views/kaminari/_last_page_link.html.haml",
33
36
  "app/views/kaminari/_next_link.html.erb",
37
+ "app/views/kaminari/_next_link.html.haml",
34
38
  "app/views/kaminari/_next_span.html.erb",
39
+ "app/views/kaminari/_next_span.html.haml",
35
40
  "app/views/kaminari/_page_link.html.erb",
41
+ "app/views/kaminari/_page_link.html.haml",
36
42
  "app/views/kaminari/_paginator.html.erb",
43
+ "app/views/kaminari/_paginator.html.haml",
37
44
  "app/views/kaminari/_prev_link.html.erb",
45
+ "app/views/kaminari/_prev_link.html.haml",
38
46
  "app/views/kaminari/_prev_span.html.erb",
47
+ "app/views/kaminari/_prev_span.html.haml",
39
48
  "app/views/kaminari/_truncated_span.html.erb",
49
+ "app/views/kaminari/_truncated_span.html.haml",
40
50
  "kaminari.gemspec",
41
51
  "lib/generators/kaminari/views_generator.rb",
42
52
  "lib/kaminari.rb",
@@ -1,11 +1,20 @@
1
1
  module Kaminari
2
2
  module Generators
3
3
  class ViewsGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../../../../app/views', __FILE__)
4
+ source_root File.expand_path('../../../../app/views/kaminari', __FILE__)
5
+
6
+ class_option :template_engine, :type => :string, :aliases => '-e', :desc => 'Template engine for the views. Available options are "erb" and "haml".'
5
7
 
6
8
  desc 'Copies all paginator partials to your application.'
7
9
  def copy_views
8
- directory 'kaminari', 'app/views/kaminari'
10
+ Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
11
+ copy_file f, "app/views/kaminari/#{f}"
12
+ end
13
+ end
14
+
15
+ private
16
+ def filename_pattern
17
+ File.join self.class.source_root, "*.html.#{options[:template_engine] || 'erb'}"
9
18
  end
10
19
  end
11
20
  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: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akira Matsuda
@@ -219,15 +219,25 @@ files:
219
219
  - TODO.txt
220
220
  - VERSION
221
221
  - app/views/kaminari/_current_page.html.erb
222
+ - app/views/kaminari/_current_page.html.haml
222
223
  - app/views/kaminari/_first_page_link.html.erb
224
+ - app/views/kaminari/_first_page_link.html.haml
223
225
  - app/views/kaminari/_last_page_link.html.erb
226
+ - app/views/kaminari/_last_page_link.html.haml
224
227
  - app/views/kaminari/_next_link.html.erb
228
+ - app/views/kaminari/_next_link.html.haml
225
229
  - app/views/kaminari/_next_span.html.erb
230
+ - app/views/kaminari/_next_span.html.haml
226
231
  - app/views/kaminari/_page_link.html.erb
232
+ - app/views/kaminari/_page_link.html.haml
227
233
  - app/views/kaminari/_paginator.html.erb
234
+ - app/views/kaminari/_paginator.html.haml
228
235
  - app/views/kaminari/_prev_link.html.erb
236
+ - app/views/kaminari/_prev_link.html.haml
229
237
  - app/views/kaminari/_prev_span.html.erb
238
+ - app/views/kaminari/_prev_span.html.haml
230
239
  - app/views/kaminari/_truncated_span.html.erb
240
+ - app/views/kaminari/_truncated_span.html.haml
231
241
  - kaminari.gemspec
232
242
  - lib/generators/kaminari/views_generator.rb
233
243
  - lib/kaminari.rb