jekyll-duplicate 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/CHANGELOG.adoc +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/develop/release +41 -0
- data/jekyll-duplicate.gemspec +20 -0
- data/lib/jekyll-duplicate.rb +7 -0
- data/lib/jekyll-duplicate/duplicate.rb +81 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 365340ca7d4d1ffeb3fc73c72956596c3f31a1eb1908eb4422f78f01db0ac601
|
4
|
+
data.tar.gz: 86e98c314d7362348ea802ad2f1529bcfae43340b17f5fc69e8682d6d4de82d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80ce68a38366fca1c0ba983d1c362969493c1cda2dd82f0b22efcf2ad18ff526e33472a9f6d9dc1041b0e8396462c84fc61cc9547bdacfde2f7816fa48823409
|
7
|
+
data.tar.gz: 4c95d8e32a9b92ca9c6ff070ab4adaa60611ec37e8c0533a1bb2489360de9355be9c7652f332ca3583795404ffd1786a8894380e43cc3e71160fb1a5867bc1fb
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ribose
|
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,67 @@
|
|
1
|
+
# Jekyll plugin to render documents in additional ways
|
2
|
+
|
3
|
+
This plugin allows to automatically generate an extra page
|
4
|
+
for each document in specified collection(s).
|
5
|
+
Additionally generated pages
|
6
|
+
can be assigned a different layout and/or extra frontmatter variables,
|
7
|
+
and will be placed under specified path.
|
8
|
+
|
9
|
+
## Use cases
|
10
|
+
|
11
|
+
* You have documentation for your desktop app
|
12
|
+
available via your main site as usual and want to reuse the same pages
|
13
|
+
in context of app’s built-in web-based help, similar to e.g. what Xcode does.
|
14
|
+
|
15
|
+
In this scenario you may want new pages to provide the same content
|
16
|
+
in a different layout (perhaps excluding some page elements).
|
17
|
+
|
18
|
+
* You want to output machine-readable JSON for each document.
|
19
|
+
|
20
|
+
## Configuration
|
21
|
+
|
22
|
+
Specify the following in your `_config.yml`:
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
duplicate_documents:
|
26
|
+
in_collection: <your collection name>
|
27
|
+
under_url_prefix: <path to render documents under>
|
28
|
+
format: <html or json>
|
29
|
+
|
30
|
+
# These two are optional
|
31
|
+
with_layout: <layout name>
|
32
|
+
with_frontmatter:
|
33
|
+
<variable>: <value>
|
34
|
+
...
|
35
|
+
```
|
36
|
+
|
37
|
+
## Notes and limitations
|
38
|
+
|
39
|
+
* Does not work with AsciiDoc or other pre-processed formats.
|
40
|
+
[Issue](../../../../riboseinc/jekyll-duplicate/issues/1).
|
41
|
+
|
42
|
+
* In case of JSON, you must still use a layout to build your structure.
|
43
|
+
Specify `layout: nil` in your layout.
|
44
|
+
Use `jsonify` filter to escape values or convert Ruby structures to JSON.
|
45
|
+
|
46
|
+
* Currently, no nesting in extra frontmatter is allowed.
|
47
|
+
[Issue](../../../../riboseinc/jekyll-duplicate/issues/2).
|
48
|
+
|
49
|
+
* If any frontmatter specified clashes with page’s original frontmatter,
|
50
|
+
frontmatter from jekyll-duplicate configuration will prevail.
|
51
|
+
|
52
|
+
## Caution
|
53
|
+
|
54
|
+
Pages with duplicate content are discouraged by search engines.
|
55
|
+
|
56
|
+
You may, for example, want to make sure that extra pages, if they’re HTML,
|
57
|
+
are not linked to from the “main site” and do not get indexed.
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
PRs are welcome.
|
62
|
+
|
63
|
+
## Release process
|
64
|
+
|
65
|
+
* Update version number in `.gemspec` and commit your change.
|
66
|
+
|
67
|
+
* Run `./develop/release` to publish new gem version, tag the repo and push to GitHub.
|
data/develop/release
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Tag and push a release.
|
3
|
+
|
4
|
+
set -e
|
5
|
+
|
6
|
+
# Make sure we're in the project root.
|
7
|
+
|
8
|
+
cd $(dirname "$0")/..
|
9
|
+
|
10
|
+
# Make sure the darn thing works? Meh.
|
11
|
+
# bundle update
|
12
|
+
|
13
|
+
# Build a new gem archive.
|
14
|
+
|
15
|
+
rm -rf jekyll-duplicate-*.gem
|
16
|
+
gem build -q jekyll-duplicate.gemspec
|
17
|
+
|
18
|
+
# Make sure we're on the master branch.
|
19
|
+
|
20
|
+
(git branch | grep -q 'master') || {
|
21
|
+
echo "Only release from the master branch."
|
22
|
+
exit 1
|
23
|
+
}
|
24
|
+
|
25
|
+
# Figure out what version we're releasing.
|
26
|
+
|
27
|
+
tag=v`ls jekyll-duplicate-*.gem | sed 's/^jekyll-duplicate-\(.*\)\.gem$/\1/'`
|
28
|
+
|
29
|
+
# Make sure we haven't released this version before.
|
30
|
+
|
31
|
+
git fetch -t origin
|
32
|
+
|
33
|
+
(git tag -l | grep -q "$tag") && {
|
34
|
+
echo "Whoops, there's already a '${tag}' tag."
|
35
|
+
exit 1
|
36
|
+
}
|
37
|
+
|
38
|
+
# Tag it and bag it.
|
39
|
+
|
40
|
+
gem push jekyll-duplicate-*.gem && git tag "$tag" &&
|
41
|
+
git push origin master && git push origin "$tag"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'jekyll-duplicate'
|
5
|
+
s.version = '0.1.0'
|
6
|
+
s.authors = ['Ribose Inc.']
|
7
|
+
s.email = ['open.source@ribose.com']
|
8
|
+
|
9
|
+
s.summary = 'Jekyll plugin to render documents in additional ways'
|
10
|
+
s.homepage = 'https://github.com/riboseinc/jekyll-duplicate/'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
|
15
|
+
s.add_runtime_dependency 'jekyll', '~> 4.0'
|
16
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
17
|
+
s.add_development_dependency 'rubocop', '~> 0.50'
|
18
|
+
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class DuplicatePage < Page
|
3
|
+
def initialize(site, base_dir, url_prefix, path, content, data, overrides, format)
|
4
|
+
@site = site
|
5
|
+
@base = base_dir
|
6
|
+
@content = content
|
7
|
+
|
8
|
+
if format == 'html'
|
9
|
+
if path.end_with?('/index')
|
10
|
+
@dir = url_prefix
|
11
|
+
else
|
12
|
+
@dir = File.join(url_prefix, path)
|
13
|
+
end
|
14
|
+
@name = "index.html"
|
15
|
+
|
16
|
+
elsif format == 'json'
|
17
|
+
@dir = File.join(url_prefix)
|
18
|
+
@name = "#{path}.json"
|
19
|
+
end
|
20
|
+
|
21
|
+
self.process(@name)
|
22
|
+
|
23
|
+
self.data = data.clone
|
24
|
+
|
25
|
+
if overrides
|
26
|
+
if overrides['frontmatter']
|
27
|
+
overrides['frontmatter'].each do |key, value|
|
28
|
+
self.data[key] = value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
if overrides['layout']
|
32
|
+
self.data['layout'] = overrides['layout']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Site
|
39
|
+
def write_duplicate_docs(collection_name, url_prefix, layout, frontmatter, format)
|
40
|
+
overrides = {
|
41
|
+
"layout" => layout,
|
42
|
+
"frontmatter" => frontmatter,
|
43
|
+
}
|
44
|
+
|
45
|
+
originals = @collections[collection_name]
|
46
|
+
|
47
|
+
originals.docs.each do |doc|
|
48
|
+
if doc.data['permalink']
|
49
|
+
permalink = doc.data['permalink'].sub("/#{collection_name}/", '')
|
50
|
+
else
|
51
|
+
permalink = doc.cleaned_relative_path
|
52
|
+
end
|
53
|
+
|
54
|
+
page = DuplicatePage.new(
|
55
|
+
self,
|
56
|
+
self.source,
|
57
|
+
url_prefix,
|
58
|
+
permalink,
|
59
|
+
doc.content,
|
60
|
+
doc.data,
|
61
|
+
overrides,
|
62
|
+
format)
|
63
|
+
|
64
|
+
@pages << page
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
Jekyll::Hooks.register :site, :post_read do |site|
|
72
|
+
if site.config.key?('duplicate_documents')
|
73
|
+
cfg = site.config['duplicate_documents']
|
74
|
+
site.write_duplicate_docs(
|
75
|
+
cfg['in_collection'],
|
76
|
+
cfg['under_url_prefix'],
|
77
|
+
cfg['with_layout'],
|
78
|
+
cfg['with_frontmatter'],
|
79
|
+
cfg['format'])
|
80
|
+
end
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-duplicate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-22 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: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.50'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.50'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- open.source@ribose.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.adoc
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- develop/release
|
66
|
+
- jekyll-duplicate.gemspec
|
67
|
+
- lib/jekyll-duplicate.rb
|
68
|
+
- lib/jekyll-duplicate/duplicate.rb
|
69
|
+
homepage: https://github.com/riboseinc/jekyll-duplicate/
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.0.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Jekyll plugin to render documents in additional ways
|
92
|
+
test_files: []
|