jekyll-scholar 7.1.3 → 7.2.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
- 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 +2 -2
- data/lib/jekyll/scholar/utilities.rb +27 -20
- data/lib/jekyll/scholar/version.rb +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a514c66d1cbe097d3d8837a024e5957ef136a03b54823915e6de74d4b7d395d
|
4
|
+
data.tar.gz: 49430b47d8eacc48bf7b34ffad39ad813bfcb223acbeb38ab9f95b4493381f29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7219d317f46e6c14e49a3a1a90c674022944511c5f71aab5688a8d22d3e50bade5d0b81660fe3a26157035ac3d1b5fa1726361c299bc7717753539e95b3cb4a
|
7
|
+
data.tar.gz: df23787617a54cd0275167ccc956482c086d9485db06fe6ce31e074711bbe7992b8182b4e7bf86ed665f839e010d4bd4aa1974a79a841637fdddc9e53d83275a
|
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
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.required_rubygems_version = '>= 1.3.6'
|
26
26
|
|
27
27
|
s.add_runtime_dependency('jekyll', '~> 4.0')
|
28
|
-
s.add_runtime_dependency('citeproc-ruby', '~>
|
29
|
-
s.add_runtime_dependency('csl-styles', '~>
|
28
|
+
s.add_runtime_dependency('citeproc-ruby', '~> 2.0')
|
29
|
+
s.add_runtime_dependency('csl-styles', '~> 2.0')
|
30
30
|
s.add_runtime_dependency('bibtex-ruby', '~> 6.0')
|
31
31
|
|
32
32
|
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
|
|
@@ -389,7 +394,7 @@ module Jekyll
|
|
389
394
|
|
390
395
|
def remove_duplicates?
|
391
396
|
@remove_duplicates || config['remove_duplicates']
|
392
|
-
end
|
397
|
+
end
|
393
398
|
|
394
399
|
def suppress_author?
|
395
400
|
!!@suppress_author
|
@@ -597,7 +602,7 @@ module Jekyll
|
|
597
602
|
return false
|
598
603
|
end
|
599
604
|
return true
|
600
|
-
end
|
605
|
+
end
|
601
606
|
#
|
602
607
|
def generate_details?
|
603
608
|
site.layouts.key?(File.basename(config['details_layout'], '.html'))
|
@@ -631,7 +636,7 @@ module Jekyll
|
|
631
636
|
|
632
637
|
# First generate placeholders for all items in the bibtex entry
|
633
638
|
url_placeholders = {}
|
634
|
-
entry.fields.each_pair do |k, v|
|
639
|
+
entry.fields.each_pair do |k, v|
|
635
640
|
value = v.to_s.dup
|
636
641
|
value = Jekyll::Utils::slugify(value, :mode => 'pretty') unless k == :doi
|
637
642
|
url_placeholders[k] = value
|
@@ -731,7 +736,9 @@ module Jekyll
|
|
731
736
|
items = keys.map do |key|
|
732
737
|
if bibliography.key?(key)
|
733
738
|
entry = bibliography[key]
|
734
|
-
|
739
|
+
cite_cache.getset(key) do
|
740
|
+
entry.convert(*bibtex_filters) unless bibtex_filters.empty?
|
741
|
+
end
|
735
742
|
else
|
736
743
|
return missing_reference
|
737
744
|
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.
|
4
|
+
version: 7.2.0
|
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-04-04 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
|
@@ -151,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
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.6.6
|
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
|