jekyll-alt-urls 0.1.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +1 -0
- data/jekyll-alt-urls.gemspec +25 -0
- data/lib/jekyll/alt_urls.rb +33 -0
- data/lib/jekyll/alt_urls/redirect_page.rb +41 -0
- data/lib/jekyll/alt_urls/version.rb +5 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3532504f9bb46f9cfc667103cd1cfd23947c122d
|
4
|
+
data.tar.gz: ef1e1f3cb2ae4cb17446aa08f0ecc58166a59422
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67a6e7a19681c58bc42fc92fe4e159df25aeda12d1bc9906f7d16bb6d77db6b980f04f00e6dab67e06d2a799d63e2e747a8efceb7b3a505f47aed4d7f593d010
|
7
|
+
data.tar.gz: 461597478592cd6125fc4b5c7f4d5d0e234e781fd744b0e7dc7f2b27fd141db752ab78526ceafd871dd1f62d725cbc6efdfbfd57f6e9f24fdbcc082bf36cc669
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 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
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Jekyll::AltUrls
|
2
|
+
|
3
|
+
Give your Jekyll 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
|
+
`jekyll-alt-urls` handle it for you.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'jekyll-alt-urls'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install jekyll-alt-urls
|
25
|
+
|
26
|
+
Once it's installed into your evironment, add it to your `_config.yml`:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
gem:
|
30
|
+
- jekyll-alt-urls
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
The object of this gem is to allow an author to specify multiple URLs for a
|
36
|
+
page, such that the alternative URLs redirect to the new Jekyll URL. This is
|
37
|
+
|
38
|
+
To use it, simply add the array to the YAML front-matter of your page or post:
|
39
|
+
|
40
|
+
```yaml
|
41
|
+
title: My amazing post
|
42
|
+
alt_urls:
|
43
|
+
- /post/123456789
|
44
|
+
- /post/123456789/my-amazing-post
|
45
|
+
```
|
46
|
+
|
47
|
+
This will generate the following pages in the destination:
|
48
|
+
|
49
|
+
```text
|
50
|
+
/post/123456789/index.html
|
51
|
+
/post/123456789/my-amazing-post/index.html
|
52
|
+
```
|
53
|
+
|
54
|
+
These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll/alt_urls/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-alt-urls"
|
8
|
+
spec.version = Jekyll::AltUrls::VERSION
|
9
|
+
spec.authors = ["Parker Moore"]
|
10
|
+
spec.email = ["parkrmoore@gmail.com"]
|
11
|
+
spec.description = %q{Seamlessly specify multiple redirection URLs for your pages and posts}
|
12
|
+
spec.summary = %q{Seamlessly specify multiple redirection URLs for your pages and posts}
|
13
|
+
spec.homepage = "https://github.com/jekyll/jekyll-alt-urls"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "jekyll", "~> 1.4"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "jekyll/alt_urls/version"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class AltUrls < Generator
|
5
|
+
def generate(site)
|
6
|
+
original_pages = site.pages.dup
|
7
|
+
generate_alt_urls(site, site.posts)
|
8
|
+
generate_alt_urls(site, original_pages)
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate_alt_urls(site, list)
|
12
|
+
list.each do |item|
|
13
|
+
if has_alt_urls?(item)
|
14
|
+
alt_urls(item).flatten.each do |alt_url|
|
15
|
+
redirect_page = RedirectPage.new(site, site.source, File.dirname(alt_url), File.basename(alt_url))
|
16
|
+
redirect_page.generate_redirect_content(item.url)
|
17
|
+
site.pages << redirect_page
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_alt_urls?(page_or_post)
|
24
|
+
page_or_post.data.has_key?('alt_urls') &&
|
25
|
+
!alt_urls(page_or_post).nil? &&
|
26
|
+
alt_urls(page_or_post).is_a?(Array)
|
27
|
+
end
|
28
|
+
|
29
|
+
def alt_urls(page_or_post)
|
30
|
+
page_or_post.data['alt_urls']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class AltUrls < Generator
|
3
|
+
class RedirectPage < Page
|
4
|
+
# Initialize a new RedirectPage.
|
5
|
+
#
|
6
|
+
# site - The Site object.
|
7
|
+
# base - The String path to the source.
|
8
|
+
# dir - The String path between the source and the file.
|
9
|
+
# name - The String filename of the file.
|
10
|
+
def initialize(site, base, dir, name)
|
11
|
+
@site = site
|
12
|
+
@base = base
|
13
|
+
@dir = dir
|
14
|
+
@name = name
|
15
|
+
|
16
|
+
self.process(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_redirect_content(item_url)
|
20
|
+
self.content = <<-EOF
|
21
|
+
<!DOCTYPE html>
|
22
|
+
<html>
|
23
|
+
<head>
|
24
|
+
<title>Redirecting...</title>
|
25
|
+
<link rel="canonical" href="#{item_url}"/>
|
26
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
27
|
+
<meta http-equiv="refresh" content="0; url=#{item_url}" />
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<p><strong>Redirecting...</strong></p>
|
31
|
+
<p><a href='#{item_url}'>Click here if you are not redirected.</a></p>
|
32
|
+
<script>
|
33
|
+
document.location.href = "#{item_url}";
|
34
|
+
</script>
|
35
|
+
</body>
|
36
|
+
</html>
|
37
|
+
EOF
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-alt-urls
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Parker Moore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Seamlessly specify multiple redirection URLs for your pages and posts
|
56
|
+
email:
|
57
|
+
- parkrmoore@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- jekyll-alt-urls.gemspec
|
68
|
+
- lib/jekyll/alt_urls.rb
|
69
|
+
- lib/jekyll/alt_urls/redirect_page.rb
|
70
|
+
- lib/jekyll/alt_urls/version.rb
|
71
|
+
homepage: https://github.com/jekyll/jekyll-alt-urls
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.0.14
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Seamlessly specify multiple redirection URLs for your pages and posts
|
95
|
+
test_files: []
|