paginate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -0
- data/lib/paginate/renderer.rb +5 -5
- data/lib/paginate/version.rb +1 -1
- data/test/paginate/action_view_test.rb +11 -11
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -63,6 +63,16 @@ If you want to translate links, you have implement the following scopes:
|
|
63
63
|
previous: "Newer"
|
64
64
|
page: "Page {{page}}"
|
65
65
|
|
66
|
+
== Styling
|
67
|
+
|
68
|
+
If you want something like Twitter Search use this CSS:
|
69
|
+
|
70
|
+
.paginate { overflow: hidden; }
|
71
|
+
.paginate li { float: left; }
|
72
|
+
.paginate li.previous-page:after { content: "«"; padding: 0 5px; }
|
73
|
+
.paginate li.next-page:before { content: "»"; padding: 0 5px; }
|
74
|
+
.paginate .disabled { display: none; }
|
75
|
+
|
66
76
|
== License
|
67
77
|
|
68
78
|
(The MIT License)
|
data/lib/paginate/renderer.rb
CHANGED
@@ -46,19 +46,19 @@ module Paginate
|
|
46
46
|
|
47
47
|
# Previous page
|
48
48
|
if processor.previous_page?
|
49
|
-
html << %[<li
|
49
|
+
html << %[<li class="previous-page"><a href="#{previous_url}" title="#{previous_label}">#{previous_label}</a></li>]
|
50
50
|
else
|
51
|
-
html << %[<li
|
51
|
+
html << %[<li class="previous-page disabled"><span title="#{previous_label}">#{previous_label}</span></li>]
|
52
52
|
end
|
53
53
|
|
54
54
|
# Current page
|
55
|
-
html << %[<li
|
55
|
+
html << %[<li class="page"><span>#{page_label}</span></li>]
|
56
56
|
|
57
57
|
# Next page
|
58
58
|
if processor.next_page?
|
59
|
-
html << %[<li
|
59
|
+
html << %[<li class="next-page"><a href="#{next_url}" title="#{next_label}">#{next_label}</a></li>]
|
60
60
|
else
|
61
|
-
html << %[<li
|
61
|
+
html << %[<li class="next-page disabled"><span title="#{next_label}">#{next_label}</span></li>]
|
62
62
|
end
|
63
63
|
|
64
64
|
html << %[</ul>]
|
data/lib/paginate/version.rb
CHANGED
@@ -42,7 +42,7 @@ class ActionViewTest < Test::Unit::TestCase
|
|
42
42
|
def test_display_next_page_link
|
43
43
|
@request.fullpath = "/some/path?page=1"
|
44
44
|
html = render(:default, Array.new(11))
|
45
|
-
link = html.css("li > a
|
45
|
+
link = html.css("li.next-page > a").first
|
46
46
|
|
47
47
|
assert_not_nil link
|
48
48
|
assert_equal "/some/path?page=2", link["href"]
|
@@ -52,7 +52,7 @@ class ActionViewTest < Test::Unit::TestCase
|
|
52
52
|
def test_display_next_page_link_from_block
|
53
53
|
@request.fullpath = "/some/path?page=1"
|
54
54
|
html = render(:block_as_url, Array.new(11))
|
55
|
-
link = html.css("li > a
|
55
|
+
link = html.css("li.next-page > a").first
|
56
56
|
|
57
57
|
assert_not_nil link
|
58
58
|
assert_equal "/some/path/2", link["href"]
|
@@ -63,7 +63,7 @@ class ActionViewTest < Test::Unit::TestCase
|
|
63
63
|
@params[:page] = 2
|
64
64
|
@request.fullpath = "/some/path?page=2"
|
65
65
|
html = render(:default, Array.new(11))
|
66
|
-
link = html.css("li > a
|
66
|
+
link = html.css("li.previous-page > a").first
|
67
67
|
|
68
68
|
assert_not_nil link
|
69
69
|
assert_equal "/some/path?page=1", link["href"]
|
@@ -73,8 +73,8 @@ class ActionViewTest < Test::Unit::TestCase
|
|
73
73
|
def test_display_next_page_as_disabled
|
74
74
|
@request.fullpath = "/some/path?page=1"
|
75
75
|
html = render(:default, Array.new(10))
|
76
|
-
link = html.css("li > a
|
77
|
-
span = html.css("li
|
76
|
+
link = html.css("li.next-page > a").first
|
77
|
+
span = html.css("li.next-page.disabled > span").first
|
78
78
|
|
79
79
|
assert_nil link
|
80
80
|
assert_not_nil span
|
@@ -84,8 +84,8 @@ class ActionViewTest < Test::Unit::TestCase
|
|
84
84
|
def test_display_previous_page_as_disabled
|
85
85
|
@request.fullpath = "/some/path?page=1"
|
86
86
|
html = render(:default, Array.new(10))
|
87
|
-
link = html.css("li > a
|
88
|
-
span = html.css("li
|
87
|
+
link = html.css("li.previous-page > a").first
|
88
|
+
span = html.css("li.previous-page.disabled > span").first
|
89
89
|
|
90
90
|
assert_nil link
|
91
91
|
assert_not_nil span
|
@@ -96,7 +96,7 @@ class ActionViewTest < Test::Unit::TestCase
|
|
96
96
|
@params[:page] = 10
|
97
97
|
@request.fullpath = "/some/path?page=10"
|
98
98
|
html = render(:default, [])
|
99
|
-
span = html.css("li > span
|
99
|
+
span = html.css("li.page > span").first
|
100
100
|
|
101
101
|
assert_not_nil span
|
102
102
|
assert_equal "Page 10", span.text
|
@@ -109,9 +109,9 @@ class ActionViewTest < Test::Unit::TestCase
|
|
109
109
|
@request.fullpath = "/some/path?page=10"
|
110
110
|
html = render(:default, Array.new(11))
|
111
111
|
|
112
|
-
assert_equal "Página 10", html.css("
|
113
|
-
assert_equal "Próxima página", html.css("
|
114
|
-
assert_equal "Página anterior", html.css("
|
112
|
+
assert_equal "Página 10", html.css("li.page > span").text
|
113
|
+
assert_equal "Próxima página", html.css("li.next-page > a").text
|
114
|
+
assert_equal "Página anterior", html.css("li.previous-page > a").text
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_iterate
|