canonical-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/canonical_rails/tag_helper.rb +9 -9
- data/lib/canonical-rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c18700d23c45f68b450a9da262f88e7524a0388c
|
4
|
+
data.tar.gz: 278eda8035516a953b73b54cac15c5a7428c0523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054e6ed7f57e857cc5b7bd9b93756d937f46a819acabc13211fefb62216a040e830cc1ab4a80b2ccc2787f5dc7333492a44ef9441105f8ff405dfc9cb50fadc4
|
7
|
+
data.tar.gz: 304915f4ed28c27353ad2dcde5ae5f06061c7c6189888cf27c95320eb305aa8c2395dfb3ad8da488f5dad9d839a8f4003283d97818be2ca3c7c20d7413d6a82f
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module CanonicalRails
|
2
2
|
module TagHelper
|
3
|
-
|
3
|
+
|
4
4
|
def trailing_slash_needed?
|
5
5
|
CanonicalRails.sym_collection_actions.include? request.params['action'].to_sym
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def trailing_slash_if_needed
|
9
9
|
"/" if trailing_slash_needed? and request.path != '/'
|
10
10
|
end
|
@@ -12,28 +12,28 @@ module CanonicalRails
|
|
12
12
|
def path_without_html_extension
|
13
13
|
request.path.sub(/\.html$/, '')
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def canonical_host
|
17
17
|
CanonicalRails.host || request.host
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def canonical_href(host=canonical_host)
|
21
21
|
"#{request.protocol}#{host}#{path_without_html_extension}#{trailing_slash_if_needed}#{whitelisted_query_string}"
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def canonical_tag(host=canonical_host)
|
25
|
-
tag(:link, :href => canonical_href(host), :rel => 'canonical')
|
25
|
+
tag(:link, :href => raw(canonical_href(host)), :rel => 'canonical')
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def whitelisted_params
|
29
29
|
request.params.select do |key, value|
|
30
30
|
value.present? and
|
31
31
|
CanonicalRails.sym_whitelisted_parameters.include? key.to_sym
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def whitelisted_query_string
|
36
|
-
"?#{whitelisted_params.
|
36
|
+
"?#{whitelisted_params.map{ |key, val| "#{key}=#{val}" }.join('&')}" if whitelisted_params.present?
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canonical-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Ivanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|