jekyll-redirect-from 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -1
- data/History.markdown +20 -0
- data/README.md +14 -5
- data/jekyll-redirect-from.gemspec +2 -2
- data/lib/jekyll-redirect-from/generator.rb +11 -3
- data/lib/jekyll-redirect-from/redirect_page.rb +1 -1
- data/lib/jekyll-redirect-from/version.rb +1 -1
- data/spec/jekyll_redirect_from/generator_spec.rb +24 -2
- data/spec/spec_helper.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa57b2c808238484878ca1bf88007e53d33913ebaf9dd17d8f8adbfa306c49a
|
4
|
+
data.tar.gz: 82bf36aaf666d402f9d0c8058cfd92b77bfb15170de288cb82d0eddc2b512c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2482574aba0bf20ebee0a17757a0bd1f967bfb70c0ddd0a8a4168d7da2105e7bf6763528ff15bdb1aca90ae7bfc068dc222ea4f1918e005f2805743d891f0cb1
|
7
|
+
data.tar.gz: 57dda6d4f263907a82f17baa9b9657cf33343c3f941f033c56563c8cf6f698445f4f691254422a59f948dc0b384b1a91d78e0b17106feb664a5393c95b23587a
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/History.markdown
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 0.16.0 / 2020-01-26
|
2
|
+
|
3
|
+
### Minor Enhancements
|
4
|
+
|
5
|
+
* Allows generation of `redirects.json` to be disabled (#207)
|
6
|
+
* Allow redirects from and for subclasses of page and document (#204)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* Use `Hash#key?` instead of `Hash#keys.any?` (#201)
|
11
|
+
|
12
|
+
### Development Fixes
|
13
|
+
|
14
|
+
* Target Ruby 2.4
|
15
|
+
* Stop testing with backwards-compatible site config (#211)
|
16
|
+
|
17
|
+
### Documentation
|
18
|
+
|
19
|
+
* Simplifies YAML for `redirect_to` (#185)
|
20
|
+
|
1
21
|
## 0.15.0 / 2019-03-23
|
2
22
|
|
3
23
|
### Development Fixes
|
data/README.md
CHANGED
@@ -113,13 +113,9 @@ Sometimes, you may want to redirect a site page to a totally different website.
|
|
113
113
|
|
114
114
|
```yaml
|
115
115
|
title: My amazing post
|
116
|
-
redirect_to:
|
117
|
-
- http://www.github.com
|
116
|
+
redirect_to: http://www.github.com
|
118
117
|
```
|
119
118
|
|
120
|
-
If you have multiple `redirect_to`s set, only the first one will be respected.
|
121
|
-
|
122
|
-
|
123
119
|
**Note**: Using `redirect_to` or `redirect_from` with collections will only work with files which are output to HTML, such as `.md`, `.textile`, `.html` etc.
|
124
120
|
|
125
121
|
## Customizing the redirect template
|
@@ -131,6 +127,19 @@ Your layout will get the following variables:
|
|
131
127
|
* `page.redirect.from` - the relative path to the redirect page
|
132
128
|
* `page.redirect.to` - the absolute URL (where available) to the target page
|
133
129
|
|
130
|
+
## Configuration
|
131
|
+
|
132
|
+
You can configure this plugin in `_config.yml` by adding to the `redirect_from` key.
|
133
|
+
|
134
|
+
### Disabling `redirects.json`
|
135
|
+
|
136
|
+
By default, a file called `redirects.json`, which can be used for automated testing or to implement server-side redirects, will be included in the output. To exclude it from the output, set the `json` key to `false`:
|
137
|
+
|
138
|
+
```yml
|
139
|
+
redirect_from:
|
140
|
+
json: false
|
141
|
+
```
|
142
|
+
|
134
143
|
## Contributing
|
135
144
|
|
136
145
|
1. Fork it
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.required_ruby_version = ">= 2.
|
25
|
+
spec.required_ruby_version = ">= 2.4.0"
|
26
26
|
|
27
27
|
spec.add_runtime_dependency "jekyll", ">= 3.3", "< 5.0"
|
28
28
|
|
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "jekyll-sitemap", "~> 1.0"
|
31
31
|
spec.add_development_dependency "rake", "~> 12.0"
|
32
32
|
spec.add_development_dependency "rspec", "~> 3.5"
|
33
|
-
spec.add_development_dependency "rubocop-jekyll", "~> 0.
|
33
|
+
spec.add_development_dependency "rubocop-jekyll", "~> 0.10"
|
34
34
|
end
|
@@ -10,19 +10,19 @@ module JekyllRedirectFrom
|
|
10
10
|
@redirects = {}
|
11
11
|
|
12
12
|
# Inject our layout, unless the user has already specified a redirect layout'
|
13
|
-
unless site.layouts.
|
13
|
+
unless site.layouts.key?("redirect")
|
14
14
|
site.layouts["redirect"] = JekyllRedirectFrom::Layout.new(site)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Must duplicate pages to modify while in loop
|
18
18
|
(site.docs_to_write + site.pages.dup).each do |doc|
|
19
|
-
next unless
|
19
|
+
next unless redirectable_document?(doc)
|
20
20
|
|
21
21
|
generate_redirect_from(doc)
|
22
22
|
generate_redirect_to(doc)
|
23
23
|
end
|
24
24
|
|
25
|
-
generate_redirects_json
|
25
|
+
generate_redirects_json if generate_redirects_json?
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -53,5 +53,13 @@ module JekyllRedirectFrom
|
|
53
53
|
page.data["layout"] = nil
|
54
54
|
site.pages << page
|
55
55
|
end
|
56
|
+
|
57
|
+
def redirectable_document?(doc)
|
58
|
+
doc.is_a?(Jekyll::Document) || doc.is_a?(Jekyll::Page)
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_redirects_json?
|
62
|
+
site.config.dig("redirect_from", "json") != false
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
@@ -94,7 +94,7 @@ RSpec.describe JekyllRedirectFrom::Generator do
|
|
94
94
|
let(:redirects) { JSON.parse(contents) }
|
95
95
|
let(:domain) { "http://jekyllrb.com" }
|
96
96
|
|
97
|
-
it "creates the
|
97
|
+
it "creates the redirects file" do
|
98
98
|
expect(path).to exist
|
99
99
|
end
|
100
100
|
|
@@ -140,10 +140,32 @@ RSpec.describe JekyllRedirectFrom::Generator do
|
|
140
140
|
FileUtils.rm_f source_path
|
141
141
|
end
|
142
142
|
|
143
|
-
it "doesn't overwrite
|
143
|
+
it "doesn't overwrite redirects.json" do
|
144
144
|
expect(path).to exist
|
145
145
|
expect(redirects).to eql("foo" => "bar")
|
146
146
|
end
|
147
147
|
end
|
148
|
+
|
149
|
+
context "when explicitly disabled" do
|
150
|
+
let(:site) { Jekyll::Site.new(config.merge("redirect_from" => { "json" => false })) }
|
151
|
+
|
152
|
+
it "does not create the redirects file" do
|
153
|
+
expect(path).to_not exist
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "redirectable_document?" do
|
159
|
+
let(:generator) { JekyllRedirectFrom::Generator.new }
|
160
|
+
|
161
|
+
it "accepts subclasses of Jekyll::Document" do
|
162
|
+
SubclassOfJekyllDocument = Class.new(Jekyll::Document) { define_method(:initialize) {} }
|
163
|
+
expect(generator.send(:redirectable_document?, SubclassOfJekyllDocument.new)).to be_truthy
|
164
|
+
end
|
165
|
+
|
166
|
+
it "accepts subclasses of Jekyll::Page" do
|
167
|
+
SubclassOfJekyllPage = Class.new(Jekyll::Page) { define_method(:initialize) {} }
|
168
|
+
expect(generator.send(:redirectable_document?, SubclassOfJekyllPage.new)).to be_truthy
|
169
|
+
end
|
148
170
|
end
|
149
171
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -42,7 +42,7 @@ RSpec.configure do |config|
|
|
42
42
|
"authors" => {},
|
43
43
|
},
|
44
44
|
"url" => "http://jekyllrb.com",
|
45
|
-
"
|
45
|
+
"plugins" => [
|
46
46
|
"jekyll-redirect-from",
|
47
47
|
"jekyll-sitemap",
|
48
48
|
],
|
@@ -50,7 +50,7 @@ RSpec.configure do |config|
|
|
50
50
|
"scope" => { "path" => "" },
|
51
51
|
"values" => { "layout" => "layout" },
|
52
52
|
}]
|
53
|
-
)
|
53
|
+
)
|
54
54
|
end
|
55
55
|
|
56
56
|
def site
|
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.
|
4
|
+
version: 0.16.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: 2020-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0.
|
95
|
+
version: '0.10'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0.
|
102
|
+
version: '0.10'
|
103
103
|
description:
|
104
104
|
email:
|
105
105
|
- parkrmoore@gmail.com
|
@@ -163,14 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements:
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.
|
166
|
+
version: 2.4.0
|
167
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
169
|
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.0.
|
173
|
+
rubygems_version: 3.0.6
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Seamlessly specify multiple redirection URLs for your pages and posts
|