jekyll-scholar 1.0.0 → 1.1.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 +8 -8
- data/.travis.yml +12 -0
- data/Gemfile +15 -3
- data/README.md +44 -11
- data/Rakefile +23 -0
- data/cucumber.yml +1 -0
- data/features/bibtex.feature +164 -136
- data/features/citation.feature +98 -98
- data/features/cite_details.feature +48 -48
- data/features/details.feature +132 -67
- data/features/filter.feature +32 -32
- data/features/reference.feature +31 -2
- data/features/sorting.feature +57 -57
- data/features/support/env.rb +5 -1
- data/jekyll-scholar.gemspec +1 -11
- data/lib/jekyll/scholar/defaults.rb +23 -16
- data/lib/jekyll/scholar/generators/details.rb +3 -1
- data/lib/jekyll/scholar/tags/bibliography.rb +4 -4
- data/lib/jekyll/scholar/utilities.rb +37 -7
- data/lib/jekyll/scholar/version.rb +1 -1
- metadata +7 -130
data/features/filter.feature
CHANGED
@@ -4,36 +4,36 @@ Feature: BibTeX
|
|
4
4
|
In order to have control over the references that go up on my website
|
5
5
|
|
6
6
|
@tags @filters
|
7
|
-
|
7
|
+
Scenario: Filter by Year
|
8
8
|
Given I have a scholar configuration with:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
9
|
+
| key | value |
|
10
|
+
| source | ./_bibliography |
|
11
|
+
| query | "@*[year=2009]" |
|
12
|
+
And I have a "_bibliography" directory
|
13
|
+
And I have a file "_bibliography/references.bib":
|
14
|
+
"""
|
15
|
+
@book{ruby,
|
16
|
+
title = {The Ruby Programming Language},
|
17
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
18
|
+
year = {2008},
|
19
|
+
publisher = {O'Reilly Media}
|
20
|
+
}
|
21
|
+
@book{pickaxe,
|
22
|
+
title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
|
23
|
+
author = {Thomas, Dave and Fowler, Chad and Hunt, Andy},
|
24
|
+
year = {2009},
|
25
|
+
edition = 3,
|
26
|
+
publisher = {Pragmatic Bookshelf}
|
27
|
+
}
|
28
|
+
"""
|
29
|
+
And I have a page "scholar.html":
|
30
|
+
"""
|
31
|
+
---
|
32
|
+
---
|
33
|
+
{% bibliography %}
|
34
|
+
"""
|
35
|
+
When I run jekyll
|
36
|
+
Then the _site directory should exist
|
37
|
+
And the "_site/scholar.html" file should exist
|
38
|
+
And I should see "Programming Ruby" in "_site/scholar.html"
|
39
|
+
And I should not see "The Ruby Programming Language" in "_site/scholar.html"
|
data/features/reference.feature
CHANGED
@@ -29,7 +29,7 @@ Feature: Formatted References
|
|
29
29
|
And the "_site/scholar.html" file should exist
|
30
30
|
And I should see "Matsumoto, Y. \(2008\). <i>The Ruby" in "_site/scholar.html"
|
31
31
|
|
32
|
-
@tags @reference
|
32
|
+
@tags @reference @missing
|
33
33
|
Scenario: Missing references
|
34
34
|
Given I have a scholar configuration with:
|
35
35
|
| key | value |
|
@@ -54,4 +54,33 @@ Feature: Formatted References
|
|
54
54
|
When I run jekyll
|
55
55
|
Then the _site directory should exist
|
56
56
|
And the "_site/scholar.html" file should exist
|
57
|
-
And I should see "missing reference" in "_site/scholar.html"
|
57
|
+
And I should see "(missing reference)" in "_site/scholar.html"
|
58
|
+
|
59
|
+
@tags @reference @missing
|
60
|
+
Scenario: Missing references with a custom text
|
61
|
+
Given I have a scholar configuration with:
|
62
|
+
| key | value |
|
63
|
+
| source | ./_bibliography |
|
64
|
+
| bibliography | my_references |
|
65
|
+
| missing_reference | not found! |
|
66
|
+
And I have a "_bibliography" directory
|
67
|
+
And I have a file "_bibliography/my_references.bib":
|
68
|
+
"""
|
69
|
+
@book{ruby,
|
70
|
+
title = {The Ruby Programming Language},
|
71
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
72
|
+
year = {2008},
|
73
|
+
publisher = {O'Reilly Media}
|
74
|
+
}
|
75
|
+
"""
|
76
|
+
And I have a page "scholar.html":
|
77
|
+
"""
|
78
|
+
---
|
79
|
+
---
|
80
|
+
{% reference java %}
|
81
|
+
"""
|
82
|
+
When I run jekyll
|
83
|
+
Then the _site directory should exist
|
84
|
+
And the "_site/scholar.html" file should exist
|
85
|
+
And I should see "not found!" in "_site/scholar.html"
|
86
|
+
And I should not see "(missing reference)" in "_site/scholar.html"
|
data/features/sorting.feature
CHANGED
@@ -3,67 +3,67 @@ Feature: Sorting BibTeX Bibliographies
|
|
3
3
|
I want to sort my bibliographies according to configurable parameters
|
4
4
|
|
5
5
|
@tags @sorting
|
6
|
-
|
6
|
+
Scenario: Sort By Year
|
7
7
|
Given I have a scholar configuration with:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
8
|
+
| key | value |
|
9
|
+
| sort_by | year |
|
10
|
+
And I have a "_bibliography" directory
|
11
|
+
And I have a file "_bibliography/references.bib":
|
12
|
+
"""
|
13
|
+
@book{ruby1,
|
14
|
+
title = {The Ruby Programming Language},
|
15
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
16
|
+
year = {2008},
|
17
|
+
publisher = {O'Reilly Media}
|
18
|
+
}
|
19
|
+
@book{ruby2,
|
20
|
+
title = {The Ruby Programming Language},
|
21
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
22
|
+
year = {2007},
|
23
|
+
publisher = {O'Reilly Media}
|
24
|
+
}
|
25
|
+
"""
|
26
|
+
And I have a page "scholar.html":
|
27
|
+
"""
|
28
|
+
---
|
29
|
+
---
|
30
|
+
{% bibliography -f references %}
|
31
|
+
"""
|
32
|
+
When I run jekyll
|
33
|
+
Then the _site directory should exist
|
34
|
+
And the "_site/scholar.html" file should exist
|
35
35
|
Then "2007" should come before "2008" in "_site/scholar.html"
|
36
36
|
|
37
37
|
@tags @sorting
|
38
|
-
|
38
|
+
Scenario: Reverse Sort Order
|
39
39
|
Given I have a scholar configuration with:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
40
|
+
| key | value |
|
41
|
+
| sort_by | year |
|
42
|
+
| order | descending |
|
43
|
+
And I have a "_bibliography" directory
|
44
|
+
And I have a file "_bibliography/references.bib":
|
45
|
+
"""
|
46
|
+
@book{ruby1,
|
47
|
+
title = {The Ruby Programming Language},
|
48
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
49
|
+
year = {2008},
|
50
|
+
publisher = {O'Reilly Media}
|
51
|
+
}
|
52
|
+
@book{ruby2,
|
53
|
+
title = {The Ruby Programming Language},
|
54
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
55
|
+
year = {2007},
|
56
|
+
publisher = {O'Reilly Media}
|
57
|
+
}
|
58
|
+
"""
|
59
|
+
And I have a page "scholar.html":
|
60
|
+
"""
|
61
|
+
---
|
62
|
+
---
|
63
|
+
{% bibliography -f references %}
|
64
|
+
"""
|
65
|
+
When I run jekyll
|
66
|
+
Then the _site directory should exist
|
67
|
+
And the "_site/scholar.html" file should exist
|
68
68
|
Then "2008" should come before "2007" in "_site/scholar.html"
|
69
69
|
|
data/features/support/env.rb
CHANGED
data/jekyll-scholar.gemspec
CHANGED
@@ -26,17 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_runtime_dependency('jekyll', '~> 0.10')
|
28
28
|
s.add_runtime_dependency('citeproc-ruby', '~> 0.0.6')
|
29
|
-
s.add_runtime_dependency('bibtex-ruby', '~> 2.
|
30
|
-
|
31
|
-
s.add_development_dependency('rake', "~> 0.9")
|
32
|
-
s.add_development_dependency('rdoc', "~> 3.11")
|
33
|
-
s.add_development_dependency('redgreen', "~> 1.2")
|
34
|
-
s.add_development_dependency('shoulda', "~> 2.11")
|
35
|
-
s.add_development_dependency('rr', "~> 1.0")
|
36
|
-
s.add_development_dependency('cucumber', "1.1")
|
37
|
-
s.add_development_dependency('RedCloth', "~> 4.2")
|
38
|
-
s.add_development_dependency('rdiscount', "~> 1.6")
|
39
|
-
s.add_development_dependency('redcarpet', "~> 1.9")
|
29
|
+
s.add_runtime_dependency('bibtex-ruby', '~> 2.3')
|
40
30
|
|
41
31
|
s.files = `git ls-files`.split("\n")
|
42
32
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -1,26 +1,33 @@
|
|
1
1
|
module Jekyll
|
2
2
|
class Scholar
|
3
|
-
@defaults =
|
3
|
+
@defaults = {
|
4
|
+
'style' => 'apa',
|
5
|
+
'locale' => 'en',
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
'sort_by' => 'none',
|
8
|
+
'order' => 'ascending',
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
'source' => './_bibliography',
|
11
|
+
'bibliography' => 'references.bib',
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
'bibtex_options' => { :strip => false },
|
14
|
+
'bibtex_filters' => [ :latex ],
|
13
15
|
|
14
|
-
details_dir
|
15
|
-
details_layout bibtex.html
|
16
|
-
details_link
|
17
|
-
|
18
|
-
bibliography_class bibliography
|
19
|
-
details_link_class details
|
16
|
+
'details_dir' => 'bibliography',
|
17
|
+
'details_layout' => 'bibtex.html',
|
18
|
+
'details_link' => 'Details',
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
'bibliography_class' => 'bibliography',
|
21
|
+
'bibliography_template' => '%{reference}',
|
22
|
+
|
23
|
+
'reference_tagname' => 'span',
|
24
|
+
'missing_reference' => '(missing reference)',
|
25
|
+
|
26
|
+
'details_link_class' => 'details',
|
27
|
+
|
28
|
+
'query' => '@*'
|
29
|
+
|
30
|
+
}.freeze
|
24
31
|
|
25
32
|
class << self
|
26
33
|
attr_reader :defaults
|
@@ -25,11 +25,13 @@ module Jekyll
|
|
25
25
|
data['entry']['key'] = entry.key
|
26
26
|
data['entry']['type'] = entry.type
|
27
27
|
|
28
|
+
data['entry']['bibtex'] = entry.to_s
|
29
|
+
|
28
30
|
entry.fields.each do |key, value|
|
31
|
+
value = value.convert(*bibtex_filters) unless bibtex_filters.empty?
|
29
32
|
data['entry'][key.to_s] = value.to_s
|
30
33
|
end
|
31
34
|
|
32
|
-
data['entry']['bibtex'] = entry.to_s
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -23,8 +23,8 @@ module Jekyll
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
references.map
|
27
|
-
reference =
|
26
|
+
bibliography = references.map.with_index { |entry, index|
|
27
|
+
reference = bibliography_tag(entry, index + 1)
|
28
28
|
|
29
29
|
if generate_details?
|
30
30
|
reference << link_to(details_link_for(entry),
|
@@ -32,9 +32,9 @@ module Jekyll
|
|
32
32
|
end
|
33
33
|
|
34
34
|
content_tag :li, reference
|
35
|
-
|
35
|
+
}.join("\n")
|
36
36
|
|
37
|
-
content_tag :ol,
|
37
|
+
content_tag :ol, bibliography, :class => config['bibliography_class']
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -40,7 +40,11 @@ module Jekyll
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def bibtex_options
|
43
|
-
|
43
|
+
config['bibtex_options'] ||= {}
|
44
|
+
end
|
45
|
+
|
46
|
+
def bibtex_filters
|
47
|
+
config['bibtex_filters'] ||= []
|
44
48
|
end
|
45
49
|
|
46
50
|
def bibtex_path
|
@@ -80,12 +84,37 @@ module Jekyll
|
|
80
84
|
end
|
81
85
|
|
82
86
|
def reference_tag(entry)
|
83
|
-
return
|
87
|
+
return missing_reference unless entry
|
84
88
|
|
89
|
+
entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
|
85
90
|
reference = CiteProc.process entry.to_citeproc,
|
86
91
|
:style => config['style'], :locale => config['locale'], :format => 'html'
|
87
92
|
|
88
|
-
content_tag
|
93
|
+
content_tag reference_tagname, reference,
|
94
|
+
:id => [prefix, entry.key].compact.join('-')
|
95
|
+
end
|
96
|
+
|
97
|
+
def missing_reference
|
98
|
+
config['missing_reference']
|
99
|
+
end
|
100
|
+
|
101
|
+
def reference_tagname
|
102
|
+
config['reference_tagname'] || :span
|
103
|
+
end
|
104
|
+
|
105
|
+
def bibliography_template
|
106
|
+
config['bibliography_template'] || '%{reference}'
|
107
|
+
end
|
108
|
+
|
109
|
+
def bibliography_tag(entry, index)
|
110
|
+
return missing_reference unless entry
|
111
|
+
|
112
|
+
bibliography_template % {
|
113
|
+
:reference => reference_tag(entry),
|
114
|
+
:key => entry.key,
|
115
|
+
:type => entry.type,
|
116
|
+
:index => index
|
117
|
+
}
|
89
118
|
end
|
90
119
|
|
91
120
|
def generate_details?
|
@@ -113,18 +142,19 @@ module Jekyll
|
|
113
142
|
end
|
114
143
|
|
115
144
|
def cite(key)
|
116
|
-
entry = bibliography[key]
|
117
|
-
|
118
145
|
context['cited'] ||= []
|
119
146
|
context['cited'] << key
|
120
147
|
|
121
148
|
if bibliography.key?(key)
|
149
|
+
entry = bibliography[key]
|
150
|
+
entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
|
151
|
+
|
122
152
|
citation = CiteProc.process entry.to_citeproc, :style => config['style'],
|
123
153
|
:locale => config['locale'], :format => 'html', :mode => :citation
|
124
154
|
|
125
155
|
link_to "##{[prefix, entry.key].compact.join('-')}", citation.join
|
126
156
|
else
|
127
|
-
|
157
|
+
missing_reference
|
128
158
|
end
|
129
159
|
rescue
|
130
160
|
"(#{key})"
|
@@ -134,7 +164,7 @@ module Jekyll
|
|
134
164
|
if bibliography.key?(key)
|
135
165
|
link_to details_link_for(bibliography[key]), text || config['details_link']
|
136
166
|
else
|
137
|
-
|
167
|
+
missing_reference
|
138
168
|
end
|
139
169
|
end
|
140
170
|
|