jekyll-data-revised 1.0.1 → 1.2.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 +4 -4
- metadata +3 -14
- data/LICENSE.txt +0 -21
- data/README.md +0 -125
- data/lib/jekyll-data.rb +0 -49
- data/lib/jekyll-data/reader.rb +0 -223
- data/lib/jekyll-data/theme_configuration.rb +0 -64
- data/lib/jekyll-data/theme_data_reader.rb +0 -37
- data/lib/jekyll-data/themed_site_drop.rb +0 -15
- data/lib/jekyll-data/version.rb +0 -3
- data/lib/jekyll/build_options.rb +0 -17
- data/lib/jekyll/data_path.rb +0 -7
- data/lib/jekyll/theme_drop.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707b112f76f32fc1f14554a99f27c6c3efdddc6c86fa4d144a1dfd502cf9545b
|
4
|
+
data.tar.gz: 2b338246b25bc273206dcccb74220078a81163dd21dd2c4da370aed5c0deca9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55e039056d3b85569f743de12de8e6f4f093dff9f96f6bce4006329834482e0bc052d0307e51d890e830cce39bdb94721f12010dc266b3fd136e372033f160d1
|
7
|
+
data.tar.gz: 4434fff2d13688928b3bee6ce25e4947b59fb2980e5b84c11072443718640dab99aaf102487444852ff03384995ce073c0a0b6364fbdc27c13d637cf3f404659
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-data-revised
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Maroli
|
@@ -106,19 +106,8 @@ email:
|
|
106
106
|
executables: []
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
|
-
files:
|
110
|
-
|
111
|
-
- README.md
|
112
|
-
- lib/jekyll-data.rb
|
113
|
-
- lib/jekyll-data/reader.rb
|
114
|
-
- lib/jekyll-data/theme_configuration.rb
|
115
|
-
- lib/jekyll-data/theme_data_reader.rb
|
116
|
-
- lib/jekyll-data/themed_site_drop.rb
|
117
|
-
- lib/jekyll-data/version.rb
|
118
|
-
- lib/jekyll/build_options.rb
|
119
|
-
- lib/jekyll/data_path.rb
|
120
|
-
- lib/jekyll/theme_drop.rb
|
121
|
-
homepage: https://github.com/ashmaroli/jekyll-data
|
109
|
+
files: []
|
110
|
+
homepage: https://github.com/ashmaroli/jekyll-data-revised
|
122
111
|
licenses:
|
123
112
|
- MIT
|
124
113
|
metadata:
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2016-2017 Ashwin Maroli & Contributors
|
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
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# JekyllData
|
2
|
-
|
3
|
-
[](https://rubygems.org/gems/jekyll-data)
|
4
|
-
[][travis]
|
5
|
-
|
6
|
-
[travis]: https://travis-ci.org/ashmaroli/jekyll-data
|
7
|
-
|
8
|
-
Introducing a plugin that reads data files within **jekyll theme-gems** and adds the resulting hash to the site's internal data hash. If a **`_config.yml`** is present at the root of the theme-gem, it will be evaluated and the extracted hash data will be incorporated into the site's existing config hash.
|
9
|
-
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Simply add the plugin to your site's Gemfile and config file like every other jekyll plugin gem:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
# Gemfile
|
17
|
-
|
18
|
-
group :jekyll_plugins do
|
19
|
-
gem "jekyll-data"
|
20
|
-
end
|
21
|
-
```
|
22
|
-
..and run
|
23
|
-
|
24
|
-
bundle install
|
25
|
-
|
26
|
-
|
27
|
-
> **Note: If the plugin has been marked as a `runtime_dependency` by the theme-gem's author it will be installed automatically with the theme-gem. Yet, it is recommended that the plugin be added to `:jekyll_plugins` group in the Gemfile rather than the `gems:` array in the config file while building or serving the site to avoid 'overriding' the `gems:` array data that may have been read-in from the theme-gem.**
|
28
|
-
|
29
|
-
|
30
|
-
## Usage
|
31
|
-
|
32
|
-
**Note:** *This plugin will only run in conjunction with a gem-based Jekyll-theme.*
|
33
|
-
|
34
|
-
As long as the plugin-gem has been installed properly, and is included in the Gemfile's `:jekyll_plugins` group, data files supported by Jekyll and present in the `_data` directory at the root of your theme-gem will be read. Their contents will be added to the site's internal data hash, provided, an identical data hash doesn't already exist at the site-source.
|
35
|
-
|
36
|
-
If the theme-gem also includes a `_config.yml` at its root, then it will be read as well. The resulting config hash will be mixed into the site's existing config hash, filling in where the *keys* are not already defined. In other words, the config file at `source` will override corresponding identical keys in a `_config.yml` within the theme-gem which would in turn override corresponding `DEFAULTS` from Jekyll:
|
37
|
-
|
38
|
-
**DEFAULTS** < **_config.yml in theme-gem** < **_config.yml at source** < **Override configs via command-line**.
|
39
|
-
|
40
|
-
|
41
|
-
### Theme Configuration
|
42
|
-
|
43
|
-
Jekyll themes (built prior to `Jekyll 3.2`) usually ship with configuration settings defined in the config file, which are then used within the theme's template files directly under the `site` namespace (e.g. `{{ site.myvariable }}`). This is not possible with theme-gems as a config file and data files within gems are not natively read (as of Jekyll 3.3), and hence require end-users to inspect a *demo* or *example* directory to source those files.
|
44
|
-
|
45
|
-
This plugin provides a solution to that hurdle:
|
46
|
-
|
47
|
-
JekyllData now reads the config file (at present only `_config.yml`) present within the theme-gem and uses the data to modify the site's config hash. This allows the theme-gem to continue using `{{ site.myvariable }}` within its templates and work out-of-the-box as intended, with minimal user intervention.
|
48
|
-
|
49
|
-
**Note: the plugins required by the theme may be listed under the `gems:` array and will be automatically `required` by Jekyll while building/serving, provided that the user doesn't have a different `gems:` array in the config file at source. Hence it is recommended to add all other plugins ( including `jekyll-data` ) via the Gemfile's `:jekyll_plugins` group.**
|
50
|
-
|
51
|
-
#### The `theme` namespace
|
52
|
-
|
53
|
-
From `v1.0`, JekyllData no longer supports reading theme configuration provided as a `[theme-name].***` file within the `_data` directory and instead the `theme` namespace points to a certain key in the bundled `_config.yml`.
|
54
|
-
|
55
|
-
For `{{ theme.variable }}` to work, the config file should nest all such key-value pairs under the `[theme-name]` key, as outlined in the example below for a theme-gem called `solitude`:
|
56
|
-
|
57
|
-
```yaml
|
58
|
-
# <solitude-0.1.0>/_config.yml
|
59
|
-
|
60
|
-
# the settings below have been used in this theme's templates via the `theme`
|
61
|
-
# namespace. e.g. `{{ theme.recent_posts.style }}` instead of using the more
|
62
|
-
# verbose `{{ site.solitude.recent_posts.style }}` though both are functionally
|
63
|
-
# the same.
|
64
|
-
#
|
65
|
-
solitude:
|
66
|
-
sidebar : true # enter 'false' to enable horizontal navbar instead.
|
67
|
-
theme_variant : Charcoal # choose from 'Ocean', 'Grass', 'Charcoal'
|
68
|
-
recent_posts :
|
69
|
-
style : list # choose from 'list' and 'grid'.
|
70
|
-
quantity : '4' # either '4' or '6'
|
71
|
-
|
72
|
-
```
|
73
|
-
|
74
|
-
|
75
|
-
### Data files
|
76
|
-
|
77
|
-
Data files may be used to supplement theme templates (e.g. locales and translated UI text) and can be named as desired.
|
78
|
-
- Organize related small data files in sub-directories. (or)
|
79
|
-
- Declare all related data as mapped data blocks within a single file.
|
80
|
-
|
81
|
-
To illustrate with an example, consider a `locales.yml` that has mappings for `en:`, `fr:`, `it:`.
|
82
|
-
|
83
|
-
```yaml
|
84
|
-
# <theme-gem>/_data/locales.yml
|
85
|
-
|
86
|
-
en:
|
87
|
-
previous : previous
|
88
|
-
next : next
|
89
|
-
|
90
|
-
fr:
|
91
|
-
previous : précédent
|
92
|
-
next : prochain
|
93
|
-
|
94
|
-
it:
|
95
|
-
previous : precedente
|
96
|
-
next : seguente
|
97
|
-
```
|
98
|
-
|
99
|
-
the Hash from above would be identical to one had the gem been shipped with a `_data/locales` directory containing individual files for each language data.
|
100
|
-
|
101
|
-
|
102
|
-
### Overriding Data Files
|
103
|
-
|
104
|
-
To override data shipped with a theme-gem, simply have an identical hash at the site-source.
|
105
|
-
|
106
|
-
Irrespective of whether the theme-gem ships with consolidated data files of related entities, or sub-directories containing individual files, the data can be overridden with a single file or with multiple files.
|
107
|
-
|
108
|
-
For example, if a theme-gem contains the above sample `locales.yml`, then to override the `fr:` key-data simply have either of the following:
|
109
|
-
- a **`_data/locales/fr.yml`** with identical subkey(s).
|
110
|
-
- a **`_data/locales.yml`** with **`fr:`** with identical subkey(s).
|
111
|
-
|
112
|
-
--
|
113
|
-
> **Note**
|
114
|
-
- having an **empty** `_data/locales.yml` at `source` directory will override the **entire `["data"]["locales"]` payload** from the theme-gem as **`false`**.
|
115
|
-
- having an **empty** `_data/locales/fr.yml` at `source` directory will override the **enire `["data"]["locales"]["fr"]` payload** from the theme-gem as **`false`**
|
116
|
-
|
117
|
-
|
118
|
-
## Contributing
|
119
|
-
|
120
|
-
Bug reports and pull requests are welcome at the [GitHub Repo](https://github.com/ashmaroli/jekyll-data). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
121
|
-
|
122
|
-
|
123
|
-
## License
|
124
|
-
|
125
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/jekyll-data.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require "jekyll-data/version"
|
3
|
-
|
4
|
-
module JekyllData
|
5
|
-
autoload :Reader, "jekyll-data/reader"
|
6
|
-
autoload :ThemedSiteDrop, "jekyll-data/themed_site_drop"
|
7
|
-
autoload :ThemeDataReader, "jekyll-data/theme_data_reader"
|
8
|
-
autoload :ThemeConfiguration, "jekyll-data/theme_configuration"
|
9
|
-
end
|
10
|
-
|
11
|
-
# Monkey-patches
|
12
|
-
require_relative "jekyll/build_options"
|
13
|
-
require_relative "jekyll/data_path"
|
14
|
-
require_relative "jekyll/theme_drop"
|
15
|
-
|
16
|
-
# ----------------------------------------------------------------------------
|
17
|
-
# Modify the current site instance if it uses a gem-based theme else have this
|
18
|
-
# plugin disabled.
|
19
|
-
#
|
20
|
-
# if a '_config.yml' is present at the root of theme-gem, it is evaluated and
|
21
|
-
# the extracted hash data is incorprated into the site's config hash.
|
22
|
-
# ----------------------------------------------------------------------------
|
23
|
-
Jekyll::Hooks.register :site, :after_reset do |site|
|
24
|
-
if site.theme
|
25
|
-
file = site.in_theme_dir("_config.yml")
|
26
|
-
JekyllData::ThemeConfiguration.reconfigure(site) if File.exist?(file)
|
27
|
-
else
|
28
|
-
Jekyll.logger.abort_with(
|
29
|
-
"JekyllData:",
|
30
|
-
"Error! This plugin only works with gem-based jekyll-themes. " \
|
31
|
-
"Please disable this plugin to proceed."
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# ---------------------------------------------------------------------------
|
37
|
-
# Replace Jekyll::Reader with a subclass JekyllData::Reader only if the
|
38
|
-
# site uses a gem-based theme.
|
39
|
-
#
|
40
|
-
# If a _config.yml exists at the root of the theme-gem, output its path.
|
41
|
-
# Placed here inorder to avoid outputting the path after every regeneration.
|
42
|
-
# ---------------------------------------------------------------------------
|
43
|
-
Jekyll::Hooks.register :site, :after_init do |site|
|
44
|
-
if site.theme
|
45
|
-
file = site.in_theme_dir("_config.yml")
|
46
|
-
Jekyll.logger.info "Theme Config file:", file if File.exist?(file)
|
47
|
-
site.reader = JekyllData::Reader.new(site)
|
48
|
-
end
|
49
|
-
end
|
data/lib/jekyll-data/reader.rb
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require "csv"
|
3
|
-
|
4
|
-
module JekyllData
|
5
|
-
class Reader < Jekyll::Reader
|
6
|
-
def initialize(site)
|
7
|
-
@site = site
|
8
|
-
@theme = site.theme
|
9
|
-
@theme_data_files = Dir[File.join(site.theme.root,
|
10
|
-
site.config["data_dir"], "**", "*.{yaml,yml,json,csv}")]
|
11
|
-
end
|
12
|
-
|
13
|
-
# Read data files within theme-gem.
|
14
|
-
#
|
15
|
-
# Returns nothing.
|
16
|
-
def read
|
17
|
-
super
|
18
|
-
read_theme_data
|
19
|
-
end
|
20
|
-
|
21
|
-
# Read data files within a theme gem and add them to internal data
|
22
|
-
#
|
23
|
-
# Returns a hash appended with new data
|
24
|
-
def read_theme_data
|
25
|
-
if @theme.data_path
|
26
|
-
#
|
27
|
-
# show contents of "<theme>/_data/" dir being read while degugging.
|
28
|
-
inspect_theme_data
|
29
|
-
theme_data = ThemeDataReader.new(site).read(site.config["data_dir"])
|
30
|
-
@site.data = Jekyll::Utils.deep_merge_hashes(theme_data, @site.data)
|
31
|
-
#
|
32
|
-
# show contents of merged site.data hash while debugging with
|
33
|
-
# additional --show-data switch.
|
34
|
-
inspect_merged_hash if site.config["show-data"] && site.config["verbose"]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
# Private:
|
41
|
-
# (only while debugging)
|
42
|
-
#
|
43
|
-
# Print a list of data file(s) within the theme-gem
|
44
|
-
def inspect_theme_data
|
45
|
-
print_clear_line
|
46
|
-
Jekyll.logger.debug "Reading:", "Theme Data Files..."
|
47
|
-
@theme_data_files.each { |file| Jekyll.logger.debug "", file }
|
48
|
-
print_clear_line
|
49
|
-
Jekyll.logger.debug "Merging:", "Theme Data Hash..."
|
50
|
-
|
51
|
-
unless site.config["show-data"] && site.config["verbose"]
|
52
|
-
Jekyll.logger.debug "", "use --show-data with --verbose to output " \
|
53
|
-
"merged Data Hash.".cyan
|
54
|
-
print_clear_line
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Private:
|
59
|
-
# (only while debugging)
|
60
|
-
#
|
61
|
-
# Print contents of the merged data hash
|
62
|
-
def inspect_merged_hash
|
63
|
-
Jekyll.logger.debug "Inspecting:", "Site Data >>"
|
64
|
-
|
65
|
-
# the width of generated logger[message]
|
66
|
-
@width = 50
|
67
|
-
@dashes = "-" * @width
|
68
|
-
|
69
|
-
inspect_hash @site.data
|
70
|
-
print_clear_line
|
71
|
-
end
|
72
|
-
|
73
|
-
# --------------------------------------------------------------------
|
74
|
-
# Private helper methods to inspect data hash and output contents
|
75
|
-
# to logger at level debugging.
|
76
|
-
# --------------------------------------------------------------------
|
77
|
-
|
78
|
-
# Dissect the (merged) site.data hash and print its contents
|
79
|
-
#
|
80
|
-
# - Print the key string(s)
|
81
|
-
# - Individually analyse the hash[key] values and extract contents
|
82
|
-
# to output.
|
83
|
-
def inspect_hash(hash)
|
84
|
-
hash.each do |key, value|
|
85
|
-
print_key key
|
86
|
-
if value.is_a? Hash
|
87
|
-
inspect_inner_hash value
|
88
|
-
elsif value.is_a? Array
|
89
|
-
extract_hashes_and_print value
|
90
|
-
else
|
91
|
-
print_string value.to_s
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Analyse deeper hashes and extract contents to output
|
97
|
-
def inspect_inner_hash(hash)
|
98
|
-
hash.each do |key, value|
|
99
|
-
if value.is_a? Array
|
100
|
-
print_label key
|
101
|
-
extract_hashes_and_print value
|
102
|
-
elsif value.is_a? Hash
|
103
|
-
print_subkey_and_value key, value
|
104
|
-
else
|
105
|
-
print_hash key, value
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# If an array of strings, print. Otherwise assume as an
|
111
|
-
# array of hashes (sequences) that needs further analysis.
|
112
|
-
def extract_hashes_and_print(array)
|
113
|
-
array.each do |entry|
|
114
|
-
if entry.is_a? String
|
115
|
-
print_list entry
|
116
|
-
else
|
117
|
-
inspect_inner_hash entry
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
#
|
123
|
-
|
124
|
-
# --------------------------------------------------------------------
|
125
|
-
# Private methods for formatting log messages while debugging
|
126
|
-
# --------------------------------------------------------------------
|
127
|
-
|
128
|
-
# Splits a string longer than the value of '@width' into smaller
|
129
|
-
# strings and prints each line as a logger[message]
|
130
|
-
#
|
131
|
-
# string - the long string
|
132
|
-
#
|
133
|
-
# label - optional text to designate the printed lines.
|
134
|
-
def print_long_string(string, label = "")
|
135
|
-
strings = string.scan(%r!(.{1,#{@width}})(\s+|\W|\Z)!).map { |s| s.join.strip }
|
136
|
-
first_line = strings.first.cyan
|
137
|
-
|
138
|
-
label.empty? ? print_value(first_line) : print(label, first_line)
|
139
|
-
strings[1..-1].each { |s| print_value s.cyan }
|
140
|
-
end
|
141
|
-
|
142
|
-
# Prints key as logger[topic] and value as [message]
|
143
|
-
def print_hash(key, value)
|
144
|
-
if value.length > @width
|
145
|
-
print_long_string value, "#{key}:"
|
146
|
-
else
|
147
|
-
print "#{key}:", value.cyan
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def print_list(item)
|
152
|
-
if item.length > @width
|
153
|
-
print_long_string item, "-"
|
154
|
-
else
|
155
|
-
print "-", item.cyan
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def print_string(str)
|
160
|
-
if str.length > @width
|
161
|
-
print_long_string str
|
162
|
-
else
|
163
|
-
print_value str.inspect
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
# Prints the site.data[key] in color
|
168
|
-
def print_key(key)
|
169
|
-
print_clear_line
|
170
|
-
print "Data Key:", " #{key} ".center(@width, "=")
|
171
|
-
print_clear_line
|
172
|
-
end
|
173
|
-
|
174
|
-
# Prints label, keys and values of mappings
|
175
|
-
def print_subkey_and_value(key, value)
|
176
|
-
print_label key
|
177
|
-
value.each do |subkey, val|
|
178
|
-
if val.is_a? Hash
|
179
|
-
print_inner_subkey subkey
|
180
|
-
inspect_inner_hash val
|
181
|
-
elsif val.is_a? Array
|
182
|
-
print_inner_subkey subkey
|
183
|
-
extract_hashes_and_print val
|
184
|
-
elsif val.is_a? String
|
185
|
-
print_hash subkey, val
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
# Print only logger[message], [topic] = nil
|
191
|
-
def print_value(value)
|
192
|
-
if value.is_a? Array
|
193
|
-
extract_hashes_and_print value
|
194
|
-
else
|
195
|
-
print "", value
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
# Print only logger[topic] appended with a colon
|
200
|
-
def print_label(key)
|
201
|
-
print_value " #{key} ".center(@width, "-")
|
202
|
-
end
|
203
|
-
|
204
|
-
def print_inner_subkey(key)
|
205
|
-
print "#{key}:", @dashes
|
206
|
-
end
|
207
|
-
|
208
|
-
def print_dashes
|
209
|
-
print "", @dashes
|
210
|
-
end
|
211
|
-
|
212
|
-
def print_clear_line
|
213
|
-
print ""
|
214
|
-
end
|
215
|
-
|
216
|
-
# Redefine Jekyll Loggers to have the [topic] indented by 30.
|
217
|
-
# (rjust by just 29 to accomodate the additional whitespace added
|
218
|
-
# by Jekyll)
|
219
|
-
def print(topic, message = "")
|
220
|
-
Jekyll.logger.debug topic.rjust(29), message
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module JekyllData
|
4
|
-
class ThemeConfiguration < Jekyll::Configuration
|
5
|
-
class << self
|
6
|
-
# Public: Establish a new site.config hash by reading an optional config
|
7
|
-
# file within the theme-gem and appending the resulting hash to
|
8
|
-
# existing site.config filling in keys not already defined.
|
9
|
-
#
|
10
|
-
# site: current Jekyll::Site instance.
|
11
|
-
#
|
12
|
-
# Returns a config Hash to be used by an 'after_reset' hook.
|
13
|
-
def reconfigure(site)
|
14
|
-
default_hash = Jekyll::Configuration::DEFAULTS
|
15
|
-
theme_config = ThemeConfiguration.new(site).read_theme_config
|
16
|
-
|
17
|
-
# Merge with existing site.config and strip any remaining defaults
|
18
|
-
config = Jekyll::Utils.deep_merge_hashes(
|
19
|
-
theme_config, site.config
|
20
|
-
).reject { |key, value| value == default_hash[key] }
|
21
|
-
|
22
|
-
# Merge DEFAULTS < _config.yml in theme-gem < config file(s) from source
|
23
|
-
# and redefine site.config
|
24
|
-
site.config = Jekyll::Configuration.from(
|
25
|
-
Jekyll::Utils.deep_merge_hashes(theme_config, config)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
def initialize(site)
|
33
|
-
@site = site
|
34
|
-
end
|
35
|
-
|
36
|
-
# Public: Read the '_config.yml' file within the theme-gem.
|
37
|
-
# Additionally validates that the extracted config data and the
|
38
|
-
# the 'value' of '<site.theme.name> key', when present, is a Hash.
|
39
|
-
#
|
40
|
-
# Returns a Configuration Hash
|
41
|
-
def read_theme_config
|
42
|
-
file = @site.in_theme_dir("_config.yml")
|
43
|
-
theme_name = @site.theme.name
|
44
|
-
|
45
|
-
config = safe_load_file(file)
|
46
|
-
|
47
|
-
check_config_is_hash!(config, file)
|
48
|
-
validate_config_hash config[theme_name] unless config[theme_name].nil?
|
49
|
-
|
50
|
-
config
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
# Validate the <site.theme.name> key's value to be accessed via the `theme`
|
56
|
-
# namespace.
|
57
|
-
def validate_config_hash(value)
|
58
|
-
unless value.is_a? Hash
|
59
|
-
Jekyll.logger.abort_with "JekyllData:", "Theme Configuration should be a " \
|
60
|
-
"Hash of key:value pairs or mappings. But got #{value.class} instead."
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module JekyllData
|
2
|
-
class ThemeDataReader < Jekyll::DataReader
|
3
|
-
attr_reader :site, :content
|
4
|
-
def initialize(site)
|
5
|
-
@site = site
|
6
|
-
@content = {}
|
7
|
-
@entry_filter = Jekyll::EntryFilter.new(site)
|
8
|
-
end
|
9
|
-
|
10
|
-
def read(dir)
|
11
|
-
return unless site.theme && site.theme.data_path
|
12
|
-
base = site.in_theme_dir(dir)
|
13
|
-
read_data_to(base, @content)
|
14
|
-
@content
|
15
|
-
end
|
16
|
-
|
17
|
-
def read_data_to(dir, data)
|
18
|
-
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
|
19
|
-
|
20
|
-
entries = Dir.chdir(dir) do
|
21
|
-
Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
22
|
-
end
|
23
|
-
|
24
|
-
entries.each do |entry|
|
25
|
-
path = @site.in_theme_dir(dir, entry)
|
26
|
-
next if @entry_filter.symlink?(path)
|
27
|
-
|
28
|
-
if File.directory?(path)
|
29
|
-
read_data_to(path, data[sanitize_filename(entry)] = {})
|
30
|
-
else
|
31
|
-
key = sanitize_filename(File.basename(entry, ".*"))
|
32
|
-
data[key] = read_data_file(path)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module JekyllData
|
4
|
-
class ThemedSiteDrop < Jekyll::Drops::SiteDrop
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
mutable false
|
8
|
-
|
9
|
-
def_delegator :@obj, :site_data, :data
|
10
|
-
def_delegators :@obj, :theme
|
11
|
-
|
12
|
-
private
|
13
|
-
def_delegator :@obj, :config, :fallback_data
|
14
|
-
end
|
15
|
-
end
|
data/lib/jekyll-data/version.rb
DELETED
data/lib/jekyll/build_options.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
class Command
|
3
|
-
class << self
|
4
|
-
#
|
5
|
-
# patch original method to inject a '--show-data' switch to display
|
6
|
-
# merged data hash
|
7
|
-
#
|
8
|
-
alias_method :original_build_options, :add_build_options
|
9
|
-
|
10
|
-
def add_build_options(c)
|
11
|
-
original_build_options(c)
|
12
|
-
c.option "show-data", "--show-data",
|
13
|
-
"Print merged site-data hash when used with --verbose."
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/jekyll/data_path.rb
DELETED
data/lib/jekyll/theme_drop.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Drops
|
5
|
-
class UnifiedPayloadDrop < Drop
|
6
|
-
def site
|
7
|
-
@site_drop ||= JekyllData::ThemedSiteDrop.new(@obj)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Register a namespace to easily call subkeys under <theme-name> key
|
11
|
-
# in the _config.yml within a theme-gem via its bundled templates.
|
12
|
-
# e.g. with this drop, theme-specific variables usually called like
|
13
|
-
# {{ site.minima.date_format }} can be shortened to simply
|
14
|
-
# {{ theme.date_format }}.
|
15
|
-
def theme
|
16
|
-
@theme_drop ||= site[site.theme.name]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|