jekyll-redirect-from 0.6.1 → 0.6.2

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: 3748b8949a4ce56e23c6f7e6a20a2e3302d4df62
4
- data.tar.gz: f4075f5f4f505b59701a48b44e6cc91dfb38a8cd
3
+ metadata.gz: 47035373089df8e9b0a6f22de4b389a6d11947c6
4
+ data.tar.gz: c93eed49a5d32f3cd5831460909f905d13d24799
5
5
  SHA512:
6
- metadata.gz: 99d1ececc18c3862930d563f60cc3383bb647d198eac0aa486ebe6fa442ed92be7e043d1d20f9b7d0d072de0920027705c7bb74ee1128fbf6dc980b895df0fda
7
- data.tar.gz: a22197a5c8ea7c3b914571a71ccd1da7daac4f2b4bde1932ce50d2d4426944eedce1a5a19e6b4910e8450c1f5d8a2cfddc94b52934e7500996ec7bbf284a3843
6
+ metadata.gz: 5f0c2d2340649cc9de1ad797ce127dcba66d5720a3e3f9f8af30f1bf5c85b6f364637129c9f862e72af0843b79699f307f6fc73d3f732b81044ee96a5066c4f4
7
+ data.tar.gz: 34b91e287cd20a980c737470d3e80921a0f305865e963a55ca455d27c8cb64637dd4e03fea5cdc4ebaf750d88c49c42309819db2788a9ebbd66a6523984390cf
data/History.markdown CHANGED
@@ -1,5 +1,9 @@
1
1
  ## HEAD
2
2
 
