bunto-redirect-from 5.0.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -18
- data/.rspec +2 -2
- data/.travis.yml +26 -26
- data/Gemfile +8 -8
- data/History.markdown +4 -3
- data/LICENSE.txt +22 -22
- data/README.md +129 -128
- data/Rakefile +6 -6
- data/bunto-redirect-from.gemspec +27 -27
- data/lib/bunto-redirect-from.rb +11 -4
- data/lib/bunto-redirect-from/redirect_page.rb +42 -34
- data/lib/bunto-redirect-from/redirector.rb +90 -86
- data/lib/bunto-redirect-from/version.rb +3 -3
- data/script/bootstrap +3 -3
- data/script/cibuild +4 -4
- data/script/release +3 -3
- data/script/test +2 -0
- data/spec/bunto_redirect_from/redirect_page_spec.rb +76 -72
- data/spec/bunto_redirect_from/redirector_spec.rb +149 -116
- data/spec/fixtures/_articles/redirect-me-plz.md +6 -6
- data/spec/fixtures/_articles/redirect-somewhere-else-im-a-permalink.html +7 -0
- data/spec/fixtures/_articles/redirect-somewhere-else-plz.html +6 -6
- data/spec/fixtures/_authors/kansaichris.md +5 -5
- data/spec/fixtures/_config.yml +7 -7
- data/spec/fixtures/_layouts/layout.html +6 -0
- data/spec/fixtures/_posts/2014-01-03-redirect-me-plz.md +6 -6
- data/spec/fixtures/multiple_redirect_tos.md +9 -9
- data/spec/fixtures/multiple_redirect_urls.md +10 -10
- data/spec/fixtures/one_redirect_to.md +6 -6
- data/spec/fixtures/one_redirect_url.md +6 -6
- data/spec/fixtures/tags/how we work.md +4 -0
- data/spec/integrations_spec.rb +13 -13
- data/spec/spec_helper.rb +88 -91
- metadata +18 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c81ffd0d28d8a47a8da2c647791c84c85940d89
|
4
|
+
data.tar.gz: 1e0d348db8ed13e868ce2a1c2f0b5cd509c48eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ca1612fb32ac2e0f4d39966721c7236f055e61f8dbf18f06bc4a684739f0f2aec9c7aa7e2318e0fcc29d26e1cecb4409035f5c1e5cfedd5c1498360e538d68
|
7
|
+
data.tar.gz: f8acb181e8a0431427c7cdfb3a336f332abe03528797ad9fb327e7fb35c225d5c55a7fb4220db6175091a0647fcf311fce309f6e59de58401df4e2b2f0da3f9f
|
data/.gitignore
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
spec/fixtures/.bunto-metadata
|
16
|
-
test/tmp
|
17
|
-
test/version_tmp
|
18
|
-
tmp
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
spec/fixtures/.bunto-metadata
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--color
|
2
|
-
--format progress
|
1
|
+
--color
|
2
|
+
--format progress
|
data/.travis.yml
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
env:
|
24
|
-
- ""
|
25
|
-
- BUNTO_VERSION=
|
26
|
-
- BUNTO_VERSION=1
|
1
|
+
# Travis CI
|
2
|
+
language: ruby
|
3
|
+
before_script:
|
4
|
+
- chmod a+x script/bootstrap
|
5
|
+
- chmod a+x script/cibuild
|
6
|
+
- chmod a+x script/release
|
7
|
+
- chmod a+x script/test
|
8
|
+
- bundle update
|
9
|
+
script: "script/cibuild"
|
10
|
+
sudo: false
|
11
|
+
cache: bundler
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
include:
|
15
|
+
- # Ruby 2.2.5
|
16
|
+
rvm: 2.2.5
|
17
|
+
env: BUNTO_VERSION=3.0.0
|
18
|
+
fast_finish: true
|
19
|
+
|
20
|
+
rvm:
|
21
|
+
- 2.3.1
|
22
|
+
- 2.3.0
|
23
|
+
env:
|
24
|
+
- ""
|
25
|
+
- BUNTO_VERSION=3.0.0
|
26
|
+
- BUNTO_VERSION=3.2.1
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
gemspec
|
3
|
-
|
4
|
-
if ENV["GH_PAGES"]
|
5
|
-
gem "github-pages"
|
6
|
-
elsif ENV["BUNTO_VERSION"]
|
7
|
-
gem "bunto", "~> #{ENV["BUNTO_VERSION"]}"
|
8
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
if ENV["GH_PAGES"]
|
5
|
+
gem "github-pages"
|
6
|
+
elsif ENV["BUNTO_VERSION"]
|
7
|
+
gem "bunto", "~> #{ENV["BUNTO_VERSION"]}"
|
8
|
+
end
|
data/History.markdown
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
##
|
2
|
-
|
3
|
-
|
1
|
+
## HEAD
|
2
|
+
|
3
|
+
## 1.0.0 / 2016-02-08
|
4
|
+
* Birthday!
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2016-present Parker Moore
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2016-present Parker Moore
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,128 +1,129 @@
|
|
1
|
-
# BuntoRedirectFrom
|
2
|
-
|
3
|
-
Give your Bunto posts and pages multiple URLs.
|
4
|
-
|
5
|
-
When importing your posts and pages from, say, Tumblr, it's annoying and
|
6
|
-
impractical to create new pages in the proper subdirectories so they, e.g.
|
7
|
-
`/post/123456789/my-slug-that-is-often-incompl`, redirect to the new post URL.
|
8
|
-
|
9
|
-
Instead of dealing with maintaining those pages for redirection, let
|
10
|
-
`bunto-redirect-from` handle it for you.
|
11
|
-
|
12
|
-
[![Build Status](https://travis-ci.org/bunto/bunto-redirect-from.svg?branch=master)](https://travis-ci.org/bunto/bunto-redirect-from)
|
13
|
-
|
14
|
-
## How it Works
|
15
|
-
|
16
|
-
Redirects are performed by serving an HTML file with an HTTP-REFRESH meta
|
17
|
-
tag which points to your destination. No `.htaccess` file, nginx conf, xml
|
18
|
-
file, or anything else will be generated. It simply creates HTML files.
|
19
|
-
|
20
|
-
## Installation
|
21
|
-
|
22
|
-
Add this line to your application's Gemfile:
|
23
|
-
|
24
|
-
gem 'bunto-redirect-from'
|
25
|
-
|
26
|
-
And then execute:
|
27
|
-
|
28
|
-
$ bundle
|
29
|
-
|
30
|
-
Or install it yourself as:
|
31
|
-
|
32
|
-
$ gem install bunto-redirect-from
|
33
|
-
|
34
|
-
Once it's installed into your evironment, add it to your `_config.yml`:
|
35
|
-
|
36
|
-
```yaml
|
37
|
-
gems:
|
38
|
-
- bunto-redirect-from
|
39
|
-
```
|
40
|
-
|
41
|
-
If you're using Bunto in `safe` mode to mimic GitHub Pages, make sure to
|
42
|
-
add bunto-redirect-from to your whitelist:
|
43
|
-
|
44
|
-
```yaml
|
45
|
-
whitelist:
|
46
|
-
- bunto-redirect-from
|
47
|
-
```
|
48
|
-
|
49
|
-
Then run `bunto <cmd> --safe` like normal.
|
50
|
-
|
51
|
-
## Usage
|
52
|
-
|
53
|
-
The object of this gem is to allow an author to specify multiple URLs for a
|
54
|
-
page, such that the alternative URLs redirect to the new Bunto URL.
|
55
|
-
|
56
|
-
To use it, simply add the array to the YAML front-matter of your page or post:
|
57
|
-
|
58
|
-
```yaml
|
59
|
-
title: My amazing post
|
60
|
-
redirect_from:
|
61
|
-
- /post/123456789/
|
62
|
-
- /post/123456789/my-amazing-post/
|
63
|
-
```
|
64
|
-
|
65
|
-
Redirects including a trailing slash will generate a corresponding subdirectory containing an `index.html`, while redirects without a trailing slash will generate a corresponding `filename` without an extension, and without a subdirectory.
|
66
|
-
|
67
|
-
For example...
|
68
|
-
|
69
|
-
```text
|
70
|
-
redirect_from:
|
71
|
-
- /post/123456789/my-amazing-post
|
72
|
-
```
|
73
|
-
|
74
|
-
...will generate the following page in the destination:
|
75
|
-
|
76
|
-
```text
|
77
|
-
/post/123456789/my-amazing-post
|
78
|
-
```
|
79
|
-
|
80
|
-
While...
|
81
|
-
|
82
|
-
```text
|
83
|
-
redirect_from:
|
84
|
-
- /post/123456789/my-amazing-post/
|
85
|
-
```
|
86
|
-
|
87
|
-
...will generate the following page in the destination:
|
88
|
-
|
89
|
-
```text
|
90
|
-
/post/123456789/my-amazing-post/index.html
|
91
|
-
```
|
92
|
-
|
93
|
-
These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.
|
94
|
-
|
95
|
-
You can also specify just **one url** like this:
|
96
|
-
|
97
|
-
```text
|
98
|
-
title: My other awesome post
|
99
|
-
redirect_from: /post/123456798/
|
100
|
-
```
|
101
|
-
|
102
|
-
### Prefix
|
103
|
-
If `site.baseurl` is set, its value is used as a prefix for the redirect url automatically.
|
104
|
-
This is useful for scenarios where a site isn't available from the domain root, so the redirects point to the correct path.
|
105
|
-
|
106
|
-
**_Note_**: If you are hosting your Bunto 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`.
|
107
|
-
|
108
|
-
### Redirect To
|
109
|
-
|
110
|
-
Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the `redirect_to` key:
|
111
|
-
|
112
|
-
```yaml
|
113
|
-
title: My amazing post
|
114
|
-
redirect_to:
|
115
|
-
- http://www.github.com
|
116
|
-
```
|
117
|
-
|
118
|
-
If you have multiple `redirect_to`s set, only the first one will be respected.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
1
|
+
# BuntoRedirectFrom
|
2
|
+
|
3
|
+
Give your Bunto posts and pages multiple URLs.
|
4
|
+
|
5
|
+
When importing your posts and pages from, say, Tumblr, it's annoying and
|
6
|
+
impractical to create new pages in the proper subdirectories so they, e.g.
|
7
|
+
`/post/123456789/my-slug-that-is-often-incompl`, redirect to the new post URL.
|
8
|
+
|
9
|
+
Instead of dealing with maintaining those pages for redirection, let
|
10
|
+
`bunto-redirect-from` handle it for you.
|
11
|
+
|
12
|
+
[![Build Status](https://travis-ci.org/bunto/bunto-redirect-from.svg?branch=master)](https://travis-ci.org/bunto/bunto-redirect-from)
|
13
|
+
|
14
|
+
## How it Works
|
15
|
+
|
16
|
+
Redirects are performed by serving an HTML file with an HTTP-REFRESH meta
|
17
|
+
tag which points to your destination. No `.htaccess` file, nginx conf, xml
|
18
|
+
file, or anything else will be generated. It simply creates HTML files.
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
gem 'bunto-redirect-from'
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
$ gem install bunto-redirect-from
|
33
|
+
|
34
|
+
Once it's installed into your evironment, add it to your `_config.yml`:
|
35
|
+
|
36
|
+
```yaml
|
37
|
+
gems:
|
38
|
+
- bunto-redirect-from
|
39
|
+
```
|
40
|
+
|
41
|
+
If you're using Bunto in `safe` mode to mimic GitHub Pages, make sure to
|
42
|
+
add bunto-redirect-from to your whitelist:
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
whitelist:
|
46
|
+
- bunto-redirect-from
|
47
|
+
```
|
48
|
+
|
49
|
+
Then run `bunto <cmd> --safe` like normal.
|
50
|
+
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
The object of this gem is to allow an author to specify multiple URLs for a
|
54
|
+
page, such that the alternative URLs redirect to the new Bunto URL.
|
55
|
+
|
56
|
+
To use it, simply add the array to the YAML front-matter of your page or post:
|
57
|
+
|
58
|
+
```yaml
|
59
|
+
title: My amazing post
|
60
|
+
redirect_from:
|
61
|
+
- /post/123456789/
|
62
|
+
- /post/123456789/my-amazing-post/
|
63
|
+
```
|
64
|
+
|
65
|
+
Redirects including a trailing slash will generate a corresponding subdirectory containing an `index.html`, while redirects without a trailing slash will generate a corresponding `filename` without an extension, and without a subdirectory.
|
66
|
+
|
67
|
+
For example...
|
68
|
+
|
69
|
+
```text
|
70
|
+
redirect_from:
|
71
|
+
- /post/123456789/my-amazing-post
|
72
|
+
```
|
73
|
+
|
74
|
+
...will generate the following page in the destination:
|
75
|
+
|
76
|
+
```text
|
77
|
+
/post/123456789/my-amazing-post
|
78
|
+
```
|
79
|
+
|
80
|
+
While...
|
81
|
+
|
82
|
+
```text
|
83
|
+
redirect_from:
|
84
|
+
- /post/123456789/my-amazing-post/
|
85
|
+
```
|
86
|
+
|
87
|
+
...will generate the following page in the destination:
|
88
|
+
|
89
|
+
```text
|
90
|
+
/post/123456789/my-amazing-post/index.html
|
91
|
+
```
|
92
|
+
|
93
|
+
These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.
|
94
|
+
|
95
|
+
You can also specify just **one url** like this:
|
96
|
+
|
97
|
+
```text
|
98
|
+
title: My other awesome post
|
99
|
+
redirect_from: /post/123456798/
|
100
|
+
```
|
101
|
+
|
102
|
+
### Prefix
|
103
|
+
If `site.baseurl` is set, its value is used as a prefix for the redirect url automatically.
|
104
|
+
This is useful for scenarios where a site isn't available from the domain root, so the redirects point to the correct path.
|
105
|
+
|
106
|
+
**_Note_**: If you are hosting your Bunto 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`.
|
107
|
+
|
108
|
+
### Redirect To
|
109
|
+
|
110
|
+
Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the `redirect_to` key:
|
111
|
+
|
112
|
+
```yaml
|
113
|
+
title: My amazing post
|
114
|
+
redirect_to:
|
115
|
+
- http://www.github.com
|
116
|
+
```
|
117
|
+
|
118
|
+
If you have multiple `redirect_to`s set, only the first one will be respected.
|
119
|
+
|
120
|
+
|
121
|
+
**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.
|
122
|
+
|
123
|
+
## Contributing
|
124
|
+
|
125
|
+
1. Fork it
|
126
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
127
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
128
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
129
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|