jekyll-relations 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +71 -0
- data/Rakefile +10 -0
- data/jekyll-relations.gemspec +27 -0
- data/lib/jekyll-relations.rb +4 -0
- data/lib/jekyll/relations/page.rb +59 -0
- data/lib/jekyll/relations/version.rb +7 -0
- data/license.txt +21 -0
- data/readme.md +115 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 145d22caafbdb3232391e3a0f525b0c0fc5d6941
|
4
|
+
data.tar.gz: 8a25ae3bb43a139f38ac5b44583abcb844df497e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 812ce2bab6934d7f64b727b0e912e677ef652978b2b9d62e24d16610ba01453bd8c858abdf7d44bbd9b4cad46bdd73fc447f7634fbf779e95375773c30e63f65
|
7
|
+
data.tar.gz: 1f44c490975bc15f5ff119c3b941e079a043b604852215e70c84e8ef8b50ed0d87ddfce158f23c54f740a61b15aaf2ff669ab65acb53f6e1717e78e9108734a9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-relations (0.1.0)
|
5
|
+
jekyll (~> 3.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
ansi (1.5.0)
|
13
|
+
builder (3.2.3)
|
14
|
+
colorator (1.1.0)
|
15
|
+
ffi (1.9.18)
|
16
|
+
forwardable-extended (2.6.0)
|
17
|
+
jekyll (3.6.2)
|
18
|
+
addressable (~> 2.4)
|
19
|
+
colorator (~> 1.0)
|
20
|
+
jekyll-sass-converter (~> 1.0)
|
21
|
+
jekyll-watch (~> 1.1)
|
22
|
+
kramdown (~> 1.14)
|
23
|
+
liquid (~> 4.0)
|
24
|
+
mercenary (~> 0.3.3)
|
25
|
+
pathutil (~> 0.9)
|
26
|
+
rouge (>= 1.7, < 3)
|
27
|
+
safe_yaml (~> 1.0)
|
28
|
+
jekyll-sass-converter (1.5.0)
|
29
|
+
sass (~> 3.4)
|
30
|
+
jekyll-watch (1.5.0)
|
31
|
+
listen (~> 3.0, < 3.1)
|
32
|
+
kramdown (1.16.1)
|
33
|
+
liquid (4.0.0)
|
34
|
+
listen (3.0.8)
|
35
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
36
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
37
|
+
mercenary (0.3.6)
|
38
|
+
minitest (5.10.3)
|
39
|
+
minitest-reporters (1.1.19)
|
40
|
+
ansi
|
41
|
+
builder
|
42
|
+
minitest (>= 5.0)
|
43
|
+
ruby-progressbar
|
44
|
+
pathutil (0.16.0)
|
45
|
+
forwardable-extended (~> 2.6)
|
46
|
+
public_suffix (3.0.1)
|
47
|
+
rake (10.5.0)
|
48
|
+
rb-fsevent (0.10.2)
|
49
|
+
rb-inotify (0.9.10)
|
50
|
+
ffi (>= 0.5.0, < 2)
|
51
|
+
rouge (2.2.1)
|
52
|
+
ruby-progressbar (1.9.0)
|
53
|
+
safe_yaml (1.0.4)
|
54
|
+
sass (3.5.3)
|
55
|
+
sass-listen (~> 4.0.0)
|
56
|
+
sass-listen (4.0.0)
|
57
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
58
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
bundler (~> 1.16)
|
65
|
+
jekyll-relations!
|
66
|
+
minitest
|
67
|
+
minitest-reporters
|
68
|
+
rake (~> 10.0)
|
69
|
+
|
70
|
+
BUNDLED WITH
|
71
|
+
1.16.0
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'jekyll/relations/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'jekyll-relations'
|
7
|
+
spec.version = Jekyll::Relations::VERSION
|
8
|
+
spec.authors = ['Adam Hollett']
|
9
|
+
spec.email = ['mail@adamhollett.com']
|
10
|
+
|
11
|
+
spec.summary = 'Jekyll plugin to make pages aware of their relatives.'
|
12
|
+
spec.homepage = 'https://github.com/adamhollett/jekyll-relations'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'jekyll', '~> 3.0'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'minitest'
|
26
|
+
spec.add_development_dependency 'minitest-reporters'
|
27
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Relations
|
5
|
+
module Page
|
6
|
+
# The next highest page in the folder structure.
|
7
|
+
#
|
8
|
+
# Returns the Page object for the parent page.
|
9
|
+
def parent
|
10
|
+
@parent ||= begin
|
11
|
+
return nil unless html?
|
12
|
+
depth = url.count('/')
|
13
|
+
site.pages
|
14
|
+
.select(&:html?)
|
15
|
+
.find { |p| url.start_with?(p.url) && p.url.count('/') == depth - 1 }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# A list of ancestors from the site index to the current page.
|
20
|
+
#
|
21
|
+
# Returns an Array of Page objects or an empty Array.
|
22
|
+
def ancestors
|
23
|
+
@ancestors ||= begin
|
24
|
+
return [] unless parent
|
25
|
+
ancestors = []
|
26
|
+
i = self
|
27
|
+
while i.parent
|
28
|
+
ancestors << i.parent
|
29
|
+
i = i.parent
|
30
|
+
end
|
31
|
+
ancestors.reverse
|
32
|
+
end
|
33
|
+
end
|
34
|
+
alias_method :parents, :ancestors
|
35
|
+
|
36
|
+
# A list of the pages directly below this one in the folder structure.
|
37
|
+
#
|
38
|
+
# Returns an Array of Page objects or an empty Array.
|
39
|
+
def children
|
40
|
+
return [] unless html? && index?
|
41
|
+
@children ||= begin
|
42
|
+
depth = url.count('/')
|
43
|
+
site.pages
|
44
|
+
.select(&:html?)
|
45
|
+
.select { |p| p.url.start_with?(url) && p.url.count('/') == depth + 1 }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Convert the new Page data to a Hash suitable for use by Liquid.
|
50
|
+
#
|
51
|
+
# Returns the Hash representation of this Page.
|
52
|
+
def to_liquid(attrs = Jekyll::Page::ATTRIBUTES_FOR_LIQUID)
|
53
|
+
super(attrs + %w(parent ancestors parents children))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Jekyll::Page.prepend Jekyll::Relations::Page
|
data/license.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Adam Hollett
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
# Jekyll Relations plugin
|
2
|
+
|
3
|
+
A Jekyll plugin to create relations between pages according to your file structure.
|
4
|
+
|
5
|
+
> ⚠️
|
6
|
+
> **Note**:
|
7
|
+
> This plugin is beta-quality and relies on the `permalink: pretty` configuration setting to work. Future versions will be compatible with other permalink settings.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
1. Add this line to the `jekyll_plugins` group of your site's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem 'jekyll-relations', git: 'https://github.com/adamhollett/jekyll-relations'
|
15
|
+
```
|
16
|
+
|
17
|
+
2. Add `jekyll-relations` under the `plugins` key in your site's `_config.yml`:
|
18
|
+
|
19
|
+
``` yml
|
20
|
+
plugins:
|
21
|
+
- jekyll-relations
|
22
|
+
```
|
23
|
+
|
24
|
+
If you're using Jekyll < 3.5.0, use the `gems` key instead of `plugins`.
|
25
|
+
|
26
|
+
3. Run `bundle` to ensure your dependencies are up to date.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
After installing this plugin, your Jekyll pages will respond to a few new methods: `parent`, `ancestors`, and `children`.
|
31
|
+
|
32
|
+
### parent
|
33
|
+
|
34
|
+
Returns a `Jekyll::Page`. You can access a page's parent in Liquid with `{{ page.parent }}`.
|
35
|
+
|
36
|
+
A page's **parent** is the next highest page in the folder structure.
|
37
|
+
|
38
|
+
- If a page's filename is `index`, then its parent is the page with the filename `index` in the folder above:
|
39
|
+
|
40
|
+
```
|
41
|
+
about.md
|
42
|
+
contact.md
|
43
|
+
index.md <-- {{ page.parent }}
|
44
|
+
fruit/
|
45
|
+
apple.md
|
46
|
+
index.md <-- {{ page }}
|
47
|
+
orange.md
|
48
|
+
```
|
49
|
+
|
50
|
+
- If a page's filename is not `index`, then its parent is the page with the filename `index` in the same folder.
|
51
|
+
|
52
|
+
```
|
53
|
+
about.md
|
54
|
+
contact.md
|
55
|
+
index.md
|
56
|
+
fruit/
|
57
|
+
apple.md <-- {{ page }}
|
58
|
+
index.md <-- {{ page.parent }}
|
59
|
+
orange.md
|
60
|
+
```
|
61
|
+
|
62
|
+
### ancestors
|
63
|
+
|
64
|
+
Returns an array of `Jekyll::Page` objects. You can access a page's ancestors in Liquid with `{{ page.ancestors }}` or `{{ page.parents }}`.
|
65
|
+
|
66
|
+
A page's **ancestors** are its parent, its parent's parent, and so on until the site index. They are returned in order from highest to lowest.
|
67
|
+
|
68
|
+
It can be useful to think of a page's ancestors as the "breadcrumbs" for the page.
|
69
|
+
|
70
|
+
```
|
71
|
+
about.md
|
72
|
+
contact.md
|
73
|
+
index.md
|
74
|
+
fruit/
|
75
|
+
apple.md <-- {{ page }}
|
76
|
+
index.md
|
77
|
+
orange.md
|
78
|
+
```
|
79
|
+
|
80
|
+
In the tree above, the page is `fruit/apple.md` and its ancestors are:
|
81
|
+
|
82
|
+
```
|
83
|
+
[
|
84
|
+
'index.md',
|
85
|
+
'fruit/index.md'
|
86
|
+
]
|
87
|
+
```
|
88
|
+
|
89
|
+
Because `fruit/apple.md`'s parent is `fruit/index.md` and that page's parent is `index.md`.
|
90
|
+
|
91
|
+
### children
|
92
|
+
|
93
|
+
Returns an array of `Jekyll::Page` objects. You can access a page's children in Liquid with `{{ page.children }}`.
|
94
|
+
|
95
|
+
A page's **children** are the pages directly below it in the folder structure. Only pages with the filename `index` have children.
|
96
|
+
|
97
|
+
The children of a page called `index` are the other page files in the same folder, as well as `index` files in its subfolders:
|
98
|
+
|
99
|
+
```
|
100
|
+
about.md {{ page.children[0] }}
|
101
|
+
contact.md {{ page.children[1] }}
|
102
|
+
index.md <-- {{ page }}
|
103
|
+
fruit/
|
104
|
+
apple.md
|
105
|
+
index.md {{ page.children[2] }}
|
106
|
+
orange.md
|
107
|
+
```
|
108
|
+
|
109
|
+
## Testing
|
110
|
+
|
111
|
+
Run `rake test` to run tests for this plugin.
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/adamhollett/jekyll-relations.
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-relations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Hollett
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-30 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: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
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.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- mail@adamhollett.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- Rakefile
|
94
|
+
- jekyll-relations.gemspec
|
95
|
+
- lib/jekyll-relations.rb
|
96
|
+
- lib/jekyll/relations/page.rb
|
97
|
+
- lib/jekyll/relations/version.rb
|
98
|
+
- license.txt
|
99
|
+
- readme.md
|
100
|
+
homepage: https://github.com/adamhollett/jekyll-relations
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.6.14
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Jekyll plugin to make pages aware of their relatives.
|
124
|
+
test_files: []
|