jekyll-redirect-from 0.9.0 → 0.9.1
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/History.markdown +5 -0
- data/README.md +11 -1
- data/lib/jekyll-redirect-from/redirect_page.rb +4 -4
- data/lib/jekyll-redirect-from/redirector.rb +3 -1
- data/lib/jekyll-redirect-from/version.rb +1 -1
- data/spec/jekyll_redirect_from/redirect_page_spec.rb +4 -4
- data/spec/jekyll_redirect_from/redirector_spec.rb +8 -3
- data/spec/spec_helper.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d02e44aaf2c3a2c7fb503ad76226e05910dd092
|
4
|
+
data.tar.gz: 0520c094f2ada7609791410bc9dbe0c80cdff345
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa17956617938d9c608ee4f61fabcd86142c7ac8307cbc5ad6498eb6c433395e7ca42467f6bd7b6657e7dc63f815a5595c6c2345202009fd4b4b22aa6f79ba70
|
7
|
+
data.tar.gz: 01117527d4cdea7a53f59cec4addc7e046d23f5e9895e33043f7f26777e3ff3075e0f4b18e1a615f2e06b42d01849d5493b3e18a9a420151c2f1716e36806765
|
data/History.markdown
CHANGED
data/README.md
CHANGED
@@ -38,10 +38,20 @@ gems:
|
|
38
38
|
- jekyll-redirect-from
|
39
39
|
```
|
40
40
|
|
41
|
+
If you're using Jekyll in `safe` mode to mimic GitHub Pages, make sure to
|
42
|
+
add jekyll-redirect-from to your whitelist:
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
whitelist:
|
46
|
+
- jekyll-redirect-from
|
47
|
+
```
|
48
|
+
|
49
|
+
Then run `jekyll <cmd> --safe` like normal.
|
50
|
+
|
41
51
|
## Usage
|
42
52
|
|
43
53
|
The object of this gem is to allow an author to specify multiple URLs for a
|
44
|
-
page, such that the alternative URLs redirect to the new Jekyll URL.
|
54
|
+
page, such that the alternative URLs redirect to the new Jekyll URL.
|
45
55
|
|
46
56
|
To use it, simply add the array to the YAML front-matter of your page or post:
|
47
57
|
|
@@ -19,13 +19,13 @@ module JekyllRedirectFrom
|
|
19
19
|
def generate_redirect_content(item_url)
|
20
20
|
self.output = self.content = <<-EOF
|
21
21
|
<!DOCTYPE html>
|
22
|
-
<meta charset=utf-8>
|
22
|
+
<meta charset="utf-8">
|
23
23
|
<title>Redirecting...</title>
|
24
|
-
<link rel=canonical href="#{item_url}">
|
25
|
-
<meta http-equiv=refresh content="0; url=#{item_url}">
|
24
|
+
<link rel="canonical" href="#{item_url}">
|
25
|
+
<meta http-equiv="refresh" content="0; url=#{item_url}">
|
26
26
|
<h1>Redirecting...</h1>
|
27
27
|
<a href="#{item_url}">Click here if you are not redirected.</a>
|
28
|
-
<script>location=
|
28
|
+
<script>location="#{item_url}"</script>
|
29
29
|
EOF
|
30
30
|
end
|
31
31
|
end
|
@@ -74,7 +74,9 @@ module JekyllRedirectFrom
|
|
74
74
|
|
75
75
|
def config_github_url(site)
|
76
76
|
github_config = site.config['github']
|
77
|
-
|
77
|
+
if github_config.is_a?(Hash) && github_config['url']
|
78
|
+
github_config['url'].to_s
|
79
|
+
end
|
78
80
|
end
|
79
81
|
|
80
82
|
def config_baseurl(site)
|
@@ -8,19 +8,19 @@ 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("<!DOCTYPE html>\n<meta charset
|
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
|
15
|
-
expect(page_content).to include("<meta http-equiv
|
15
|
+
expect(page_content).to include("<meta http-equiv=\"refresh\" content=\"0; url=#{item_url}\">")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "contains JavaScript redirect" do
|
19
|
-
expect(page_content).to include("location
|
19
|
+
expect(page_content).to include("location=\"http://jekyllrb.com/2014/01/03/moving-to-jekyll.md\"")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "contains canonical link in header" do
|
23
|
-
expect(page_content).to include("<link rel
|
23
|
+
expect(page_content).to include("<link rel=\"canonical\" href=\"http://jekyllrb.com/2014/01/03/moving-to-jekyll.md\">")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "contains a clickable link to redirect" do
|
@@ -68,17 +68,17 @@ describe JekyllRedirectFrom::Redirector do
|
|
68
68
|
|
69
69
|
it "generates the refresh page for the collection with one redirect_to url" do
|
70
70
|
expect(@dest.join("articles", "redirect-somewhere-else-plz.html")).to exist
|
71
|
-
expect(destination_doc_contents("articles", "redirect-somewhere-else-plz.html")).to include(%|<meta http-equiv=refresh content="0; url=http://www.zombo.com">|)
|
71
|
+
expect(destination_doc_contents("articles", "redirect-somewhere-else-plz.html")).to include(%|<meta http-equiv="refresh" content="0; url=http://www.zombo.com">|)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "generates the refresh page for the page with one redirect_to url" do
|
75
75
|
expect(destination_file_exists?("one_redirect_to.html")).to be_truthy
|
76
|
-
expect(destination_file_contents("one_redirect_to.html")).to include(%|<meta http-equiv=refresh content="0; url=https://www.github.com">|)
|
76
|
+
expect(destination_file_contents("one_redirect_to.html")).to include(%|<meta http-equiv="refresh" content="0; url=https://www.github.com">|)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "generates the refresh page for the page with multiple redirect_to urls" do
|
80
80
|
expect(destination_file_exists?("multiple_redirect_tos.html")).to be_truthy
|
81
|
-
expect(destination_file_contents("multiple_redirect_tos.html")).to include(%|<meta http-equiv=refresh content="0; url=https://www.jekyllrb.com">|)
|
81
|
+
expect(destination_file_contents("multiple_redirect_tos.html")).to include(%|<meta http-equiv="refresh" content="0; url=https://www.jekyllrb.com">|)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -88,6 +88,11 @@ describe JekyllRedirectFrom::Redirector do
|
|
88
88
|
expect(redirector.redirect_url(@site, page_with_one)).to start_with("http://example.github.io/test")
|
89
89
|
end
|
90
90
|
|
91
|
+
it "converts non-string values in site.github.url to strings" do
|
92
|
+
@site.config['github'] = { "url" => TestStringContainer.new("http://example.github.io/test") }
|
93
|
+
expect(redirector.redirect_url(@site, page_with_one)).to start_with("http://example.github.io/test")
|
94
|
+
end
|
95
|
+
|
91
96
|
it "uses site.baseurl as the redirect prefix when site.github.url is not set" do
|
92
97
|
@site.config['baseurl'] = "/fancy/prefix"
|
93
98
|
expect(redirector.redirect_url(@site, page_with_one)).to start_with("/fancy/prefix")
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-redirect-from
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.2.
|
139
|
+
rubygems_version: 2.2.5
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Seamlessly specify multiple redirection URLs for your pages and posts
|