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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47035373089df8e9b0a6f22de4b389a6d11947c6
4
- data.tar.gz: c93eed49a5d32f3cd5831460909f905d13d24799
3
+ metadata.gz: dfb1076c07c42f81fb9f4e91d8b7a1e9959e2d58
4
+ data.tar.gz: 9ffd8729f7adc022c572bf6325b4207c5bbb5436
5
5
  SHA512:
6
- metadata.gz: 5f0c2d2340649cc9de1ad797ce127dcba66d5720a3e3f9f8af30f1bf5c85b6f364637129c9f862e72af0843b79699f307f6fc73d3f732b81044ee96a5066c4f4
7
- data.tar.gz: 34b91e287cd20a980c737470d3e80921a0f305865e963a55ca455d27c8cb64637dd4e03fea5cdc4ebaf750d88c49c42309819db2788a9ebbd66a6523984390cf
6
+ metadata.gz: f1341b8ec5a41ea28ad1954b148d5b03203842fbe9f631f233ab5a6eea53fd35f9cd178f026e733d8cfe6ca7fc8fff0f4bc2cd7bb7c689851feb7c692b663af8
7
+ data.tar.gz: 32563503dd3d74bf0c3efb15dcbcc83255c6af1d3a78500532aa4263e553872cdfe61fcbc98b99b9a6078bd4c247568726fe29a69c0a6fef53b982e7b66c6980
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
5
  - 2.1
4
6
  - 2.0
5
7
  - 1.9.3
8
+ before_script: bundle update
6
9
  script: "script/cibuild"
data/History.markdown CHANGED
@@ -1,4 +1,9 @@
1
- ## HEAD
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 ***must** end in *.html* in order for `redirect_to` to properly process.
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", "~> 2.0"
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
- <!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
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
- page_or_post.data.has_key?('redirect_from') &&
39
- !alt_urls(page_or_post).nil? &&
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
- page_or_post.data.has_key?('redirect_to') &&
49
- !alt_urls(page_or_post).nil? &&
50
- !alt_urls(page_or_post).empty?
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)
@@ -1,3 +1,3 @@
1
1
  module JekyllRedirectFrom
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.0"
3
3
  end
data/script/bootstrap CHANGED
@@ -1,3 +1,3 @@
1
1
  #! /bin/bash
2
2
 
3
- bundle install
3
+ bundle install -j8
data/script/cibuild CHANGED
@@ -1,4 +1,2 @@
1
1
  #! /bin/bash
2
-
3
- script/bootstrap > /dev/null 2>&1
4
- bundle exec rake spec
2
+ script/test $@
data/script/test ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec rake spec
@@ -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(" <!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")
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
- expect(redirect_page.destination("/")).to eql("/posts/1914798137981389/larry-had-a-little-lamb/index.html")
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
- expect(redirect_page.destination("/")).to eql("/posts/12435151125/larry-had-a-little-lamb")
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
@@ -37,6 +37,10 @@ RSpec.configure do |config|
37
37
  @dest.rmtree if @dest.exist?
38
38
  end
39
39
 
40
+ def dest_dir(*paths)
41
+ File.join(@dest.to_s, *paths)
42
+ end
43
+
40
44
  def unpublished_doc
41
45
  @site.collections["authors"].docs.first
42
46
  end
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.6.2
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: 2014-09-13 00:00:00.000000000 Z
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