jekyll-overrides 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 +8 -0
- data/Gemfile +6 -0
- data/README.md +23 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jekyll-overrides.gemspec +11 -0
- data/lib/jekyll-overrides.rb +1 -0
- data/lib/jekyll/overrides.rb +52 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6fcc9d0b48d888c7e318fdabf6f2c2db14e582e9
|
4
|
+
data.tar.gz: 3cd897d47c1636dd1cca2ff695908608f1ef9401
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c64a80deed914eed3f294c258ce2370a01849cba9e3c0e3e246d59a40a4c154142cc6f7fb453ebf9fadfd1358d8ed95607810d2c2bf0a8eaa5962d3204ad2332
|
7
|
+
data.tar.gz: 5d0e40d47a8820356682df332573c20157b94e5edd89792f781f394dc992e775e158a2f140afb2e3c7067de6f5e3234a6400ebbb662620ec1bf9ba63220fe16d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Jekyll::Overrides
|
2
|
+
|
3
|
+
This is a Jekyll plugin to manage overrides from a variety of sources, including AWS S3 and PO Editor.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'jekyll-overrides'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install jekyll-overrides
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
If added correctly to the Gemfile, this plugin should work as a seamless replacement to local versions of the plugin that we have been using on our frontend Jekyll sites.
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jekyll/overrides"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "jekyll-overrides"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Jordan Dalton"]
|
5
|
+
spec.email = ["jordan.dalton@researchsquare.com"]
|
6
|
+
spec.require_paths = ["lib"]
|
7
|
+
spec.summary = %q{Overrides tool for Jekyll}
|
8
|
+
spec.homepage = "https://github.com/researchsquare/jekyll-overrides"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.files = `git ls-files -z`.split("\x0")
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jekyll/overrides'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Overrides
|
2
|
+
class OverridePage < Jekyll::Page
|
3
|
+
def initialize(site, base, dir, name)
|
4
|
+
@override_path = File.join(Dir.pwd, base, name)
|
5
|
+
super(site, base, dir, name)
|
6
|
+
end
|
7
|
+
|
8
|
+
def read_yaml(base, name, opts = {})
|
9
|
+
path = @path
|
10
|
+
# We temporarily replace the path here where super.read_yaml doesn't fail
|
11
|
+
@path = @override_path
|
12
|
+
super
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Generator < Jekyll::Generator
|
18
|
+
def generate(site)
|
19
|
+
return if not override_directory = site.config['overrides']
|
20
|
+
|
21
|
+
# Let's gather pages that exist in our override directory, in case
|
22
|
+
# they aren't originally defined in our source directory`
|
23
|
+
Dir["#{override_directory}/**/*.{md,html}"].each do |path|
|
24
|
+
site.pages << OverridePage.new(
|
25
|
+
site,
|
26
|
+
override_directory.gsub(/\/$/, '') + '/',
|
27
|
+
'',
|
28
|
+
'/' + path.gsub(override_directory, '').gsub(/^\//, '')
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
site.pages.map { | page | configure_page(page, override_directory, site) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def configure_page(page, override_directory, site)
|
36
|
+
override_file = File.join(override_directory, page.path)
|
37
|
+
if File.exists?(override_file)
|
38
|
+
override_content = File.read(override_file)
|
39
|
+
|
40
|
+
# Lets merge the old page data with any overrides
|
41
|
+
matches = Jekyll::Document::YAML_FRONT_MATTER_REGEXP.match(override_content)
|
42
|
+
if matches[0]
|
43
|
+
page.data = page.data.merge(SafeYAML.load(matches[0]))
|
44
|
+
end
|
45
|
+
|
46
|
+
page.content = override_content.gsub(matches[0], '')
|
47
|
+
end
|
48
|
+
|
49
|
+
return page
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-overrides
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jordan Dalton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- jordan.dalton@researchsquare.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- README.md
|
23
|
+
- bin/console
|
24
|
+
- bin/setup
|
25
|
+
- jekyll-overrides.gemspec
|
26
|
+
- lib/jekyll-overrides.rb
|
27
|
+
- lib/jekyll/overrides.rb
|
28
|
+
homepage: https://github.com/researchsquare/jekyll-overrides
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.5.2.3
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Overrides tool for Jekyll
|
52
|
+
test_files: []
|