jekyll-write-and-commit-changes 0.2.3 → 0.3.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
- checksums.yaml.gz.sig +0 -0
- data/README.md +7 -0
- data/lib/jekyll/document_writer.rb +59 -25
- data.tar.gz.sig +0 -0
- metadata +31 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 655b02a7cc7a4889eab96ca03d4f382761a18cb1f53c1f5d2e7425dffbccf4d2
|
4
|
+
data.tar.gz: 515baaf4b6f14889b65e7e21f346709b1b0304b11c32ef2d2e4213fee960f9f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c7196b4f10affc4f8a618587e49d43ecddf19ee60a0c13d45ac4f7253d1e1bb55ccf15e485b29144fab5811bd42927cc005d279bab451788ae576a18aa5ea9
|
7
|
+
data.tar.gz: 6141bfb6372ca466d4ab7620c1d9e6eaed3507d7e9dac81777e82c0714a946514df6420c835918a8b2a0fdb0f289e26ceb7250e1b6fb74a76c8c442186ea2af9
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/README.md
CHANGED
@@ -47,6 +47,13 @@ Jekyll::Hooks.register :site, :post_read do |site|
|
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
50
|
+
## Sutty CMS
|
51
|
+
|
52
|
+
If you're using the [Sutty CMS](https://panel.sutty.nl), the plugin will
|
53
|
+
detect the layout schemas on the `_data/layouts/` directory and extract
|
54
|
+
the required attributes on the order they're set. This way the post will
|
55
|
+
not change the order of the attributes.
|
56
|
+
|
50
57
|
## Contributing
|
51
58
|
|
52
59
|
Bug reports and pull requests are welcome on 0xacab.org at
|
@@ -1,25 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'digest'
|
3
4
|
require 'jekyll/document'
|
4
5
|
|
5
6
|
module Jekyll
|
6
7
|
module DocumentWriter
|
8
|
+
EXCLUDED_ATTRIBUTES = %w[slug ext date excerpt].freeze
|
9
|
+
SUTTY_FIELDS = %w[permalink alternate_permalinks layout uuid render_with_liquid usuaries created_at last_modified_at].freeze
|
10
|
+
|
7
11
|
def self.included(base)
|
8
12
|
base.class_eval do
|
9
13
|
# Writes changes to the file and adds it to git staged changes
|
14
|
+
#
|
15
|
+
# @return [Bool,nil]
|
10
16
|
def save
|
11
17
|
return unless data.fetch('save', true)
|
12
18
|
|
13
|
-
|
19
|
+
file_digest = Digest::SHA2.file(path).hexdigest
|
20
|
+
content_digest = Digest::SHA2.hexdigest(writable_content)
|
21
|
+
|
22
|
+
return if file_digest == content_digest
|
23
|
+
|
24
|
+
Jekyll.logger.debug 'Writing:', real_path
|
14
25
|
|
15
26
|
file = File.open(path, File::RDWR | File::CREAT, 0o640) do |f|
|
16
27
|
f.flock(File::LOCK_EX)
|
17
28
|
f.rewind
|
18
|
-
|
19
|
-
f.write(sanitized_data.to_yaml)
|
20
|
-
f.write("---\n\n")
|
21
|
-
f.write(content)
|
22
|
-
|
29
|
+
f.write(writable_content)
|
23
30
|
f.flush
|
24
31
|
f.truncate(f.pos)
|
25
32
|
end
|
@@ -29,30 +36,16 @@ module Jekyll
|
|
29
36
|
file.zero?
|
30
37
|
end
|
31
38
|
|
32
|
-
# Resolves the real path for the document
|
33
|
-
# @return [String]
|
34
|
-
def real_path
|
35
|
-
@real_path ||= Pathname.new(relative_path).realpath.relative_path_from(site.source).to_s
|
36
|
-
end
|
37
|
-
|
38
39
|
# Prepares the data for dumping, by excluding some keys and
|
39
40
|
# transforming other Documents replaced by jekyll-linked-posts.
|
40
41
|
#
|
41
42
|
# @return [Hash]
|
42
43
|
def sanitized_data
|
43
|
-
data.
|
44
|
-
excluded_attributes.include? k
|
45
|
-
end.transform_values do |value|
|
44
|
+
data.slice(*attributes).transform_values do |value|
|
46
45
|
case value
|
47
|
-
when Jekyll::Document
|
46
|
+
when Jekyll::Document, Jekyll::Convertible
|
48
47
|
value.data['uuid']
|
49
|
-
when
|
50
|
-
value.data['uuid']
|
51
|
-
when Set
|
52
|
-
value.map do |v|
|
53
|
-
v.respond_to?(:data) ? v.data['uuid'] : v
|
54
|
-
end
|
55
|
-
when Array
|
48
|
+
when Array, Set
|
56
49
|
value.map do |v|
|
57
50
|
v.respond_to?(:data) ? v.data['uuid'] : v
|
58
51
|
end
|
@@ -66,8 +59,49 @@ module Jekyll
|
|
66
59
|
end
|
67
60
|
end
|
68
61
|
|
69
|
-
|
70
|
-
|
62
|
+
private
|
63
|
+
|
64
|
+
# Resolves the real path for the document
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
def real_path
|
68
|
+
@real_path ||= Pathname.new(relative_path).realpath.relative_path_from(site.source).to_s
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
relative_path
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Array<String>]
|
74
|
+
def attributes
|
75
|
+
@attributes ||= data.keys - EXCLUDED_ATTRIBUTES
|
76
|
+
end
|
77
|
+
|
78
|
+
def layout?
|
79
|
+
layout.is_a? Hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Hash,nil]
|
83
|
+
def layout
|
84
|
+
@layout ||= site.data.dig('layouts', data['layout'])
|
85
|
+
end
|
86
|
+
|
87
|
+
def fields
|
88
|
+
@fields ||= (layout.keys + SUTTY_FIELDS).uniq
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String]
|
92
|
+
def writable_content
|
93
|
+
@writable_content ||=
|
94
|
+
begin
|
95
|
+
dumpable_data = sanitized_data
|
96
|
+
dumpable_data = dumpable_data.slice(*fields) if layout?
|
97
|
+
|
98
|
+
<<~CONTENT
|
99
|
+
#{dumpable_data.to_yaml.chomp}
|
100
|
+
---
|
101
|
+
|
102
|
+
#{content.chomp}
|
103
|
+
CONTENT
|
104
|
+
end
|
71
105
|
end
|
72
106
|
end
|
73
107
|
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-write-and-commit-changes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEYDCCAsigAwIBAgIBATANBgkqhkiG9w0BAQsFADA7MQ4wDAYDVQQDDAVmYXVu
|
14
|
+
bzEVMBMGCgmSJomT8ixkARkWBXN1dHR5MRIwEAYKCZImiZPyLGQBGRYCbmwwHhcN
|
15
|
+
MjUwMTA3MTczMTQ1WhcNMjYwMTA3MTczMTQ1WjA7MQ4wDAYDVQQDDAVmYXVubzEV
|
16
|
+
MBMGCgmSJomT8ixkARkWBXN1dHR5MRIwEAYKCZImiZPyLGQBGRYCbmwwggGiMA0G
|
17
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDqrFZ8PCNQbaW1incHEZp/OZTIt7bZ
|
18
|
+
TMKmkVLeRDqsSBGWTGdZbzRS6idn0vUKlTTnclPPG7dXw1r+AiYVdwIdjx16SLV1
|
19
|
+
ipbT/ezdzchfBVQHqdvExszAlL689iUnM9r22KkAXSzidSWuySjA5BY+8p1S2QO5
|
20
|
+
NcuB/+R5JRybVn6g500EB60jAZNUMM+2OlDqzS7oVqObOZ8zl8/HJaJnBGNNYLbN
|
21
|
+
cUY6qV9/0HUD2fS/eidBUGhg4jPKWHLHOZuXHPmGyE8bqdKC9T+Jbk/8KFM+SW7B
|
22
|
+
i4nZK4afoA6IT3KfQr5xnuyH0sUQj9M9eevWcG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00:00.000000000 Z
|
12
39
|
dependencies:
|
13
40
|
- !ruby/object:Gem::Dependency
|
14
41
|
name: jekyll
|
@@ -84,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
111
|
- !ruby/object:Gem::Version
|
85
112
|
version: '0'
|
86
113
|
requirements: []
|
87
|
-
rubygems_version: 3.3.
|
114
|
+
rubygems_version: 3.3.27
|
88
115
|
signing_key:
|
89
116
|
specification_version: 4
|
90
117
|
summary: Write changes to the repository
|
metadata.gz.sig
ADDED
Binary file
|