mobile_pagination 0.0.2 → 0.0.3
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/.gitignore +2 -1
- data/README.md +21 -16
- data/lib/mobile_pagination/paginate.rb +16 -4
- data/lib/mobile_pagination/templates.rb +2 -2
- data/lib/mobile_pagination/utils/utils.rb +2 -0
- data/lib/mobile_pagination/utils/version.rb +1 -1
- data/spec/spec_helper.rb +5 -2
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# MobilePagination
|
2
2
|
|
3
3
|
## Description
|
4
|
-
|
4
|
+
Gem for producing minimal pagination links, best suited for smaller screens.
|
5
5
|
|
6
6
|

|
7
7
|
|
8
|
-
|
9
8
|
## Installation
|
10
9
|
|
11
10
|
Add this line to your application's Gemfile:
|
@@ -24,6 +23,12 @@ Or install it yourself as:
|
|
24
23
|
Initializes with 4 options: `current_page, total_pages, query, path`
|
25
24
|
|
26
25
|
```ruby
|
26
|
+
# in your view, you may have something like this:
|
27
|
+
ol
|
28
|
+
= pagination
|
29
|
+
|
30
|
+
# in your helpers, you might have something like:
|
31
|
+
|
27
32
|
require 'mobile_pagination'
|
28
33
|
|
29
34
|
# http://local.m.newhomeguide.com/New-Homes/Georgia/Atlanta/?page=2
|
@@ -41,22 +46,8 @@ def pagination
|
|
41
46
|
MobilePagination::Paginate.new(opts).html
|
42
47
|
end
|
43
48
|
|
44
|
-
# in your view, you may have something like this:
|
45
|
-
ol
|
46
|
-
= pagination
|
47
49
|
```
|
48
50
|
|
49
|
-
### Configuration
|
50
|
-
Configuration is optional. Say for example you were paginating slides on a slideshow - instead of using page, you could configure the gem to use a different key.
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
MobilePagination.configure do |config|
|
54
|
-
config.page_key = 'slide'
|
55
|
-
end
|
56
|
-
```
|
57
|
-
|
58
|
-
Configuration must run prior to initialization. The resulting pagination links will now contain `/?slide=2, /?slide=3` to suit your custom url structure. The default page_key is `page`.
|
59
|
-
|
60
51
|
### Overrides
|
61
52
|
|
62
53
|
If you don't like list items, you will need to override `MobilePagination::Templates`
|
@@ -94,9 +85,23 @@ module MobilePagination
|
|
94
85
|
end
|
95
86
|
end
|
96
87
|
```
|
88
|
+
### Configuration
|
89
|
+
Configuration is optional.
|
90
|
+
|
91
|
+
Say for example you were paginating slides on a slideshow - instead of using page, you could configure the gem to use a different key.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
MobilePagination.configure do |config|
|
95
|
+
config.page_key = 'slide'
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
Configuration must run prior to initialization. The resulting pagination links will now contain `/?slide=2, /?slide=3` to suit your custom url structure. The default page_key is `page`.
|
97
100
|
|
98
101
|
Please note, any methods ending in `_link` will need to remain, as these methods are responsible for generating the paginated urls.
|
99
102
|
|
103
|
+
### Testing
|
104
|
+
`rspec spec`
|
100
105
|
|
101
106
|
## Contributing
|
102
107
|
|
@@ -35,12 +35,24 @@ module MobilePagination
|
|
35
35
|
@total_pages > 1
|
36
36
|
end
|
37
37
|
|
38
|
+
def first_page?
|
39
|
+
@current_page != 1
|
40
|
+
end
|
41
|
+
|
38
42
|
def previous_page?
|
39
|
-
@current_page >
|
43
|
+
@current_page > 2
|
40
44
|
end
|
41
45
|
|
42
46
|
def next_page?
|
43
|
-
|
47
|
+
last_page? && !second_to_last?
|
48
|
+
end
|
49
|
+
|
50
|
+
def last_page?
|
51
|
+
@current_page != @total_pages
|
52
|
+
end
|
53
|
+
|
54
|
+
def second_to_last?
|
55
|
+
@current_page == (@total_pages - 1)
|
44
56
|
end
|
45
57
|
|
46
58
|
def current(page)
|
@@ -56,13 +68,13 @@ module MobilePagination
|
|
56
68
|
page.nil? ? "#{@path}#{qs_without_key}" : "#{@path}#{qs_with_key(page)}"
|
57
69
|
end
|
58
70
|
|
59
|
-
|
60
71
|
def qs_with_key(page)
|
61
72
|
"?#{hash_to_query(opts_with_key(page))}"
|
62
73
|
end
|
63
74
|
|
64
75
|
def qs_without_key
|
65
|
-
"
|
76
|
+
str = "#{hash_to_query(opts_without_key)}"
|
77
|
+
str.insert(0, '?') unless str.empty?
|
66
78
|
end
|
67
79
|
|
68
80
|
def opts_with_key(page)
|
@@ -28,10 +28,10 @@ module MobilePagination
|
|
28
28
|
def html
|
29
29
|
return '' unless should_paginate?
|
30
30
|
''.tap do |markup|
|
31
|
-
markup << first_page_html if
|
31
|
+
markup << first_page_html if first_page?
|
32
32
|
markup << previous_page_html if previous_page?
|
33
33
|
markup << next_page_html if next_page?
|
34
|
-
markup << last_page_html if
|
34
|
+
markup << last_page_html if last_page?
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile_pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|