jekyll-get-data-json 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +16 -0
- data/.gitignore +4 -0
- data/LICENSE +21 -0
- data/README.md +45 -0
- data/jekyll-get-data-json.gemspec +18 -0
- data/lib/jekyll-get-data-json/converter.rb +39 -0
- data/lib/jekyll-get-data-json/version.rb +3 -0
- data/lib/jekyll-get-data-json.rb +5 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e67af310a82b1e7fb3000028e36a676a837263a792b7d36bfd887d51996f259
|
4
|
+
data.tar.gz: f10c252bc7e335c7b821e76d807def250ad2cf812d1693a4f456e4ec7766e240
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 66bf84deeb414e0c0cdc2c79c9a36baccdcedb5faa9838fcb234cd6212c3d9482b6f9990b79d467927dcbdc33025cfa5f027eab73c2865dafa3f3724cc399173
|
7
|
+
data.tar.gz: a70d70618dfcede98f4c6d538a035ba3371e8de5359687c1f704bf993544fc2bfb6ef5b7dd45414726e6eb77304d363352b8792e51d2c86602c8e2050dc7b8a2
|
data/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
indent_style = space
|
5
|
+
indent_size = 2
|
6
|
+
trim_trailing_whitespace = true
|
7
|
+
insert_final_newline = true
|
8
|
+
|
9
|
+
[*.{md,rb,gemspec},Makefile]
|
10
|
+
charset = utf-8
|
11
|
+
|
12
|
+
[Makefile]
|
13
|
+
indent_style = tab
|
14
|
+
|
15
|
+
[*.md]
|
16
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Brock Fanning <brockfanning@gmail.com> (https://github.com/brockfanning
|
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,45 @@
|
|
1
|
+
# jekyll-get-data-json
|
2
|
+
|
3
|
+
> 💎 Import remote JSON data into the data for a Jekyll site
|
4
|
+
|
5
|
+
> This version uses the `_data` folder so that you can more freely manage without having to restart jekyll
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
1. Use `bundle add jekyll-get-data-json` to add this to your site's Gemfile.
|
9
|
+
2. Add this plugin to the `plugins` listed in your `_config.yml` file. For example:
|
10
|
+
```
|
11
|
+
plugins:
|
12
|
+
- jekyll-get-data-json
|
13
|
+
```
|
14
|
+
Or you can download the [converter.rb](https://raw.githubusercontent.com/maling-it/jekyll-get-data-json/master/lib/jekyll-get-data-json/converter.rb) file and put it in the _plugins . folder
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Create a `getjson.yml` file inside your `_data` folder. This section should be an object array containing the `data` and `json` properties:
|
18
|
+
* The `data` property specifies where in the `site.data` you would like to put this data.
|
19
|
+
* The `json` property is the remote URL of the JSON file.
|
20
|
+
|
21
|
+
To illustrate an example, assuming that you have a remote JSON file at `https://example.com/data.json` containing this:
|
22
|
+
```
|
23
|
+
{
|
24
|
+
"bar": "Success!"
|
25
|
+
}
|
26
|
+
```
|
27
|
+
And you put the following into your `getjson.yml` file:
|
28
|
+
```
|
29
|
+
- data: foo
|
30
|
+
json: 'https://example.com/data.json'
|
31
|
+
```
|
32
|
+
Then in your Jekyll site you will be able to use:
|
33
|
+
```
|
34
|
+
{{ site.data.foo.bar }}
|
35
|
+
```
|
36
|
+
And you will see:
|
37
|
+
```
|
38
|
+
Success!
|
39
|
+
```
|
40
|
+
|
41
|
+
## Credit
|
42
|
+
|
43
|
+
This plugin is basically a more limited version of [jekyll-get](https://github.com/18F/jekyll-get), duplicated here purely for the purposes of making it a Ruby gem.
|
44
|
+
|
45
|
+
This plugin is basically another version of [jekyll-get-json](https://github.com/brockfanning/jekyll-get-json), duplicated here purely for better usage purposes.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jekyll-get-data-json/version"
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "jekyll-get-data-json"
|
6
|
+
spec.summary = "Import remote JSON data into the data for a Jekyll site"
|
7
|
+
spec.description = "Import remote JSON data into the data for a Jekyll site"
|
8
|
+
spec.version = JekyllGetDataJson::VERSION
|
9
|
+
spec.authors = ["Zxce3"]
|
10
|
+
spec.email = ["memetpea25@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/maling-it/jekyll-get-data-json"
|
12
|
+
spec.licenses = ["MIT"]
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
spec.add_dependency "jekyll", ">= 4.2"
|
16
|
+
spec.add_dependency "deep_merge", "~> 1.2"
|
17
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require 'json'
|
3
|
+
require 'deep_merge'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module JekyllGetDataJson
|
7
|
+
class GetJsonGenerator < Jekyll::Generator
|
8
|
+
safe true
|
9
|
+
priority :highest
|
10
|
+
|
11
|
+
def generate(site)
|
12
|
+
|
13
|
+
config = site.data['getjson']
|
14
|
+
if !config
|
15
|
+
warn "No config".yellow
|
16
|
+
return
|
17
|
+
end
|
18
|
+
if !config.kind_of?(Array)
|
19
|
+
config = [config]
|
20
|
+
end
|
21
|
+
|
22
|
+
config.each do |d|
|
23
|
+
begin
|
24
|
+
target = site.data[d['data']]
|
25
|
+
source = JSON.load(URI.open(d['json']))
|
26
|
+
|
27
|
+
if target
|
28
|
+
target.deep_merge(source)
|
29
|
+
else
|
30
|
+
site.data[d['data']] = source
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
next
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-get-data-json
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zxce3
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-20 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.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: deep_merge
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
description: Import remote JSON data into the data for a Jekyll site
|
42
|
+
email:
|
43
|
+
- memetpea25@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".editorconfig"
|
49
|
+
- ".gitignore"
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- jekyll-get-data-json.gemspec
|
53
|
+
- lib/jekyll-get-data-json.rb
|
54
|
+
- lib/jekyll-get-data-json/converter.rb
|
55
|
+
- lib/jekyll-get-data-json/version.rb
|
56
|
+
homepage: https://github.com/maling-it/jekyll-get-data-json
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
allowed_push_host: https://rubygems.org
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubygems_version: 3.2.32
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Import remote JSON data into the data for a Jekyll site
|
80
|
+
test_files: []
|