jekyll-sqlite 0.1.3 → 0.1.5
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
- data/.rubocop.yml +7 -2
- data/CHANGELOG.md +6 -0
- data/Gemfile +6 -1
- data/README.md +62 -57
- data/Rakefile +60 -0
- data/jekyll-sqlite.gemspec +33 -0
- data/lib/jekyll-sqlite/generator.rb +97 -57
- data/lib/jekyll-sqlite/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf075a895e90cae8f3b5d69299089ad2f2381b9ba255348b7f517c6ef03f8a0
|
4
|
+
data.tar.gz: 920c6c9292ead41d747e88a8cb6ab5e5a1a85d54d19781d3b675a316a90c3e98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769762e5786644f055002eae18dd443e12989242f24f5ce79cbd03dcea235bf73cc7e6b4c6a70b30dac024d03ca03e84fbe5f16ef5cdf9289cd930b8ccbeedf4
|
7
|
+
data.tar.gz: 0c950eca035285304de7900e780b41e769340083b9966c2a01df02a4b10330bc8917cbd63be53f84852ceb1e8dfb7f7d4845c73c89afa0fa8f4719c8dfad82fb
|
data/.rubocop.yml
CHANGED
@@ -2,7 +2,12 @@ require: rubocop-rake
|
|
2
2
|
AllCops:
|
3
3
|
TargetRubyVersion: 3.0
|
4
4
|
NewCops: enable
|
5
|
-
|
5
|
+
Exclude:
|
6
|
+
- "node_modules/**/*"
|
7
|
+
- "tmp/**/*"
|
8
|
+
- "vendor/**/*"
|
9
|
+
- ".git/**/*"
|
10
|
+
- "test/_plugins/jekyll_sqlite_generator.rb"
|
6
11
|
Style/StringLiterals:
|
7
12
|
Enabled: true
|
8
13
|
EnforcedStyle: double_quotes
|
@@ -15,4 +20,4 @@ Layout/LineLength:
|
|
15
20
|
Max: 120
|
16
21
|
|
17
22
|
Metrics/AbcSize:
|
18
|
-
Max:
|
23
|
+
Max: 15
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.4] - 2024-07-17
|
4
|
+
- Per-page queries are now supported via a `sqlite` config block in the front matter.
|
5
|
+
- Documents support for existing site data being used within queries.
|
6
|
+
- Code cleanup and refactoring.
|
7
|
+
- Don't disable journaling on the database.
|
8
|
+
|
3
9
|
## [0.1.3] - 2024-07-02
|
4
10
|
- First functional version
|
5
11
|
- Adds tests
|
data/Gemfile
CHANGED
@@ -6,7 +6,12 @@ source "https://rubygems.org"
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
# These are development dependencies
|
9
|
-
gem "rake", "~> 13.0"
|
10
9
|
gem "jekyll", "~> 4.0"
|
10
|
+
gem "rake", "~> 13.0"
|
11
11
|
gem "rubocop", "~> 1.21"
|
12
12
|
gem "rubocop-rake", "~> 0.6.0"
|
13
|
+
|
14
|
+
# Ruby 3.4 preparedness
|
15
|
+
gem "base64", "~> 0.2.0"
|
16
|
+
gem "bigdecimal", "~> 3.1"
|
17
|
+
gem "csv", "~> 3.3"
|
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
A Jekyll generator plugin to lets you use SQLite database instead of data files as a data source. It lets you easily create APIs and websites from a SQLite database, by linking together a database file, your template, and the relevant queries.
|
4
4
|
|
5
|
-
It
|
5
|
+
It supports site-level queries, per-page queries, and prepared queries that can
|
6
|
+
use existing data (possibly generated via more queries) as parameters.
|
6
7
|
|
7
8
|
[](https://github.com/captn3m0/jekyll-sqlite/actions/workflows/main.yml) [](https://badge.fury.io/rb/jekyll-sqlite)
|
8
9
|
|
@@ -31,73 +32,38 @@ the `test` directory for a functional example with the [Northwind database](http
|
|
31
32
|
```yml
|
32
33
|
...
|
33
34
|
sqlite:
|
34
|
-
- data: orders
|
35
|
-
file: &db "_db/northwind.db"
|
36
|
-
query: SELECT * from Orders
|
37
35
|
- data: customers
|
38
36
|
file: *db
|
39
37
|
query: SELECT * from Customers
|
40
|
-
- data: categories
|
41
|
-
file: *db
|
42
|
-
query: SELECT CategoryID, CategoryName, Description FROM Categories
|
43
|
-
# Note that the CategoryID parameter in the query is coming from site.data.categories[].CategoryID
|
44
|
-
# which was picked up in the previous query
|
45
|
-
- data: categories.products
|
46
|
-
file: *db
|
47
|
-
query: SELECT ProductID, ProductName FROM Products WHERE Products.CategoryID=:CategoryID
|
48
38
|
```
|
49
39
|
|
50
40
|
Then, you can use the `site.data` attributes accordingly:
|
51
41
|
|
52
42
|
```liquid
|
53
|
-
{{ site.data.
|
54
|
-
```
|
55
|
-
|
56
|
-
## Generating Pages
|
57
|
-
|
58
|
-
It works well with the `datapage_gen` plugin:
|
59
|
-
|
60
|
-
See the [datapage_gen](https://github.com/avillafiorita/jekyll-datapage_gen) docs for more details.
|
61
|
-
|
62
|
-
Here's a sample configuration:
|
63
|
-
|
64
|
-
```yaml
|
65
|
-
# This will automatically generate a file for each restaurant
|
66
|
-
# restaurants/#{id}.html file
|
67
|
-
# with the layout `_layouts/restaurant.html`
|
68
|
-
# and page.id, page.name, page.active set
|
69
|
-
# and page.title set to restaurant name
|
70
|
-
sqlite:
|
71
|
-
restaurants:
|
72
|
-
file: _db/reviews.db
|
73
|
-
sql: SELECT id, name, last_review_date > 1672531200 as active, address FROM restaurants;
|
74
|
-
page_gen:
|
75
|
-
- data: restaurants
|
76
|
-
template: restaurant
|
77
|
-
name: id
|
78
|
-
title: name
|
79
|
-
filter: active
|
43
|
+
{{ site.data.customers | jsonify }}
|
80
44
|
```
|
81
45
|
|
82
|
-
##
|
46
|
+
## Prepared Queries
|
83
47
|
|
84
|
-
|
85
|
-
|
48
|
+
This plugin supports prepared queries with parameter binding. This lets you
|
49
|
+
use existing data from a previous query, or some other source (such as
|
50
|
+
`site.data.*` or `page.*`) as a parameter in your query.
|
86
51
|
|
87
|
-
Say you have a YAML file defining your items (`data/
|
52
|
+
Say you have a YAML file defining your items (`data/books.yaml`):
|
88
53
|
|
89
54
|
```yaml
|
90
55
|
- id: 31323952-2708-42dc-a995-6006a23cbf00
|
91
|
-
name:
|
56
|
+
name: Time Travel with a Rubber Band
|
92
57
|
- id: 5c8e67a0-d490-4743-b5b8-8e67bd1f95a2
|
93
|
-
name:
|
58
|
+
name: The Art of Cache Invalidation
|
94
59
|
```
|
95
60
|
and the prices for the items in your SQLite database, the following configuration will enrich the `items` array with the price:
|
96
61
|
|
97
62
|
```yaml
|
98
63
|
sql:
|
99
|
-
- data:
|
100
|
-
query: SELECT price,author FROM pricing WHERE id =:id
|
64
|
+
- data: items.books
|
65
|
+
query: SELECT price, author FROM pricing WHERE id =:id
|
66
|
+
db: books.db
|
101
67
|
```
|
102
68
|
This would allow the following Liquid loop to be written:
|
103
69
|
|
@@ -107,23 +73,62 @@ This would allow the following Liquid loop to be written:
|
|
107
73
|
{% endfor %}
|
108
74
|
```
|
109
75
|
|
110
|
-
|
76
|
+
## Per Page Queries
|
77
|
+
|
78
|
+
The exact same syntax can be used on a per-page basis to generate data within
|
79
|
+
each page. This is helpful for keeping page-specific queries within the page
|
80
|
+
itself. Here's an example:
|
111
81
|
|
112
82
|
```yaml
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
83
|
+
---
|
84
|
+
FeaturedSupplierID: 2
|
85
|
+
sqlite:
|
86
|
+
- data: suppliers
|
87
|
+
file: "_db/northwind.db"
|
88
|
+
query: "SELECT CompanyName, SupplierID FROM suppliers ORDER BY SupplierID"
|
89
|
+
- data: suppliers.products
|
90
|
+
# This is a prepared query, where SupplierID is coming from the previous query.
|
91
|
+
file: "_db/northwind.db"
|
92
|
+
query: "SELECT ProductName, CategoryID,UnitPrice FROM products WHERE SupplierID = :SupplierID"
|
93
|
+
# :FeaturedSupplierID is picked up automatically from the page frontmatter.
|
94
|
+
- data: FeaturedSupplier
|
95
|
+
file: "_db/northwind.db"
|
96
|
+
query: "SELECT * SupplierID = :FeaturedSupplierID"
|
97
|
+
---
|
98
|
+
{{page.suppliers|jsonify}}
|
117
99
|
```
|
118
100
|
|
119
|
-
|
101
|
+
This will generate a `page.suppliers` array with all the suppliers, and a `page.FeaturedSupplier` object with the details of the featured supplier.
|
120
102
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
103
|
+
Each supplier will have a `products` array with all the products for that supplier.
|
104
|
+
|
105
|
+
## Generating Pages
|
106
|
+
|
107
|
+
It works well with the `datapage_gen` plugin:
|
108
|
+
|
109
|
+
See the [datapage_gen](https://github.com/avillafiorita/jekyll-datapage_gen) docs for more details.
|
110
|
+
|
111
|
+
Here's a sample configuration:
|
112
|
+
|
113
|
+
```yaml
|
114
|
+
sqlite:
|
115
|
+
restaurants:
|
116
|
+
file: _db/reviews.db
|
117
|
+
sql: SELECT id, name, last_review_date > 1672531200 as active, address FROM restaurants;
|
118
|
+
page_gen:
|
119
|
+
- data: restaurants
|
120
|
+
template: restaurant
|
121
|
+
name: id
|
122
|
+
title: name
|
123
|
+
filter: active
|
125
124
|
```
|
126
125
|
|
126
|
+
This will automatically generate a file for each restaurant
|
127
|
+
restaurants/#{id}.html file with the layout `_layouts/restaurant.html` and page.id, page.name, page.active set and page.title set to restaurant name
|
128
|
+
|
129
|
+
Note that the `datapage_gen` plugin will run _after_ the `jekyll-sqlite` plugin,
|
130
|
+
if you generate any pages with per-page queries, these queries will not execute.
|
131
|
+
|
127
132
|
## Development
|
128
133
|
|
129
134
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
@@ -2,7 +2,67 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rubocop/rake_task"
|
5
|
+
require "jekyll"
|
6
|
+
require "sqlite3"
|
5
7
|
|
6
8
|
RuboCop::RakeTask.new
|
7
9
|
|
10
|
+
def assert(cond, msg = "Assertion Failed")
|
11
|
+
raise msg unless cond
|
12
|
+
end
|
13
|
+
|
14
|
+
def query_db(query)
|
15
|
+
db = SQLite3::Database.new "_db/northwind.db"
|
16
|
+
db.results_as_hash = true
|
17
|
+
results = db.execute query
|
18
|
+
results[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
# rubocop:disable Metrics/AbcSize
|
22
|
+
# rubocop:disable Metrics/MethodLength
|
23
|
+
def validate_json
|
24
|
+
file = "_site/data.json"
|
25
|
+
data = JSON.parse(File.read(file))
|
26
|
+
assert data["orders"].size == 53, "Expected 53 orders, got #{data["orders"].size}"
|
27
|
+
assert data["customers"].size == 93, "Expected 93 customers, got #{data["customers"].size}"
|
28
|
+
assert data["categories"].size == 8, "Expected 93 categories, got #{data["categories"].size}"
|
29
|
+
assert data["orders"][0] == query_db("SELECT * FROM Orders LIMIT 1"), "Order Fetch Failed"
|
30
|
+
assert data["customers"][0] == query_db("SELECT * FROM Customers LIMIT 1"), "Customer Fetch Failed"
|
31
|
+
assert data["customers"][0] == query_db("SELECT * FROM Customers LIMIT 1"), "Customer Fetch Failed"
|
32
|
+
assert data["categories"][0]["products"].size == 12, "Products don't match"
|
33
|
+
data["categories"][0]["products"].each do |p|
|
34
|
+
assert p["CategoryID"] == 1, "CategoryID doesn't match"
|
35
|
+
end
|
36
|
+
assert data["delayedOrders"].size == 17
|
37
|
+
assert data["delayedOrders"][0]["OrderID"] == 10_249
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_page_json
|
41
|
+
file = "_site/suppliers.json"
|
42
|
+
read_data = JSON.parse(File.read(file))
|
43
|
+
data = read_data["allSuppliers"]
|
44
|
+
assert data.size == 29, "Expected 29 suppliers, got #{data.size}"
|
45
|
+
r = query_db("SELECT CompanyName, SupplierID FROM Suppliers ORDER BY SupplierID LIMIT 1")
|
46
|
+
assert r["CompanyName"] == data[0]["CompanyName"], "Company Name doesn't match"
|
47
|
+
assert r["SupplierID"] == data[0]["SupplierID"], "Supplier ID doesn't match"
|
48
|
+
assert data[0]["products"].size == 3, "Products don't match"
|
49
|
+
assert data[0]["products"][0]["ProductName"] == "Chai"
|
50
|
+
assert data[0]["products"][1]["ProductName"] == "Chang"
|
51
|
+
assert data[0]["products"][2]["ProductName"] == "Aniseed Syrup"
|
52
|
+
|
53
|
+
# Focus Supplier - this uses the data from the page front-matter to prepare a query
|
54
|
+
fs = query_db("SELECT * FROM Suppliers WHERE SupplierID = 6")
|
55
|
+
assert read_data["focusSupplier"][0] == fs, "Focus Supplier doesn't match"
|
56
|
+
end
|
57
|
+
# rubocop:enable Metrics/AbcSize
|
58
|
+
# rubocop:enable Metrics/MethodLength
|
59
|
+
|
8
60
|
task default: :rubocop
|
61
|
+
|
62
|
+
desc "Build Test Site"
|
63
|
+
task :test do
|
64
|
+
Dir.chdir("test")
|
65
|
+
Jekyll::Site.new(Jekyll.configuration).process
|
66
|
+
validate_json
|
67
|
+
validate_page_json
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll-sqlite/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jekyll-sqlite"
|
7
|
+
spec.license = "MIT"
|
8
|
+
spec.version = Jekyll::Sqlite::VERSION
|
9
|
+
spec.authors = ["Nemo"]
|
10
|
+
spec.email = ["jekyll-sqlite@captnemo.in"]
|
11
|
+
|
12
|
+
spec.summary = "A Jekyll plugin to use SQLite databases as a data source."
|
13
|
+
spec.homepage = "https://github.com/captn3m0/jekyll-sqlite"
|
14
|
+
spec.required_ruby_version = ">= 3.0.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/captn3m0/jekyll-sqlite/blob/master/CHANGELOG.md"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "sqlite3", "~> 2.0"
|
32
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
33
|
+
end
|
@@ -1,100 +1,140 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "sqlite3"
|
3
4
|
|
4
5
|
module JekyllSQlite
|
5
6
|
# Main generator class
|
6
7
|
class Generator < Jekyll::Generator
|
7
|
-
safe true
|
8
8
|
# Set to high to be higher than the Jekyll Datapages Plugin
|
9
9
|
priority :high
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
|
11
|
+
##
|
12
|
+
# Split the given key using dots and return the last part
|
13
|
+
# customers.order -> order
|
14
|
+
def get_tip(name)
|
15
|
+
name.split(".")[-1]
|
15
16
|
end
|
16
17
|
|
18
|
+
##
|
17
19
|
# Get the root of where we are generating the data
|
18
20
|
def get_root(root, db_name)
|
19
21
|
db_name.split(".")[0..-2].each do |p|
|
20
22
|
root = root[p]
|
23
|
+
rescue KeyError
|
24
|
+
raise "Jekyll SQLite: Invalid root. #{p} not found while iterating to #{db_name}"
|
21
25
|
end
|
22
26
|
root
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
db.prepare(query) do |stmt|
|
35
|
-
# We bind params, ignoring any errors
|
36
|
-
# Since there's no way to get required params
|
37
|
-
# From a statement
|
38
|
-
item.each do |key, value|
|
39
|
-
stmt.bind_param key, value
|
40
|
-
rescue StandardError # rubocop:disable Lint/SuppressedException
|
41
|
-
end
|
42
|
-
stmt.execute.each { |d| item[db_name] << d }
|
29
|
+
##
|
30
|
+
# Prepare the query by binding the parameters
|
31
|
+
# Since we don't know if the query needs them
|
32
|
+
# we ignore all errors about "no such bind parameter"
|
33
|
+
def _prepare_query(stmt, params)
|
34
|
+
params.each do |key, value|
|
35
|
+
stmt.bind_param key, value
|
36
|
+
rescue StandardError => e
|
37
|
+
raise e unless e.message.include? "no such bind parameter"
|
43
38
|
end
|
44
|
-
item[db_name].size
|
45
39
|
end
|
46
40
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
41
|
+
##
|
42
|
+
# Internal function to generate data given
|
43
|
+
# root: a Hash-Like root object (site.data, site.data.*, page.data)
|
44
|
+
# key: string as the key to use to attach the data to the root
|
45
|
+
# db: SQLite3 Database object to execute the query on
|
46
|
+
# query: string containing the query to execute
|
47
|
+
# Sets root[db_name] = ResultSet of the query, as an array
|
48
|
+
# Returns the count of the result set
|
49
|
+
def _gen_data(root, key, db, query)
|
50
|
+
db.prepare(query) do |stmt|
|
51
|
+
_prepare_query stmt, get_bind_params(root)
|
52
|
+
root[key] = stmt.execute.to_a
|
56
53
|
end
|
57
|
-
count
|
54
|
+
root[key].count
|
58
55
|
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
57
|
+
##
|
58
|
+
# Calls _gen_data for the given root
|
59
|
+
# iterates through the array if root is an array
|
60
|
+
def gen_data(root, ...)
|
61
|
+
if root.is_a? Array
|
62
|
+
# call gen_data for each item in the array
|
63
|
+
# and return the sum of all the counts
|
64
|
+
root.map { |item| gen_data(item, ...) }.sum
|
65
|
+
else
|
66
|
+
_gen_data(root, ...)
|
66
67
|
end
|
67
|
-
count
|
68
|
-
end
|
69
|
-
|
70
|
-
def get_tip(name)
|
71
|
-
name.split(".")[-1]
|
72
68
|
end
|
73
69
|
|
70
|
+
##
|
71
|
+
# Validate given configuration object
|
74
72
|
def validate_config(config)
|
75
73
|
return false unless config.is_a? Hash
|
76
74
|
return false unless config.key?("query")
|
77
75
|
return false unless File.exist?(config["file"])
|
78
76
|
return false unless config.key?("data")
|
77
|
+
|
79
78
|
true
|
80
79
|
end
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
## pick bindable parameters
|
82
|
+
# from the root
|
83
|
+
# All primitive values are bound to the query
|
84
|
+
# Arrays and Hashes are ignored
|
85
|
+
def get_bind_params(dict)
|
86
|
+
dict.select { |_key, value| !value.is_a?(Array) && !value.is_a?(Hash) }
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Given a configuration, generate the data
|
91
|
+
# and attach it to the given data_root
|
92
|
+
def generate_data_from_config(root, config)
|
93
|
+
key = config["data"]
|
94
|
+
query = config["query"]
|
95
|
+
file = config["file"]
|
96
|
+
SQLite3::Database.new file, readonly: true do |db|
|
97
|
+
db.results_as_hash = config.fetch("results_as_hash", true)
|
98
|
+
|
99
|
+
branch = get_root(root, key)
|
100
|
+
tip = get_tip(config["data"])
|
101
|
+
|
102
|
+
count = gen_data(branch, tip, db, query)
|
103
|
+
Jekyll.logger.info "Jekyll SQLite:", "Loaded #{key}. Count=#{count}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# Iterate through all the pages in the site
|
109
|
+
# and generate the data from the configuration
|
110
|
+
def gen_pages(site)
|
111
|
+
site.pages.each do |page|
|
112
|
+
gen(page.data, page)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Generate the data from the configuration
|
118
|
+
# Takes as input the root where the data will be attached
|
119
|
+
# and a configuration holder, where the sqlite key can be found
|
120
|
+
# Root is either site.data or page.data
|
121
|
+
# and config_holder is either site.config or page itself.
|
122
|
+
def gen(root, config_holder)
|
123
|
+
sqlite_configs = config_holder["sqlite"] || []
|
124
|
+
sqlite_configs.each do |config|
|
85
125
|
unless validate_config(config)
|
86
126
|
Jekyll.logger.error "Jekyll SQLite:", "Invalid Configuration. Skipping"
|
87
127
|
next
|
88
128
|
end
|
89
|
-
|
90
|
-
SQLite3::Database.new config["file"], readonly: true do |db|
|
91
|
-
fast_setup db
|
92
|
-
db.results_as_hash = config.fetch("results_as_hash", true)
|
93
|
-
root = get_root(site.data, d_name)
|
94
|
-
count = gen_data(root, config, get_tip(d_name), db)
|
95
|
-
Jekyll.logger.info "Jekyll SQLite:", "Loaded #{d_name}. Count=#{count}"
|
96
|
-
end
|
129
|
+
generate_data_from_config(root, config)
|
97
130
|
end
|
98
131
|
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Entrpoint to the generator, called by Jekyll
|
135
|
+
def generate(site)
|
136
|
+
gen(site.data, site.config)
|
137
|
+
gen_pages(site)
|
138
|
+
end
|
99
139
|
end
|
100
140
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-sqlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nemo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -16,15 +16,15 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
description:
|
26
|
+
version: '2.0'
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- jekyll-sqlite@captnemo.in
|
30
30
|
executables: []
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- Gemfile
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
|
+
- jekyll-sqlite.gemspec
|
40
41
|
- lib/jekyll-sqlite/generator.rb
|
41
42
|
- lib/jekyll-sqlite/version.rb
|
42
43
|
- lib/jekyll_sqlite.rb
|
@@ -48,7 +49,7 @@ metadata:
|
|
48
49
|
source_code_uri: https://github.com/captn3m0/jekyll-sqlite
|
49
50
|
changelog_uri: https://github.com/captn3m0/jekyll-sqlite/blob/master/CHANGELOG.md
|
50
51
|
rubygems_mfa_required: 'true'
|
51
|
-
post_install_message:
|
52
|
+
post_install_message:
|
52
53
|
rdoc_options: []
|
53
54
|
require_paths:
|
54
55
|
- lib
|
@@ -63,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
64
|
- !ruby/object:Gem::Version
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
|
-
rubygems_version: 3.5.
|
67
|
-
signing_key:
|
67
|
+
rubygems_version: 3.5.11
|
68
|
+
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: A Jekyll plugin to use SQLite databases as a data source.
|
70
71
|
test_files: []
|