jekyll-redirect-from 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/History.markdown +6 -1
- data/README.md +2 -2
- data/jekyll-redirect-from.gemspec +1 -1
- data/lib/jekyll-redirect-from/redirect_page.rb +9 -9
- data/lib/jekyll-redirect-from/redirector.rb +13 -7
- data/lib/jekyll-redirect-from/version.rb +1 -1
- data/script/bootstrap +1 -1
- data/script/cibuild +1 -3
- data/script/test +2 -0
- data/spec/jekyll_redirect_from/redirect_page_spec.rb +5 -3
- data/spec/spec_helper.rb +4 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfb1076c07c42f81fb9f4e91d8b7a1e9959e2d58
|
4
|
+
data.tar.gz: 9ffd8729f7adc022c572bf6325b4207c5bbb5436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1341b8ec5a41ea28ad1954b148d5b03203842fbe9f631f233ab5a6eea53fd35f9cd178f026e733d8cfe6ca7fc8fff0f4bc2cd7bb7c689851feb7c692b663af8
|
7
|
+
data.tar.gz: 32563503dd3d74bf0c3efb15dcbcc83255c6af1d3a78500532aa4263e553872cdfe61fcbc98b99b9a6078bd4c247568726fe29a69c0a6fef53b982e7b66c6980
|
data/.travis.yml
CHANGED
data/History.markdown
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
##
|
1
|
+
## 0.7.0 / 2015-03-16
|
2
|
+
|
3
|
+
* Remove spaces in redirect page (#62)
|
4
|
+
* Only parse through documents/pages/posts (#56)
|
5
|
+
* Simplified `has_alt_urls?` and `has_redirect_to_url?` conditions (#52)
|
6
|
+
* Add support for Jekyll 3. (#59)
|
2
7
|
|
3
8
|
## 0.6.2 / 2014-09-12
|
4
9
|
|
data/README.md
CHANGED
@@ -96,12 +96,12 @@ Sometimes, you may want to redirect a site page to a totally different website.
|
|
96
96
|
```yaml
|
97
97
|
title: My amazing post
|
98
98
|
redirect_to:
|
99
|
-
- www.github.com
|
99
|
+
- http://www.github.com
|
100
100
|
```
|
101
101
|
|
102
102
|
If you have multiple `redirect_to`s set, only the first one will be respected.
|
103
103
|
|
104
|
-
**Note**: if using `redirect_to` with collections, your collection's extension
|
104
|
+
**Note**: if using `redirect_to` with collections, your collection's extension **must** end in *.html* in order for `redirect_to` to properly process.
|
105
105
|
|
106
106
|
## Contributing
|
107
107
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "jekyll", "
|
21
|
+
spec.add_runtime_dependency "jekyll", ">= 2.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
@@ -18,15 +18,15 @@ module JekyllRedirectFrom
|
|
18
18
|
|
19
19
|
def generate_redirect_content(item_url)
|
20
20
|
self.output = self.content = <<-EOF
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
<!DOCTYPE html>
|
22
|
+
<meta charset=utf-8>
|
23
|
+
<title>Redirecting...</title>
|
24
|
+
<link rel=canonical href="#{item_url}">
|
25
|
+
<meta http-equiv=refresh content="0; url=#{item_url}">
|
26
|
+
<h1>Redirecting...</h1>
|
27
|
+
<a href="#{item_url}">Click here if you are not redirected.</a>
|
28
|
+
<script>location='#{item_url}'</script>
|
29
|
+
EOF
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -34,24 +34,30 @@ module JekyllRedirectFrom
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def is_dynamic_document?(page_or_post)
|
38
|
+
page_or_post.is_a?(Jekyll::Post) ||
|
39
|
+
page_or_post.is_a?(Jekyll::Page) ||
|
40
|
+
page_or_post.is_a?(Jekyll::Document)
|
41
|
+
end
|
42
|
+
|
37
43
|
def has_alt_urls?(page_or_post)
|
38
|
-
|
39
|
-
|
44
|
+
is_dynamic_document?(page_or_post) &&
|
45
|
+
page_or_post.data.has_key?('redirect_from') &&
|
40
46
|
!alt_urls(page_or_post).empty?
|
41
47
|
end
|
42
48
|
|
43
49
|
def alt_urls(page_or_post)
|
44
|
-
Array[page_or_post.data['redirect_from']].flatten
|
50
|
+
Array[page_or_post.data['redirect_from']].flatten.compact
|
45
51
|
end
|
46
52
|
|
47
53
|
def has_redirect_to_url?(page_or_post)
|
48
|
-
|
49
|
-
|
50
|
-
!
|
54
|
+
is_dynamic_document?(page_or_post) &&
|
55
|
+
page_or_post.data.has_key?('redirect_to') &&
|
56
|
+
!redirect_to_url(page_or_post).empty?
|
51
57
|
end
|
52
58
|
|
53
59
|
def redirect_to_url(page_or_post)
|
54
|
-
[Array[page_or_post.data['redirect_to']].flatten.first]
|
60
|
+
[Array[page_or_post.data['redirect_to']].flatten.first].compact
|
55
61
|
end
|
56
62
|
|
57
63
|
def redirect_url(site, item)
|
data/script/bootstrap
CHANGED
data/script/cibuild
CHANGED
data/script/test
ADDED
@@ -8,7 +8,7 @@ describe JekyllRedirectFrom::RedirectPage do
|
|
8
8
|
|
9
9
|
context "#generate_redirect_content" do
|
10
10
|
it "sets the #content to the generated refresh page" do
|
11
|
-
expect(page_content).to eq("
|
11
|
+
expect(page_content).to eq("<!DOCTYPE html>\n<meta charset=utf-8>\n<title>Redirecting...</title>\n<link rel=canonical href=\"#{item_url}\">\n<meta http-equiv=refresh content=\"0; url=#{item_url}\">\n<h1>Redirecting...</h1>\n<a href=\"#{item_url}\">Click here if you are not redirected.</a>\n<script>location='#{item_url}'</script>\n")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "contains the meta refresh tag" do
|
@@ -34,13 +34,15 @@ describe JekyllRedirectFrom::RedirectPage do
|
|
34
34
|
let(:redirect_page) { new_redirect_page(permalink_dir) }
|
35
35
|
|
36
36
|
it "knows to add the index.html if it's a folder" do
|
37
|
-
|
37
|
+
dest = dest_dir("/posts/1914798137981389/larry-had-a-little-lamb/index.html")
|
38
|
+
expect(redirect_page.destination("/")).to eql(dest)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
context "of a redirect page meant to be a file" do
|
42
43
|
it "knows not to add the index.html if it's not a folder" do
|
43
|
-
|
44
|
+
dest = dest_dir("/posts/12435151125/larry-had-a-little-lamb")
|
45
|
+
expect(redirect_page.destination("/")).to eql(dest)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-redirect-from
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- script/bootstrap
|
90
90
|
- script/cibuild
|
91
91
|
- script/release
|
92
|
+
- script/test
|
92
93
|
- spec/fixtures/_articles/redirect-me-plz.md
|
93
94
|
- spec/fixtures/_articles/redirect-somewhere-else-plz.html
|
94
95
|
- spec/fixtures/_authors/kansaichris.md
|