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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8fa3fc03dd67c563c6018790133a100fcc0f04912859e8622efb6762116fc08
4
- data.tar.gz: fce8c765fea3f6f17ae338fee50ce01331c91cc1f083f26d4294681b709972eb
3
+ metadata.gz: aaa57b2c808238484878ca1bf88007e53d33913ebaf9dd17d8f8adbfa306c49a
4
+ data.tar.gz: 82bf36aaf666d402f9d0c8058cfd92b77bfb15170de288cb82d0eddc2b512c90
5
5
  SHA512:
6
- metadata.gz: 217696213cdf50a1f85dc636ced9efa29dd80567837989a00c87b7f68add82c84a74eb2319a547e3f04612b04eb8731685490d79a334ac85121fb78063d791fe
7
- data.tar.gz: 01044dde063223161451b32fd6a4fa56cc17451eae306b88065f56a72e21b5f8f3b63f10fb0aba19bc7a6856e20b84d9fcad9ad920f7c7bc500e15ba70950c0a
6
+ metadata.gz: 2482574aba0bf20ebee0a17757a0bd1f967bfb70c0ddd0a8a4168d7da2105e7bf6763528ff15bdb1aca90ae7bfc068dc222ea4f1918e005f2805743d891f0cb1
7
+ data.tar.gz: 57dda6d4f263907a82f17baa9b9657cf33343c3f941f033c56563c8cf6f698445f4f691254422a59f948dc0b384b1a91d78e0b17106feb664a5393c95b23587a
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ spec/fixtures/.jekyll-cache
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
+ vendor/bundle
@@ -6,6 +6,6 @@ inherit_gem:
6
6
  rubocop-jekyll: .rubocop.yml
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: 2.3
9
+ TargetRubyVersion: 2.4
10
10
  Exclude:
11
11
  - vendor/**/*
@@ -12,7 +12,7 @@ matrix:
12
12
  rvm: 2.5.3
13
13
  env: GH_PAGES=true
14
14
  - rvm: *latest_ruby
15
- env: JEKYLL_VERSION=">= 4.0.0.pre.alpha1"
15
+ env: JEKYLL_VERSION="~> 4.0"
16
16
 
17
17
  before_install:
18
18
  - gem update --system
@@ -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.3.0"
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.4"
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.keys.any? { |name| name == "redirect" }
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 JekyllRedirectFrom::CLASSES.include?(doc.class)
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
@@ -49,7 +49,7 @@ module JekyllRedirectFrom
49
49
  "permalink" => from,
50
50
  "redirect" => {
51
51
  "from" => from,
52
- "to" => to =~ %r!^https?://! ? to : absolute_url(to),
52
+ "to" => %r!^https?://!.match?(to) ? to : absolute_url(to),
53
53
  }
54
54
  )
55
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllRedirectFrom
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.0"
5
5
  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 redirets file" do
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 redirets.json" do
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
@@ -42,7 +42,7 @@ RSpec.configure do |config|
42
42
  "authors" => {},
43
43
  },
44
44
  "url" => "http://jekyllrb.com",
45
- "gems" => [
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
- ).backwards_compatibilize
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.15.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: 2019-03-23 00:00:00.000000000 Z
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.4'
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.4'
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.3.0
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.3
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