genki-dm-pagination 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +20 -1
- data/Rakefile +1 -1
- data/lib/dm-pagination/pagination_builder.rb +3 -3
- data/spec/dm-pagination_spec.rb +7 -1
- data/spec/fixture/app/views/pagination_builder/variant.html.erb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
data/README
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
dm-pagination
|
2
2
|
=============
|
3
3
|
|
4
|
-
A plugin for the Merb framework that provides
|
4
|
+
A plugin for the Merb framework that provides pagination for DataMapper.
|
5
|
+
|
6
|
+
USAGE:
|
7
|
+
|
8
|
+
In your controller,
|
9
|
+
|
10
|
+
class Posts
|
11
|
+
def index
|
12
|
+
@posts = Post.paginate(:page => params[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
In your view,
|
16
|
+
|
17
|
+
<ul>
|
18
|
+
<% @posts.each do |post| %>
|
19
|
+
<li><%= h(post.body) %></li>
|
20
|
+
<% end %>
|
21
|
+
</ul>
|
22
|
+
<%= paginate @posts %>
|
23
|
+
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ module DmPagination
|
|
25
25
|
url(:page => @pagination.page - 1),
|
26
26
|
:class => :prev, :rel => "prev"
|
27
27
|
else
|
28
|
-
span.call(prev_label)
|
28
|
+
span.call(prev_label, :prev)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,9 +33,9 @@ module DmPagination
|
|
33
33
|
if @pagination.page < @pagination.num_pages
|
34
34
|
@context.link_to next_label,
|
35
35
|
url(:page => @pagination.page + 1),
|
36
|
-
:class => :
|
36
|
+
:class => :next, :rel => "next"
|
37
37
|
else
|
38
|
-
span.call(next_label)
|
38
|
+
span.call(next_label, :next)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
data/spec/dm-pagination_spec.rb
CHANGED
@@ -72,7 +72,8 @@ describe "dm-pagination" do
|
|
72
72
|
it "should have rendered with pagination at page 2" do
|
73
73
|
response = request "/pagination_builder/simple", :params => {:page => 2}
|
74
74
|
response.should be_successful
|
75
|
-
response.should have_selector("a[rel=prev]")
|
75
|
+
response.should have_selector("a.prev[rel=prev]")
|
76
|
+
response.should have_selector("a.next[rel=next]")
|
76
77
|
response.body.scan(/Prev|Next/).should == %w(Prev Next)
|
77
78
|
end
|
78
79
|
|
@@ -80,6 +81,11 @@ describe "dm-pagination" do
|
|
80
81
|
response = request "/pagination_builder/variant"
|
81
82
|
response.should be_successful
|
82
83
|
response.body.scan(/Prev|Next/).should == %w(Next Prev)
|
84
|
+
response.should have_selector("a.next[rel=next]")
|
85
|
+
response.should_not have_selector("a.prev[rel=prev]")
|
86
|
+
response.should have_selector("span.prev")
|
87
|
+
response.should have_selector("span.number")
|
88
|
+
response.should_not have_selector("span.prev.number")
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
@@ -1 +1 @@
|
|
1
|
-
<%= paginate @posts, :pages, :next, :prev %>
|
1
|
+
<%= paginate @posts, :pages, :next, :prev, :style => 'number' %>
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genki-dm-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Takiuchi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|