3
+ ## 0.6.2 / 2014-09-12
4
+
5
+ * Fixed error where `redirect_to` `Document`s were not being output properly (#46)
6
+
3
7
  ## 0.6.1 / 2014-09-08
4
8
 
5
9
  * Fixed error when the `site.github` config key is not a `Hash` (#43)
data/README.md CHANGED
@@ -89,6 +89,20 @@ This is useful for scenarios where a site isn't available from the domain root,
89
89
 
90
90
  **_Note_**: If you are hosting your Jekyll site on [GitHub Pages](https://pages.github.com/), the prefix is set to the pages domain name i.e. `http://example.github.io/project` or a custom `CNAME`.
91
91
 
92
+ ### Redirect To
93
+
94
+ Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the `redirect_to` key:
95
+
96
+ ```yaml
97
+ title: My amazing post
98
+ redirect_to:
99
+ - www.github.com
100
+ ```
101
+
102
+ If you have multiple `redirect_to`s set, only the first one will be respected.
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.
105
+
92
106
  ## Contributing
93
107
 
94
108
  1. Fork it
@@ -24,7 +24,11 @@ module JekyllRedirectFrom
24
24
  redirect_page = RedirectPage.new(site, site.source, File.dirname(item.url), File.basename(item.url))
25
25
  redirect_page.data['permalink'] = item.url
26
26
  redirect_page.generate_redirect_content(alt_url)
27
- site.pages << redirect_page
27
+ if item.is_a?(Jekyll::Document)
28
+ item.content = item.output = redirect_page.content
29
+ else
30
+ site.pages << redirect_page
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllRedirectFrom
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Please redirect away from me, sir.
3
+ redirect_to: "http://www.zombo.com"
4
+ ---
5
+
6
+ Boo.
@@ -3,7 +3,8 @@ require "spec_helper"
3
3
  describe JekyllRedirectFrom::Redirector do
4
4
  let(:redirector) { described_class.new }
5
5
  let(:post_to_redirect) { setup_post("2014-01-03-redirect-me-plz.md") }
6
- let(:doc_to_redirect) { setup_doc }
6
+ let(:doc_to_redirect_from) { setup_doc("redirect-me-plz.md") }
7
+ let(:doc_to_redirect_to) { setup_doc("redirect-somewhere-else-plz.html") }
7
8
  let(:page_with_one) { setup_page("one_redirect_url.md") }
8
9
  let(:page_with_many) { setup_page("multiple_redirect_urls.md") }
9
10
  let(:page_with_one_redirect_to) { setup_page("one_redirect_to.md") }
@@ -14,7 +15,11 @@ describe JekyllRedirectFrom::Redirector do
14
15
  end
15
16
 
16
17
  it "knows if a document is requesting a redirect page" do
17
- expect(redirector.has_alt_urls?(doc_to_redirect)).to be_truthy
18
+ expect(redirector.has_alt_urls?(doc_to_redirect_from)).to be_truthy
19
+ end
20
+
21
+ it "knows if a document is requesting a redirect away" do
22
+ expect(redirector.redirect_to_url(doc_to_redirect_to)).to eql(["http://www.zombo.com"])
18
23
  end
19
24
 
20
25
  it "handles one redirect path" do
@@ -53,6 +58,11 @@ describe JekyllRedirectFrom::Redirector do
53
58
  expect(destination_file_exists?("mencius/was/my/father")).to be_truthy
54
59
  end
55
60
 
61
+ it "generates the refresh page for the collection with one redirect_to url" do
62
+ expect(@dest.join("articles", "redirect-somewhere-else-plz.html")).to exist
63
+ expect(destination_doc_contents("articles", "redirect-somewhere-else-plz.html")).to include(%|<meta http-equiv=refresh content="0; url=http://www.zombo.com">|)
64
+ end
65
+
56
66
  it "generates the refresh page for the page with one redirect_to url" do
57
67
  expect(destination_file_exists?("one_redirect_to.html")).to be_truthy
58
68
  expect(destination_file_contents("one_redirect_to.html")).to include(%|<meta http-equiv=refresh content="0; url=https://www.github.com">|)
@@ -80,7 +90,7 @@ describe JekyllRedirectFrom::Redirector do
80
90
  @site.config['baseurl'] = "/fancy/baseurl"
81
91
  expect(redirector.redirect_url(@site, page_with_one)).to start_with("http://example.github.io/test")
82
92
  end
83
-
93
+
84
94
  it "no-ops when site.github.url and site.baseurl are not set" do
85
95
  expect(redirector.redirect_url(@site, page_with_one)).to eql("/one_redirect_url.html")
86
96
  end
data/spec/spec_helper.rb CHANGED
@@ -41,8 +41,8 @@ RSpec.configure do |config|
41
41
  @site.collections["authors"].docs.first
42
42
  end
43
43
 
44
- def setup_doc
45
- @site.collections["articles"].docs.first
44
+ def setup_doc(doc_filename)
45
+ @site.collections["articles"].docs.find { |d| d.relative_path.match(doc_filename) }
46
46
  end
47
47
 
48
48
  def setup_post(file)
@@ -61,6 +61,10 @@ RSpec.configure do |config|
61
61
  File.read(File.join(@dest.to_s, file))
62
62
  end
63
63
 
64
+ def destination_doc_contents(collection, file)
65
+ File.read(File.join(@dest.to_s, collection, file))
66
+ end
67
+
64
68
  def new_redirect_page(permalink)
65
69
  page = JekyllRedirectFrom::RedirectPage.new(@site, @site.source, "", "")
66
70
  page.data['permalink'] = permalink
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.6.1
4
+ version: 0.6.2
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-08 00:00:00.000000000 Z
11
+ date: 2014-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -90,6 +90,7 @@ files:
90
90
  - script/cibuild
91
91
  - script/release
92
92
  - spec/fixtures/_articles/redirect-me-plz.md
93
+ - spec/fixtures/_articles/redirect-somewhere-else-plz.html
93
94
  - spec/fixtures/_authors/kansaichris.md
94
95
  - spec/fixtures/_config.yml
95
96
  - spec/fixtures/_posts/2014-01-03-redirect-me-plz.md
@@ -127,6 +128,7 @@ specification_version: 4
127
128
  summary: Seamlessly specify multiple redirection URLs for your pages and posts
128
129
  test_files:
129
130
  - spec/fixtures/_articles/redirect-me-plz.md
131
+ - spec/fixtures/_articles/redirect-somewhere-else-plz.html
130
132
  - spec/fixtures/_authors/kansaichris.md
131
133
  - spec/fixtures/_config.yml
132
134
  - spec/fixtures/_posts/2014-01-03-redirect-me-plz.md