jekyll-last-modified 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/jekyll-last-modified.gemspec +2 -2
- data/lib/jekyll/last_modified.rb +13 -10
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6675a8cd6e3bab30f372a3983c96b59efba23996d3b24c88971ccce9bb405f40
|
4
|
+
data.tar.gz: 7a5b74a9e269c183571edb4954ec94d728309d83bff62204897fd172024197a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89d347882ab0f7cb91d612cc84c9e9b09e9ef909a79d22064c756f7f1856070544ec299fa405c55f19ed1a58e85e4b4ff6485d893f3dc81c234b2d39d9f8e74
|
7
|
+
data.tar.gz: 384449699adb7057dec73749066ed18c9c0fdc47efe53c797eeed8180e53f538df0178c8c92636fb66ef95ce9c3301649cb07e9d158f84b0deef1cefb18a367d
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
# Jekyll::LastModified
|
2
2
|
|
3
3
|
This is a fork of [ivantsepp/jekyll-git_metadata](https://github.com/ivantsepp/jekyll-git_metadata), with the addition that it populates `page.date` (if unset) and `page.last_modified_at` from retrieved Git metadata.
|
4
|
+
|
5
|
+
Additionally, `subject` and `body` are available for commits, for retrieving the first line and the rest of the commit message separately.
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "jekyll-last-modified"
|
7
|
-
spec.version = '1.0.
|
7
|
+
spec.version = '1.0.4'
|
8
8
|
spec.authors = ["iBug"]
|
9
9
|
spec.email = ["i@ibugone.com"]
|
10
10
|
spec.summary = %q{Set page date from Git database}
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "jekyll", '>= 3.5'
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler", "
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.6"
|
23
23
|
spec.add_development_dependency "shoulda"
|
24
24
|
spec.add_development_dependency "mocha"
|
25
25
|
end
|
data/lib/jekyll/last_modified.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
|
|
3
3
|
module Jekyll
|
4
4
|
module LastModified
|
5
5
|
class Generator < Jekyll::Generator
|
6
|
-
VERSION = '1.0.
|
6
|
+
VERSION = '1.0.2'
|
7
7
|
|
8
8
|
safe true
|
9
9
|
|
@@ -11,7 +11,7 @@ module Jekyll
|
|
11
11
|
raise "Git is not installed" unless git_installed?
|
12
12
|
|
13
13
|
Dir.chdir(site.source) do
|
14
|
-
base_path = site.config['collections_dir']
|
14
|
+
base_path = site.config['collections_dir'] || ''
|
15
15
|
data = load_git_metadata(site)
|
16
16
|
site.config['git'] = data['site_data']
|
17
17
|
jekyll_items(site).each do |page|
|
@@ -19,11 +19,11 @@ module Jekyll
|
|
19
19
|
path = page.path
|
20
20
|
else
|
21
21
|
path = page.relative_path
|
22
|
-
path = File.join base_path, path
|
22
|
+
path = File.join base_path, path unless base_path.empty?
|
23
23
|
end
|
24
24
|
page.data['git'] = data['pages_data'][path]
|
25
25
|
unless page.data['git'].nil?
|
26
|
-
page.data['last_modified_at']
|
26
|
+
page.data['last_modified_at'] ||= page.data['git']['last_commit']['commit_date']
|
27
27
|
if page.data['date'] == site.time
|
28
28
|
page.data['date'] = page.data['git']['first_commit']['commit_date']
|
29
29
|
end
|
@@ -35,22 +35,22 @@ module Jekyll
|
|
35
35
|
def load_git_metadata(site)
|
36
36
|
current_sha = %x{ git rev-parse HEAD }.strip
|
37
37
|
|
38
|
-
cache_dir = site.source
|
38
|
+
cache_dir = File.join site.source, '.git-metadata'
|
39
39
|
FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir)
|
40
|
-
cache_file = cache_dir
|
40
|
+
cache_file = File.join cache_dir, "#{current_sha}.json"
|
41
41
|
|
42
42
|
if File.exist?(cache_file)
|
43
43
|
return JSON.parse(IO.read(cache_file))
|
44
44
|
end
|
45
45
|
|
46
|
-
base_path = site.config['collections_dir']
|
46
|
+
base_path = site.config['collections_dir'] || ''
|
47
47
|
pages_data = {}
|
48
48
|
jekyll_items(site).each do |page|
|
49
49
|
if page.is_a?(Jekyll::Page)
|
50
50
|
path = page.path
|
51
51
|
else
|
52
52
|
path = page.relative_path
|
53
|
-
path = File.join base_path, path
|
53
|
+
path = File.join base_path, path unless base_path.empty?
|
54
54
|
end
|
55
55
|
pages_data[path] = page_data(path)
|
56
56
|
end
|
@@ -112,7 +112,8 @@ module Jekyll
|
|
112
112
|
|
113
113
|
def commit(sha)
|
114
114
|
result = %x{ git show --format=fuller --name-only #{sha} }
|
115
|
-
long_sha, author_name, author_email, author_date, commit_name, commit_email, commit_date, message, changed_files = result.scan(/commit (.*)\nAuthor:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n((
|
115
|
+
long_sha, author_name, author_email, author_date, commit_name, commit_email, commit_date, message, changed_files = result.scan(/commit (.*)\nAuthor:(.*)<(.*)>\nAuthorDate:(.*)\nCommit:(.*)<(.*)>\nCommitDate:(.*)\n\n((?:^\s{4}[^\r\n]*\n)*)\n(.*)/m).first.map(&:strip)
|
116
|
+
message.gsub! /^\s{4}/, ''
|
116
117
|
{
|
117
118
|
'short_sha' => sha,
|
118
119
|
'long_sha' => long_sha,
|
@@ -122,7 +123,9 @@ module Jekyll
|
|
122
123
|
'commit_name' => commit_name,
|
123
124
|
'commit_email' => commit_email,
|
124
125
|
'commit_date' => commit_date,
|
125
|
-
'
|
126
|
+
'subject' => message.lines.first.strip,
|
127
|
+
'body' => message.lines[2..]&.join,
|
128
|
+
'message' => message,
|
126
129
|
'changed_files' => changed_files.split("\n")
|
127
130
|
}
|
128
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-last-modified
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iBug
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.3.5
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Set page date from Git database
|