jekyll-redirect-from 0.2.0 → 0.3.0
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 +10 -0
- data/README.md +4 -5
- data/lib/jekyll-redirect-from/redirector.rb +2 -1
- data/lib/jekyll-redirect-from/version.rb +1 -1
- data/script/release +3 -0
- data/spec/jekyll_redirect_from/redirect_page_spec.rb +21 -3
- data/spec/spec_helper.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f48702f5b873fef8239a201f6a7dc3d759f605f2
|
4
|
+
data.tar.gz: b50321198ad8c462591127c64bb94484f97e7c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cba68960c4460e460bd89aeaf21493fcaa8d2475953d9ac1650f21b8ecbc1d542c7c572b58937f0e8317e5ca754e6234b8e8736b9e35b9d63f014ca9ef61f615
|
7
|
+
data.tar.gz: 2a66c019939be98292d157227ed8d84f23192743fbd8e9bea94a61a7b659dc21d01c5dd071fd791b6919fb13f42cbc0d7562a63f25dce8b4d85d252a7126bed2
|
data/History.markdown
CHANGED
@@ -8,6 +8,16 @@
|
|
8
8
|
|
9
9
|
### Development Fixes
|
10
10
|
|
11
|
+
## 0.3.0 / 2014-01-15
|
12
|
+
|
13
|
+
### Major Enhancements
|
14
|
+
|
15
|
+
* `redirect_from` items are now proper permalinks rooted in site source (#8)
|
16
|
+
|
17
|
+
### Development Fixes
|
18
|
+
|
19
|
+
* Add forgotten `s` to `gems` in README.md (#7)
|
20
|
+
|
11
21
|
## 0.2.0 / 2014-01-04
|
12
22
|
|
13
23
|
### Minor Enhancements
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
|
|
28
28
|
Once it's installed into your evironment, add it to your `_config.yml`:
|
29
29
|
|
30
30
|
```yaml
|
31
|
-
|
31
|
+
gems:
|
32
32
|
- jekyll-redirect-from
|
33
33
|
```
|
34
34
|
|
@@ -49,14 +49,13 @@ redirect_from:
|
|
49
49
|
This will generate the following pages in the destination:
|
50
50
|
|
51
51
|
```text
|
52
|
-
/post/123456789
|
53
|
-
/post/123456789/my-amazing-post
|
52
|
+
/post/123456789
|
53
|
+
/post/123456789/my-amazing-post
|
54
54
|
```
|
55
55
|
|
56
56
|
These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.
|
57
57
|
|
58
|
-
You can also specify just one url like this:
|
59
|
-
|
58
|
+
You can also specify just **one url** like this:
|
60
59
|
|
61
60
|
```text
|
62
61
|
title: My other awesome post
|
@@ -10,7 +10,8 @@ module JekyllRedirectFrom
|
|
10
10
|
list.each do |item|
|
11
11
|
if has_alt_urls?(item)
|
12
12
|
alt_urls(item).flatten.each do |alt_url|
|
13
|
-
redirect_page = RedirectPage.new(site, site.source,
|
13
|
+
redirect_page = RedirectPage.new(site, site.source, "", "")
|
14
|
+
redirect_page.data['permalink'] = alt_url
|
14
15
|
redirect_page.generate_redirect_content(item.url)
|
15
16
|
site.pages << redirect_page
|
16
17
|
end
|
data/script/release
ADDED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe JekyllRedirectFrom::RedirectPage do
|
4
|
-
let(:
|
4
|
+
let(:permalink) { "/posts/12435151125/larry-had-a-little-lamb" }
|
5
|
+
let(:redirect_page) { new_redirect_page(permalink) }
|
5
6
|
let(:item_url) { File.join(@site.config["url"], "2014", "01", "03", "moving-to-jekyll.md") }
|
6
7
|
let(:page_content) { redirect_page.generate_redirect_content(item_url) }
|
7
8
|
|
@@ -27,6 +28,23 @@ describe JekyllRedirectFrom::RedirectPage do
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
31
|
+
context "when determining the write destination" do
|
32
|
+
context "of a redirect page meant to be a dir" do
|
33
|
+
let(:permalink_dir) { "/posts/1914798137981389/larry-had-a-little-lamb/" }
|
34
|
+
let(:redirect_page) { new_redirect_page(permalink_dir) }
|
35
|
+
|
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")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "of a redirect page meant to be a file" do
|
42
|
+
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
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
30
48
|
context "when writing to disk" do
|
31
49
|
let(:redirect_page_full_path) { redirect_page.destination(@site.dest) }
|
32
50
|
|
@@ -36,7 +54,7 @@ describe JekyllRedirectFrom::RedirectPage do
|
|
36
54
|
end
|
37
55
|
|
38
56
|
it "fetches the path properly" do
|
39
|
-
expect(redirect_page_full_path).to match /\/spec\/fixtures\/\_site\/posts\/12435151125\/larry-had-a-little-lamb
|
57
|
+
expect(redirect_page_full_path).to match /\/spec\/fixtures\/\_site\/posts\/12435151125\/larry-had-a-little-lamb$/
|
40
58
|
end
|
41
59
|
|
42
60
|
it "is written to the proper location" do
|
@@ -47,4 +65,4 @@ describe JekyllRedirectFrom::RedirectPage do
|
|
47
65
|
expect(File.read(redirect_page_full_path)).to eql(page_content)
|
48
66
|
end
|
49
67
|
end
|
50
|
-
end
|
68
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -45,4 +45,10 @@ RSpec.configure do |config|
|
|
45
45
|
def destination_file_exists?(file)
|
46
46
|
File.exists?(File.join(@dest.to_s, file))
|
47
47
|
end
|
48
|
+
|
49
|
+
def new_redirect_page(permalink)
|
50
|
+
page = JekyllRedirectFrom::RedirectPage.new(@site, @site.source, "", "")
|
51
|
+
page.data['permalink'] = permalink
|
52
|
+
page
|
53
|
+
end
|
48
54
|
end
|
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.3.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-01-
|
11
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/jekyll-redirect-from/version.rb
|
89
89
|
- script/bootstrap
|
90
90
|
- script/cibuild
|
91
|
+
- script/release
|
91
92
|
- spec/fixtures/_config.yml
|
92
93
|
- spec/fixtures/_posts/2014-01-03-redirect-me-plz.md
|
93
94
|
- spec/fixtures/multiple_redirect_urls.md
|