jekyll-scholar 7.1.3 → 7.2.1
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/.github/workflows/ci.yml +2 -6
- data/Gemfile +3 -13
- data/features/cache.feature +89 -0
- data/features/step_definitions/jekyll_steps.rb +9 -0
- data/features/step_definitions/scholar_steps.rb +27 -0
- data/jekyll-scholar.gemspec +3 -2
- data/lib/jekyll/scholar/utilities.rb +35 -23
- data/lib/jekyll/scholar/version.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22062feb1139b1e2221ba006d0d346047698487b0639fea5c9a9e01b710f01b4
|
4
|
+
data.tar.gz: c984c667598bc4b5a4d795f880736ad373ebdd5607198318b137fb7faee2a2f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c4cdaa40fa01076ec52b983324e22f630bb2c7a421f81878cb7d358933fb0a6b9a8535c46d796a641907a3c830ee894bdac7b48305597f9638f734827fffbf4
|
7
|
+
data.tar.gz: 83e6086ef4309c257290b527ece5c0d5752d9fbfca4ec5e4755f66564f7b4507fc952df06d760b0d2f28e9097b6519a0506a404ebc946bbc3ceabefbc2b30595
|
data/.github/workflows/ci.yml
CHANGED
@@ -4,9 +4,6 @@ on:
|
|
4
4
|
branches: [ main ]
|
5
5
|
pull_request:
|
6
6
|
branches: [ main ]
|
7
|
-
concurrency:
|
8
|
-
group: ci-${{ github.ref }}
|
9
|
-
cancel-in-progress: true
|
10
7
|
jobs:
|
11
8
|
ci:
|
12
9
|
name: ${{ matrix.ruby-version }} ${{ matrix.friendlyName }}-${{ matrix.arch }}
|
@@ -15,11 +12,10 @@ jobs:
|
|
15
12
|
strategy:
|
16
13
|
matrix:
|
17
14
|
ruby-version:
|
18
|
-
- "2.6"
|
19
|
-
- "2.7"
|
20
|
-
- "3.0"
|
21
15
|
- "3.1"
|
22
16
|
- "3.2"
|
17
|
+
- "3.3"
|
18
|
+
- "3.4"
|
23
19
|
os:
|
24
20
|
- ubuntu-latest
|
25
21
|
- macos-latest
|
data/Gemfile
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gem 'redcarpet'
|
8
|
-
gem 'redgreen'
|
9
|
-
gem 'shoulda'
|
10
|
-
gem 'test-unit'
|
11
|
-
gem 'unicode_utils' if RUBY_VERSION < '2.4'
|
12
|
-
end
|
13
|
-
|
14
|
-
group :extra do
|
15
|
-
gem 'listen'
|
16
|
-
end
|
4
|
+
gem 'cucumber'
|
5
|
+
gem 'minitest'
|
6
|
+
gem 'rake'
|
17
7
|
|
18
8
|
group :coverage do
|
19
9
|
gem 'simplecov', :require => false
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: BibTex
|
2
|
+
As as scholar who likes to blog and has limited time
|
3
|
+
I want to render my bibliography quickly
|
4
|
+
by caching the bibliography entries
|
5
|
+
|
6
|
+
Scenario: Normal usage
|
7
|
+
Given I have a scholar configuration with:
|
8
|
+
| key | value |
|
9
|
+
| source | ./_bibliography |
|
10
|
+
And I have a "_bibliography" directory
|
11
|
+
And I have a file "_bibliography/references.bib":
|
12
|
+
"""
|
13
|
+
@book{ruby,
|
14
|
+
title = {The Ruby Programming Language},
|
15
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
16
|
+
year = {2008},
|
17
|
+
publisher = {O'Reilly Media}
|
18
|
+
}
|
19
|
+
"""
|
20
|
+
And I have a page "scholar.html":
|
21
|
+
"""
|
22
|
+
---
|
23
|
+
---
|
24
|
+
{% cite ruby %}
|
25
|
+
{% bibliography -f references %}
|
26
|
+
"""
|
27
|
+
And I clear the jekyll caches
|
28
|
+
When I run jekyll
|
29
|
+
Then I should have 1 bibliography cache entry
|
30
|
+
And I should have 1 cite cache entry
|
31
|
+
And I should have a cite cache entry for ruby
|
32
|
+
|
33
|
+
Scenario: Changed file
|
34
|
+
Given I have a scholar configuration with:
|
35
|
+
| key | value |
|
36
|
+
| source | ./_bibliography |
|
37
|
+
And I have a "_bibliography" directory
|
38
|
+
And I have a file "_bibliography/references.bib":
|
39
|
+
"""
|
40
|
+
@book{ruby,
|
41
|
+
title = {The Ruby Programming Language},
|
42
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
43
|
+
year = {2008},
|
44
|
+
publisher = {O'Reilly Media}
|
45
|
+
}
|
46
|
+
"""
|
47
|
+
And I have a page "scholar.html":
|
48
|
+
"""
|
49
|
+
---
|
50
|
+
---
|
51
|
+
{% cite ruby %}
|
52
|
+
{% bibliography -f references %}
|
53
|
+
"""
|
54
|
+
And I clear the jekyll caches
|
55
|
+
When I run jekyll
|
56
|
+
Then I should have 1 bibliography cache entry
|
57
|
+
And I should have 1 cite cache entry
|
58
|
+
And I should have a cite cache entry for ruby
|
59
|
+
And I should see "Ruby" in "_site/scholar.html"
|
60
|
+
When I have a file "_bibliography/references.bib":
|
61
|
+
"""
|
62
|
+
@book{ruby,
|
63
|
+
title = {The Scooby Programming Language},
|
64
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
65
|
+
year = {2008},
|
66
|
+
publisher = {O'Reilly Media}
|
67
|
+
}
|
68
|
+
@book{newbie,
|
69
|
+
title = {The Newbie Programming Language},
|
70
|
+
author = {Programmer, Tennex},
|
71
|
+
year = {2009},
|
72
|
+
publisher = {O'Reilly Media}
|
73
|
+
}
|
74
|
+
"""
|
75
|
+
And I have a page "scholar.html":
|
76
|
+
"""
|
77
|
+
---
|
78
|
+
---
|
79
|
+
{% cite ruby %}
|
80
|
+
{% cite newbie %}
|
81
|
+
{% bibliography -f references %}
|
82
|
+
"""
|
83
|
+
And I run jekyll
|
84
|
+
Then I should have 2 bibliography cache entries
|
85
|
+
And I should have 2 cite cache entries
|
86
|
+
And I should have a cite cache entry for ruby
|
87
|
+
And I should have a cite cache entry for newbie
|
88
|
+
And I should see "Scooby" in "_site/scholar.html"
|
89
|
+
And I should see "Newbie" in "_site/scholar.html"
|
@@ -35,6 +35,15 @@ Given(/^I have a configuration file with:$/) do |table|
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
Given(/^I clear the jekyll caches$/) do
|
39
|
+
begin
|
40
|
+
Jekyll::Scholar::Utilities.class_variable_get(:@@bib_cache).clear
|
41
|
+
Jekyll::Scholar::Utilities.class_variable_get(:@@cite_cache).clear
|
42
|
+
rescue NameError
|
43
|
+
# Ignored
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
38
47
|
When(/^I run jekyll$/) do
|
39
48
|
run_jekyll
|
40
49
|
end
|
@@ -54,3 +54,30 @@ Then(/^"(.*)" should come before "(.*)" in "(.*)"$/) do |p1, p2, file|
|
|
54
54
|
assert m1.offset(0)[0] < m2.offset(0)[0]
|
55
55
|
end
|
56
56
|
|
57
|
+
Then(/^I should have a (bibliography|cite) cache entry for (.*)$/) do |cache_type, key|
|
58
|
+
require "digest"
|
59
|
+
case cache_type
|
60
|
+
when "bibliography"
|
61
|
+
raise NotImplementedError "Can't load temporary files for some reason"
|
62
|
+
# paths = key.split(", ")
|
63
|
+
# bib_mtimes = paths.reduce('') { |s, p| s << File.mtime(p).inspect }
|
64
|
+
# bib_hash = Digest::SHA256.hexdigest bib_mtimes
|
65
|
+
# assert Jekyll::Scholar::Utilities.bib_cache.key?(bib_hash)
|
66
|
+
when "cite"
|
67
|
+
assert Jekyll::Scholar::Utilities.class_variable_get(:@@cite_cache).key?(key)
|
68
|
+
else
|
69
|
+
raise "Unknown cache type"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
Then(/^I should have (\d*) (bibliography|cite) cache entr(?:ies|y)$/) do |n_entries, cache_type|
|
74
|
+
case cache_type
|
75
|
+
when "bibliography"
|
76
|
+
assert Jekyll::Scholar::Utilities.class_variable_get(:@@bib_cache).instance_variable_get(:@cache).length == n_entries.to_i
|
77
|
+
when "cite"
|
78
|
+
assert Jekyll::Scholar::Utilities.class_variable_get(:@@cite_cache).instance_variable_get(:@cache).length == n_entries.to_i
|
79
|
+
else
|
80
|
+
raise "Unknown cache type"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
data/jekyll-scholar.gemspec
CHANGED
@@ -23,10 +23,11 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.date = Time.now
|
24
24
|
|
25
25
|
s.required_rubygems_version = '>= 1.3.6'
|
26
|
+
s.required_ruby_version = '>= 3.0'
|
26
27
|
|
27
28
|
s.add_runtime_dependency('jekyll', '~> 4.0')
|
28
|
-
s.add_runtime_dependency('citeproc-ruby', '~>
|
29
|
-
s.add_runtime_dependency('csl-styles', '~>
|
29
|
+
s.add_runtime_dependency('citeproc-ruby', '~> 2.0')
|
30
|
+
s.add_runtime_dependency('csl-styles', '~> 2.0')
|
30
31
|
s.add_runtime_dependency('bibtex-ruby', '~> 6.0')
|
31
32
|
|
32
33
|
s.files = `git ls-files`.split("\n")
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Jekyll
|
2
2
|
class Scholar
|
3
3
|
require 'date'
|
4
|
+
require 'digest'
|
4
5
|
|
5
6
|
# Load styles into static memory.
|
6
7
|
# They should be thread safe as long as they are
|
@@ -47,7 +48,7 @@ module Jekyll
|
|
47
48
|
|
48
49
|
opts.on('-r', '--remove_duplicates [MATCH_FIELDS]') do |match_field|
|
49
50
|
@remove_duplicates = true
|
50
|
-
@match_fields = match_field.split(/,\s+/) if not match_field.nil?
|
51
|
+
@match_fields = match_field.split(/,\s+/) if not match_field.nil?
|
51
52
|
end
|
52
53
|
|
53
54
|
opts.on('-A', '--suppress_author') do |cited|
|
@@ -181,33 +182,37 @@ module Jekyll
|
|
181
182
|
bibtex_paths[0]
|
182
183
|
end
|
183
184
|
|
185
|
+
def bib_cache
|
186
|
+
@@bib_cache ||= Jekyll::Cache.new("jekyll-scholar::BibCache")
|
187
|
+
end
|
188
|
+
|
189
|
+
def cite_cache
|
190
|
+
@@cite_cache ||= Jekyll::Cache.new("jekyll-scholar::CiteCache")
|
191
|
+
end
|
192
|
+
|
184
193
|
def bibliography
|
185
194
|
paths = bibtex_paths
|
195
|
+
bib_mtimes = paths.reduce('') { |s, p| s << p << File.mtime(p).inspect }
|
196
|
+
bib_hash = Digest::SHA256.hexdigest bib_mtimes
|
186
197
|
|
187
|
-
|
188
|
-
|
189
|
-
@bibliography = nil
|
190
|
-
end
|
191
|
-
|
192
|
-
unless @bibliography
|
193
|
-
@bibliography = BibTeX::Bibliography.parse(
|
198
|
+
bib_cache.getset(bib_hash) do
|
199
|
+
bib = BibTeX::Bibliography.parse(
|
194
200
|
paths.reduce('') { |s, p| s << IO.read(p) },
|
195
201
|
bibtex_options
|
196
202
|
)
|
197
203
|
|
204
|
+
# clear cite caches on bibliography update
|
205
|
+
cite_cache.clear
|
206
|
+
|
198
207
|
@paths = paths
|
199
208
|
|
200
|
-
|
201
|
-
|
209
|
+
bib.replace_strings if replace_strings?
|
210
|
+
bib.join if join_strings? && replace_strings?
|
202
211
|
|
203
212
|
# Remove duplicate entries
|
204
|
-
|
213
|
+
bib.uniq!(*match_fields) if remove_duplicates?
|
214
|
+
bib
|
205
215
|
end
|
206
|
-
|
207
|
-
@bibliography
|
208
|
-
end
|
209
|
-
|
210
|
-
def bibliography_stale?
|
211
216
|
end
|
212
217
|
|
213
218
|
|
@@ -338,12 +343,17 @@ module Jekyll
|
|
338
343
|
case key
|
339
344
|
when 'type'
|
340
345
|
type_aliases[item.type.to_s] || item.type.to_s
|
346
|
+
when 'year', 'date'
|
347
|
+
value = item[key]
|
348
|
+
if value.date?
|
349
|
+
value.to_date
|
350
|
+
else
|
351
|
+
value.to_s
|
352
|
+
end
|
341
353
|
else
|
342
354
|
value = item[key]
|
343
355
|
if value.numeric?
|
344
356
|
value.to_i
|
345
|
-
elsif value.date?
|
346
|
-
value.to_date
|
347
357
|
else
|
348
358
|
value.to_s
|
349
359
|
end
|
@@ -389,7 +399,7 @@ module Jekyll
|
|
389
399
|
|
390
400
|
def remove_duplicates?
|
391
401
|
@remove_duplicates || config['remove_duplicates']
|
392
|
-
end
|
402
|
+
end
|
393
403
|
|
394
404
|
def suppress_author?
|
395
405
|
!!@suppress_author
|
@@ -597,7 +607,7 @@ module Jekyll
|
|
597
607
|
return false
|
598
608
|
end
|
599
609
|
return true
|
600
|
-
end
|
610
|
+
end
|
601
611
|
#
|
602
612
|
def generate_details?
|
603
613
|
site.layouts.key?(File.basename(config['details_layout'], '.html'))
|
@@ -631,9 +641,9 @@ module Jekyll
|
|
631
641
|
|
632
642
|
# First generate placeholders for all items in the bibtex entry
|
633
643
|
url_placeholders = {}
|
634
|
-
entry.fields.each_pair do |k, v|
|
644
|
+
entry.fields.each_pair do |k, v|
|
635
645
|
value = v.to_s.dup
|
636
|
-
value = Jekyll::Utils::slugify(value, :mode => 'pretty') unless k == :doi
|
646
|
+
value = Jekyll::Utils::slugify(value, :mode => 'pretty') unless k == :doi || value.empty?
|
637
647
|
url_placeholders[k] = value
|
638
648
|
end
|
639
649
|
# Maintain the same URLs are previous versions of jekyll-scholar
|
@@ -731,7 +741,9 @@ module Jekyll
|
|
731
741
|
items = keys.map do |key|
|
732
742
|
if bibliography.key?(key)
|
733
743
|
entry = bibliography[key]
|
734
|
-
|
744
|
+
cite_cache.getset(key) do
|
745
|
+
entry.convert(*bibtex_filters) unless bibtex_filters.empty?
|
746
|
+
end
|
735
747
|
else
|
736
748
|
return missing_reference
|
737
749
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-scholar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1
|
4
|
+
version: 7.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-09-01 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: jekyll
|
@@ -30,28 +29,28 @@ dependencies:
|
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '2.0'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '2.0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: csl-styles
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '2.0'
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '2.0'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: bibtex-ruby
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +86,7 @@ files:
|
|
87
86
|
- features/191.feature
|
88
87
|
- features/215.feature
|
89
88
|
- features/bibtex.feature
|
89
|
+
- features/cache.feature
|
90
90
|
- features/citation.feature
|
91
91
|
- features/cite_details.feature
|
92
92
|
- features/cited_only.feature
|
@@ -136,7 +136,6 @@ homepage: http://github.com/inukshuk/jekyll-scholar
|
|
136
136
|
licenses:
|
137
137
|
- MIT
|
138
138
|
metadata: {}
|
139
|
-
post_install_message:
|
140
139
|
rdoc_options: []
|
141
140
|
require_paths:
|
142
141
|
- lib
|
@@ -144,15 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
143
|
requirements:
|
145
144
|
- - ">="
|
146
145
|
- !ruby/object:Gem::Version
|
147
|
-
version: '0'
|
146
|
+
version: '3.0'
|
148
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
148
|
requirements:
|
150
149
|
- - ">="
|
151
150
|
- !ruby/object:Gem::Version
|
152
151
|
version: 1.3.6
|
153
152
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
153
|
+
rubygems_version: 3.7.0
|
156
154
|
specification_version: 4
|
157
155
|
summary: Jekyll extensions for the academic blogger.
|
158
156
|
test_files:
|
@@ -160,6 +158,7 @@ test_files:
|
|
160
158
|
- features/191.feature
|
161
159
|
- features/215.feature
|
162
160
|
- features/bibtex.feature
|
161
|
+
- features/cache.feature
|
163
162
|
- features/citation.feature
|
164
163
|
- features/cite_details.feature
|
165
164
|
- features/cited_only.feature
|