roku_pages 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/README.rdoc +20 -5
- data/lib/roku_pages.rb +5 -1
- data/lib/roku_pages/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02f353e4f68cf40c0bd1e87f5840ec9526ebab5a
|
4
|
+
data.tar.gz: e03c44b42a6a08bd936ea9fdb3e1aa1df36509b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 099666ba43373444030eef7c320012b45f30de91fac2b8132e7e4ca5127de19c7809db70dab80055fc15742ad0f6997c1f149a0d1f101fbf401a44f0f9a40de3
|
7
|
+
data.tar.gz: 730d8196712286cd254048c29ecd11ae0c00b20e00e0e3408d46262a0132caee692bacbaefcdd58782bb952df1357552bd4a37d36ef5c126d7b0d164562d0bcd
|
data/README.rdoc
CHANGED
@@ -2,10 +2,13 @@
|
|
2
2
|
Dumb idea for adding pagination to header.
|
3
3
|
Only page numbers and total, no other.
|
4
4
|
|
5
|
+
|
5
6
|
= Install
|
6
|
-
gem 'roku_pages', '0.0.
|
7
|
+
gem 'roku_pages', '0.0.8'
|
7
8
|
|
8
9
|
= Usage
|
10
|
+
options(paginate) > params > default method
|
11
|
+
|
9
12
|
use <tt>params[:page]</tt> and <tt>params[:per_page]</tt>
|
10
13
|
|
11
14
|
default <tt>page: 1</tt> and <tt>per_page: 25</tt>
|
@@ -14,15 +17,27 @@ just replace render
|
|
14
17
|
paginate json: articles
|
15
18
|
|
16
19
|
result
|
17
|
-
Pagination:{"first":1,"prev":1,"current":1,"next":
|
18
|
-
Total:4
|
20
|
+
Pagination:{"first":1,"prev":1,"current":1,"next":1,"last":1,"total":"4"}
|
19
21
|
|
20
22
|
you can also override by this
|
21
23
|
paginate json: articles, page: 2, per_page: 2
|
22
24
|
|
25
|
+
|
26
|
+
or override the default method in controller
|
27
|
+
def paginate_page
|
28
|
+
2
|
29
|
+
end
|
30
|
+
|
31
|
+
def paginate_per_page
|
32
|
+
1
|
33
|
+
end
|
34
|
+
|
35
|
+
def paginate_hash
|
36
|
+
super.merge!({first: "1st"})
|
37
|
+
end
|
38
|
+
|
23
39
|
result
|
24
|
-
Pagination:{"
|
25
|
-
Total:4
|
40
|
+
Pagination:{"1st":1,"prev":1,"current":2,"next":3,"last":4,"total":"4"}
|
26
41
|
|
27
42
|
you can use +json+ or +xml+
|
28
43
|
paginate json: articles
|
data/lib/roku_pages.rb
CHANGED
@@ -30,7 +30,7 @@ module RokuPages
|
|
30
30
|
pages[pages_key[:next]] = collection.current_page + 1 < collection.total_pages ? collection.current_page + 1 : collection.total_pages
|
31
31
|
pages[pages_key[:last]] = collection.total_pages
|
32
32
|
pages[pages_key[:total]] = collection.total_count.to_s
|
33
|
-
headers[
|
33
|
+
headers[paginate_root] = pages.to_json
|
34
34
|
end
|
35
35
|
|
36
36
|
render options
|
@@ -54,6 +54,10 @@ module RokuPages
|
|
54
54
|
total: :total
|
55
55
|
}
|
56
56
|
end
|
57
|
+
|
58
|
+
def paginate_root
|
59
|
+
"Pagination"
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
|
data/lib/roku_pages/version.rb
CHANGED