rails_will_paginate_seo_helper 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/view_helpers.rb +30 -14
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20345eab25324a106d4dcd1cdb4c04053ded7e3c
|
4
|
+
data.tar.gz: 3f42274fa552f8d73c5db3ba4f9cdf2536c1380c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57929fc77321c87ecfde3463e2acee633b2b3caa454b77ea41c8fd1d677336cb2740476896227e850ab6ed6da76bda9cba1bdea3ac4a9d8be4483e3cfe345ca8
|
7
|
+
data.tar.gz: c41c726f0308f50a51ad21b1fa317a88c5685455daa8f9d7b04827425984d1297b9c65ea37ac4129e568a8c2d4c30fadb1c8ab30633539ce4bdde9b9a4d23a8d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/view_helpers.rb
CHANGED
@@ -3,34 +3,50 @@ module RailsWillPaginateSeoHelper
|
|
3
3
|
def will_paginate_seo_links(collection)
|
4
4
|
return unless collection.respond_to?(:current_page)
|
5
5
|
@collection = collection
|
6
|
-
build_tags
|
6
|
+
build_tags
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
|
12
11
|
def build_tags
|
13
12
|
if next_link_tag && previous_link_tag
|
14
|
-
return previous_link_tag << next_link_tag
|
15
|
-
end
|
16
|
-
return next_link_tag if next_link_tag
|
17
|
-
return previous_link_tag if previous_link_tag
|
18
|
-
end
|
19
|
-
|
20
|
-
def next_link_tag
|
21
|
-
next_page = @collection.next_page
|
22
|
-
if next_page
|
23
|
-
next_page_url = request.original_url.gsub(/page\=\d{1,}/, "page=#{next_page}")
|
24
|
-
return tag(:link, href: next_page_url, rel: :next)
|
13
|
+
return (previous_link_tag << next_link_tag).html_safe
|
25
14
|
end
|
15
|
+
return previous_link_tag.html_safe if previous_link_tag
|
16
|
+
next_link_tag.html_safe if next_link_tag
|
26
17
|
end
|
27
18
|
|
28
19
|
def previous_link_tag
|
29
20
|
previous_page = @collection.previous_page
|
21
|
+
original_url = request.original_url
|
22
|
+
|
30
23
|
if previous_page
|
31
|
-
|
24
|
+
if previous_page == 1
|
25
|
+
prev_page_url = original_url.gsub(/(&|\?)page\=\d{1,}/, '')
|
26
|
+
else
|
27
|
+
prev_page_url = original_url.gsub(/page\=\d{1,}/, "page=#{previous_page}")
|
28
|
+
end
|
32
29
|
return tag(:link, href: prev_page_url, rel: :prev)
|
33
30
|
end
|
34
31
|
end
|
32
|
+
|
33
|
+
def next_link_tag
|
34
|
+
next_page = @collection.next_page
|
35
|
+
original_url = request.original_url
|
36
|
+
|
37
|
+
match = original_url.match(/(&|\?)page\=\d{1,}/)
|
38
|
+
|
39
|
+
if match # has :page url-parameter
|
40
|
+
next_page_url = original_url.gsub(/page\=\d{1,}/, "page=#{next_page}")
|
41
|
+
else # no :page url-parameter page
|
42
|
+
sign_match = original_url.match(/\?/)
|
43
|
+
if sign_match # url has parameter attached
|
44
|
+
next_page_url = original_url.concat("&page=#{next_page}")
|
45
|
+
else # url has no parameter attached
|
46
|
+
next_page_url = original_url.concat("?page=#{next_page}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
tag(:link, href: next_page_url, rel: :next) if next_page_url
|
50
|
+
end
|
35
51
|
end
|
36
52
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|