jekyll-scholar 5.3.1 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -3
- data/features/grouping.feature +304 -0
- data/features/sorting.feature +37 -0
- data/lib/jekyll/scholar/defaults.rb +47 -24
- data/lib/jekyll/scholar/generators/details.rb +5 -0
- data/lib/jekyll/scholar/tags/bibliography.rb +39 -2
- data/lib/jekyll/scholar/utilities.rb +136 -6
- data/lib/jekyll/scholar/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d0ccfbfe88b7da749fa9664058817b55d0e6884
|
4
|
+
data.tar.gz: 3422aaf5888ddf64cea8247edc089d8421690c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a504af58d6a47edd86d1e69f105ce9d3b9b92099831f1890af42a0b3d7312efc8c403e1e51b8aa9b86177bbaaea7e19672084b3f5d4dc198955142e95defe7ad
|
7
|
+
data.tar.gz: 0333fe4d418b51ffa53a9c9fd5f1573fab4bffda85dea06e01206f5978f01179bdb6517d8f36b250446336d056db5ef645c5579fc8ab1b1cad3c7f53de46efef
|
data/README.md
CHANGED
@@ -24,6 +24,20 @@ Or add it to your `Gemfile`:
|
|
24
24
|
|
25
25
|
gem 'jekyll-scholar'
|
26
26
|
|
27
|
+
### Github Pages
|
28
|
+
|
29
|
+
Note that it is not possible to use this plugin with the
|
30
|
+
[default Github pages workflow](https://help.github.com/articles/using-jekyll-with-pages/).
|
31
|
+
Github does not allow any but a few select plugins to run for security reasons,
|
32
|
+
and Jekyll-Scholar is not among them.
|
33
|
+
You will have to generate your site locally and push the results to the `master` resp. `gh-pages`
|
34
|
+
branch of your site repository.
|
35
|
+
You can keep sources, configuration and plugins in a separate branch; see e.g.
|
36
|
+
[here](http://davidensinger.com/2013/07/automating-jekyll-deployment-to-github-pages-with-rake/)
|
37
|
+
for details.
|
38
|
+
|
39
|
+
|
40
|
+
|
27
41
|
Usage
|
28
42
|
-----
|
29
43
|
|
@@ -49,6 +63,9 @@ default configuration is as follows:
|
|
49
63
|
sort_by: none
|
50
64
|
order: ascending
|
51
65
|
|
66
|
+
group_by: none
|
67
|
+
group_order: ascending
|
68
|
+
|
52
69
|
source: ./_bibliography
|
53
70
|
bibliography: references.bib
|
54
71
|
bibliography_template: "{{reference}}"
|
@@ -66,8 +83,11 @@ default configuration is as follows:
|
|
66
83
|
|
67
84
|
You can use any style that ships with
|
68
85
|
[CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g.,
|
69
|
-
apa, mla, chicago-fullnote-bibliography)
|
70
|
-
|
86
|
+
apa, mla, chicago-fullnote-bibliography) which is usually the filename as seen
|
87
|
+
[here](https://github.com/citation-style-language/styles)
|
88
|
+
sans the `.csl` ending; note that you have to use `dependent/style` if you want
|
89
|
+
to use one from that directory.
|
90
|
+
Alternatively you can add a link to any CSL style (e.g., you could link to any of the styles available at
|
71
91
|
the official [CSL style repository](https://github.com/citation-style-language/styles)).
|
72
92
|
|
73
93
|
The `locale` settings defines what language to use when formatting
|
@@ -83,6 +103,33 @@ are embedded in the Bibtex fields. This option provides a way to circumvent
|
|
83
103
|
the problem that the double braces functionality of BibTex is accidentally
|
84
104
|
parsed by Liquid, while it was intended to keep the exact capitalization style.
|
85
105
|
|
106
|
+
The `sort_by` and `order` options specify if and how bibliography
|
107
|
+
entries are sorted. Entries can be sorted on multiple fields, by using
|
108
|
+
a list of keys, e.g. `sort_by: year,month`. Ordering can be specified
|
109
|
+
per sort level, e.g. `order: descending,ascending` will sort the years
|
110
|
+
descending, but per year the months are ascending. If there are more
|
111
|
+
sort keys than order directives, the last order entry is used for the
|
112
|
+
remaining keys.
|
113
|
+
|
114
|
+
The `group_by` and `group_order` options specify how bibliography
|
115
|
+
items are grouped. Grouping can be multi-level as well,
|
116
|
+
e.g. `group_by: type, year` groups entries per publication type, and
|
117
|
+
within those groups per year. Ordering for groups is specified in the
|
118
|
+
same way as the sort order. Publication types -- specified with group
|
119
|
+
key `type`, can be ordered by adding `type_order` to the
|
120
|
+
configuration. For example, `type_order: article,techreport` lists
|
121
|
+
journal articles before technical reports. Types not mentioned in
|
122
|
+
`type_order` are considered smaller than types that are
|
123
|
+
mentioned. Types can be merge in one group using the `type_aliases`
|
124
|
+
setting. By default `phdthesis` and `mastersthesis` are grouped as
|
125
|
+
`thesis`. By using, for example, `type_aliases: { inproceeding =>
|
126
|
+
article}`, journal and conference articles appear in a single
|
127
|
+
group. The display names for entry types are specified with
|
128
|
+
`type_names`. Names for common types are provided, but they can be
|
129
|
+
extended or overridden. For example, the default name for `article` is
|
130
|
+
*Journal Articles*, but it can be changed to *Papers* using
|
131
|
+
`type_name: { article => 'Papers' }`.
|
132
|
+
|
86
133
|
### Bibliographies
|
87
134
|
|
88
135
|
Once you have loaded Jekyll-Scholar, all files with the extension `.bib` or
|
@@ -170,7 +217,8 @@ use the `--max` option:
|
|
170
217
|
{% bibliography --max 5 %}
|
171
218
|
|
172
219
|
This would generate a bibliography containing only the first 5 entries
|
173
|
-
of your bibliography (after query filters and sort options have been
|
220
|
+
of your bibliography (after query filters and sort options have been
|
221
|
+
applied). Limiting entries is disabled if grouping is active.
|
174
222
|
|
175
223
|
### Bibliography Template
|
176
224
|
|
@@ -0,0 +1,304 @@
|
|
1
|
+
Feature: Grouping BibTeX Bibliographies
|
2
|
+
As a scholar who likes to blog
|
3
|
+
I want to group my bibliographies according to configurable parameters
|
4
|
+
|
5
|
+
@tags @grouping
|
6
|
+
Scenario: Group By Year
|
7
|
+
Given I have a scholar configuration with:
|
8
|
+
| key | value |
|
9
|
+
| group_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
|
+
Then I should see "<h2 class=\"bibliography\">2007</h2>" in "_site/scholar.html"
|
36
|
+
And I should see "<h2 class=\"bibliography\">2008</h2>" in "_site/scholar.html"
|
37
|
+
|
38
|
+
@tags @grouping
|
39
|
+
Scenario: Group Order
|
40
|
+
Given I have a scholar configuration with:
|
41
|
+
| key | value |
|
42
|
+
| group_by | year |
|
43
|
+
| group_order | ascending |
|
44
|
+
And I have a "_bibliography" directory
|
45
|
+
And I have a file "_bibliography/references.bib":
|
46
|
+
"""
|
47
|
+
@book{ruby1,
|
48
|
+
title = {The Ruby Programming Language},
|
49
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
50
|
+
year = {2008},
|
51
|
+
publisher = {O'Reilly Media}
|
52
|
+
}
|
53
|
+
@book{ruby2,
|
54
|
+
title = {The Ruby Programming Language},
|
55
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
56
|
+
year = {2007},
|
57
|
+
publisher = {O'Reilly Media}
|
58
|
+
}
|
59
|
+
"""
|
60
|
+
And I have a page "scholar.html":
|
61
|
+
"""
|
62
|
+
---
|
63
|
+
---
|
64
|
+
{% bibliography -f references %}
|
65
|
+
"""
|
66
|
+
When I run jekyll
|
67
|
+
Then the _site directory should exist
|
68
|
+
And the "_site/scholar.html" file should exist
|
69
|
+
Then "<h2 class=\"bibliography\">2007</h2>" should come before "<h2 class=\"bibliography\">2008</h2>" in "_site/scholar.html"
|
70
|
+
|
71
|
+
@tags @grouping
|
72
|
+
Scenario: Reverse Group Order
|
73
|
+
Given I have a scholar configuration with:
|
74
|
+
| key | value |
|
75
|
+
| group_by | year |
|
76
|
+
| group_order | descending |
|
77
|
+
And I have a "_bibliography" directory
|
78
|
+
And I have a file "_bibliography/references.bib":
|
79
|
+
"""
|
80
|
+
@book{ruby1,
|
81
|
+
title = {The Ruby Programming Language},
|
82
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
83
|
+
year = {2008},
|
84
|
+
publisher = {O'Reilly Media}
|
85
|
+
}
|
86
|
+
@book{ruby2,
|
87
|
+
title = {The Ruby Programming Language},
|
88
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
89
|
+
year = {2007},
|
90
|
+
publisher = {O'Reilly Media}
|
91
|
+
}
|
92
|
+
"""
|
93
|
+
And I have a page "scholar.html":
|
94
|
+
"""
|
95
|
+
---
|
96
|
+
---
|
97
|
+
{% bibliography -f references %}
|
98
|
+
"""
|
99
|
+
When I run jekyll
|
100
|
+
Then the _site directory should exist
|
101
|
+
And the "_site/scholar.html" file should exist
|
102
|
+
Then "<h2 class=\"bibliography\">2008</h2>" should come before "<h2 class=\"bibliography\">2007</h2>" in "_site/scholar.html"
|
103
|
+
|
104
|
+
@tags @grouping
|
105
|
+
Scenario: Multi-level Group Order
|
106
|
+
Given I have a scholar configuration with:
|
107
|
+
| key | value |
|
108
|
+
| group_by | year,month |
|
109
|
+
| group_order | descending,ascending |
|
110
|
+
And I have a "_bibliography" directory
|
111
|
+
And I have a file "_bibliography/references.bib":
|
112
|
+
"""
|
113
|
+
@book{ruby1,
|
114
|
+
title = {November 08},
|
115
|
+
year = {2008},
|
116
|
+
month = {nov}
|
117
|
+
}
|
118
|
+
@book{ruby2,
|
119
|
+
title = {March 08},
|
120
|
+
year = {2008},
|
121
|
+
month = {mar}
|
122
|
+
}
|
123
|
+
@book{ruby3,
|
124
|
+
title = {June 07},
|
125
|
+
year = {2007},
|
126
|
+
month = {jun}
|
127
|
+
}
|
128
|
+
"""
|
129
|
+
And I have a page "scholar.html":
|
130
|
+
"""
|
131
|
+
---
|
132
|
+
---
|
133
|
+
{% bibliography -f references %}
|
134
|
+
"""
|
135
|
+
When I run jekyll
|
136
|
+
Then the _site directory should exist
|
137
|
+
And the "_site/scholar.html" file should exist
|
138
|
+
Then "March" should come before "November" in "_site/scholar.html"
|
139
|
+
And "November" should come before "June" in "_site/scholar.html"
|
140
|
+
|
141
|
+
@tags @grouping
|
142
|
+
Scenario: Group by Type
|
143
|
+
Given I have a scholar configuration with:
|
144
|
+
| key | value |
|
145
|
+
| group_by | type |
|
146
|
+
And I have a "_bibliography" directory
|
147
|
+
And I have a file "_bibliography/references.bib":
|
148
|
+
"""
|
149
|
+
@book{ruby1,
|
150
|
+
title = {Book 1},
|
151
|
+
}
|
152
|
+
@article{ruby2,
|
153
|
+
title = {Article 1},
|
154
|
+
}
|
155
|
+
@book{ruby3,
|
156
|
+
title = {Book 2},
|
157
|
+
}
|
158
|
+
@article{ruby4,
|
159
|
+
title = {Article 2},
|
160
|
+
}
|
161
|
+
"""
|
162
|
+
And I have a page "scholar.html":
|
163
|
+
"""
|
164
|
+
---
|
165
|
+
---
|
166
|
+
{% bibliography -f references %}
|
167
|
+
"""
|
168
|
+
When I run jekyll
|
169
|
+
Then the _site directory should exist
|
170
|
+
And the "_site/scholar.html" file should exist
|
171
|
+
Then "Journal Articles" should come before "Article 1" in "_site/scholar.html"
|
172
|
+
And "Journal Articles" should come before "Article 2" in "_site/scholar.html"
|
173
|
+
Then "Books" should come before "Book 1" in "_site/scholar.html"
|
174
|
+
And "Books" should come before "Book 2" in "_site/scholar.html"
|
175
|
+
|
176
|
+
@tags @grouping
|
177
|
+
Scenario: Type Order
|
178
|
+
Given I have a scholar configuration with:
|
179
|
+
| key | value |
|
180
|
+
| group_by | type |
|
181
|
+
| type_order | [article,book] |
|
182
|
+
And I have a "_bibliography" directory
|
183
|
+
And I have a file "_bibliography/references.bib":
|
184
|
+
"""
|
185
|
+
@book{ruby1,
|
186
|
+
title = {Book 1},
|
187
|
+
}
|
188
|
+
@article{ruby2,
|
189
|
+
title = {Article 1},
|
190
|
+
}
|
191
|
+
@book{ruby3,
|
192
|
+
title = {Book 2},
|
193
|
+
}
|
194
|
+
@techreport{ruby4,
|
195
|
+
title = {Book 2},
|
196
|
+
}
|
197
|
+
@article{ruby5,
|
198
|
+
title = {Article 2},
|
199
|
+
}
|
200
|
+
"""
|
201
|
+
And I have a page "scholar.html":
|
202
|
+
"""
|
203
|
+
---
|
204
|
+
---
|
205
|
+
{% bibliography -f references %}
|
206
|
+
"""
|
207
|
+
When I run jekyll
|
208
|
+
Then the _site directory should exist
|
209
|
+
And the "_site/scholar.html" file should exist
|
210
|
+
Then "Journal Articles" should come before "Books" in "_site/scholar.html"
|
211
|
+
And "Books" should come before "Technical Reports" in "_site/scholar.html"
|
212
|
+
|
213
|
+
@tags @grouping
|
214
|
+
Scenario: Type Names
|
215
|
+
Given I have a scholar configuration with:
|
216
|
+
| key | value |
|
217
|
+
| group_by | type |
|
218
|
+
| type_names | { article: 'Long Papers' } |
|
219
|
+
And I have a "_bibliography" directory
|
220
|
+
And I have a file "_bibliography/references.bib":
|
221
|
+
"""
|
222
|
+
@article{ruby1,
|
223
|
+
title = {Article},
|
224
|
+
}
|
225
|
+
@book{ruby2,
|
226
|
+
title = {Book},
|
227
|
+
}
|
228
|
+
"""
|
229
|
+
And I have a page "scholar.html":
|
230
|
+
"""
|
231
|
+
---
|
232
|
+
---
|
233
|
+
{% bibliography -f references %}
|
234
|
+
"""
|
235
|
+
When I run jekyll
|
236
|
+
Then the _site directory should exist
|
237
|
+
And the "_site/scholar.html" file should exist
|
238
|
+
Then I should see "Long Papers" in "_site/scholar.html"
|
239
|
+
And I should not see "Journal Articles" in "_site/scholar.html"
|
240
|
+
And I should see "Books" in "_site/scholar.html"
|
241
|
+
|
242
|
+
@tags @grouping
|
243
|
+
Scenario: Type Aliases
|
244
|
+
Given I have a scholar configuration with:
|
245
|
+
| key | value |
|
246
|
+
| group_by | type |
|
247
|
+
| type_aliases | { phdthesis: phdthesis } |
|
248
|
+
And I have a "_bibliography" directory
|
249
|
+
And I have a file "_bibliography/references.bib":
|
250
|
+
"""
|
251
|
+
@mastersthesis{ruby1,
|
252
|
+
title = {MSc Thesis},
|
253
|
+
}
|
254
|
+
@phdthesis{ruby2,
|
255
|
+
title = {PhD Thesis},
|
256
|
+
}
|
257
|
+
"""
|
258
|
+
And I have a page "scholar.html":
|
259
|
+
"""
|
260
|
+
---
|
261
|
+
---
|
262
|
+
{% bibliography -f references %}
|
263
|
+
"""
|
264
|
+
When I run jekyll
|
265
|
+
Then the _site directory should exist
|
266
|
+
And the "_site/scholar.html" file should exist
|
267
|
+
Then I should see "PhD Theses" in "_site/scholar.html"
|
268
|
+
And I should not see "Master's Theses" in "_site/scholar.html"
|
269
|
+
|
270
|
+
@tags @grouping
|
271
|
+
Scenario: Month Names
|
272
|
+
Given I have a scholar configuration with:
|
273
|
+
| key | value |
|
274
|
+
| group_by | month |
|
275
|
+
| month_names | [Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember] |
|
276
|
+
And I have a "_bibliography" directory
|
277
|
+
And I have a file "_bibliography/references.bib":
|
278
|
+
"""
|
279
|
+
@book{ruby1,
|
280
|
+
title = {The Ruby Programming Language},
|
281
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
282
|
+
year = {2008},
|
283
|
+
month = jan
|
284
|
+
}
|
285
|
+
@book{ruby2,
|
286
|
+
title = {The Ruby Programming Language},
|
287
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
288
|
+
year = {2008},
|
289
|
+
month = dec
|
290
|
+
}
|
291
|
+
"""
|
292
|
+
And I have a page "scholar.html":
|
293
|
+
"""
|
294
|
+
---
|
295
|
+
---
|
296
|
+
{% bibliography -f references %}
|
297
|
+
"""
|
298
|
+
When I run jekyll
|
299
|
+
Then the _site directory should exist
|
300
|
+
And the "_site/scholar.html" file should exist
|
301
|
+
Then I should see "Januar" in "_site/scholar.html"
|
302
|
+
And I should not see "January" in "_site/scholar.html"
|
303
|
+
And I should see "Dezember" in "_site/scholar.html"
|
304
|
+
And I should not see "December" in "_site/scholar.html"
|
data/features/sorting.feature
CHANGED
@@ -262,3 +262,40 @@ Feature: Sorting BibTeX Bibliographies
|
|
262
262
|
And the "_site/scholar.html" file should exist
|
263
263
|
Then "August 07" should come before "March 08" in "_site/scholar.html"
|
264
264
|
And "March 08" should come before "December 08" in "_site/scholar.html"
|
265
|
+
|
266
|
+
@tags @sorting
|
267
|
+
Scenario: Multi-level Sort Order
|
268
|
+
Given I have a scholar configuration with:
|
269
|
+
| key | value |
|
270
|
+
| sort_by | year, month |
|
271
|
+
| order | descending, ascending |
|
272
|
+
And I have a "_bibliography" directory
|
273
|
+
And I have a file "_bibliography/references.bib":
|
274
|
+
"""
|
275
|
+
@book{ruby1,
|
276
|
+
title = {August 07},
|
277
|
+
year = {2007},
|
278
|
+
month = aug
|
279
|
+
}
|
280
|
+
@book{ruby2,
|
281
|
+
title = {March 08},
|
282
|
+
year = {2008},
|
283
|
+
month = mar
|
284
|
+
}
|
285
|
+
@book{ruby3,
|
286
|
+
title = {December 08},
|
287
|
+
year = {2008},
|
288
|
+
month = dec
|
289
|
+
}
|
290
|
+
"""
|
291
|
+
And I have a page "scholar.html":
|
292
|
+
"""
|
293
|
+
---
|
294
|
+
---
|
295
|
+
{% bibliography %}
|
296
|
+
"""
|
297
|
+
When I run jekyll
|
298
|
+
Then the _site directory should exist
|
299
|
+
And the "_site/scholar.html" file should exist
|
300
|
+
Then "March 08" should come before "December 08" in "_site/scholar.html"
|
301
|
+
And "December 08" should come before "August 07" in "_site/scholar.html"
|
@@ -1,40 +1,63 @@
|
|
1
1
|
module Jekyll
|
2
2
|
class Scholar
|
3
3
|
@defaults = {
|
4
|
-
'style'
|
5
|
-
'locale'
|
4
|
+
'style' => 'apa',
|
5
|
+
'locale' => 'en',
|
6
6
|
|
7
|
-
'sort_by'
|
8
|
-
'order'
|
9
|
-
'
|
10
|
-
'
|
7
|
+
'sort_by' => 'none',
|
8
|
+
'order' => 'ascending',
|
9
|
+
'group_by' => 'none',
|
10
|
+
'group_order' => 'ascending',
|
11
|
+
'bibliography_group_tag' => 'h2,h3,h4,h5',
|
12
|
+
'bibliography_list_tag' => 'ol',
|
13
|
+
'bibliography_item_tag' => 'li',
|
11
14
|
|
12
|
-
'source'
|
13
|
-
'bibliography'
|
14
|
-
'repository'
|
15
|
+
'source' => './_bibliography',
|
16
|
+
'bibliography' => 'references.bib',
|
17
|
+
'repository' => nil,
|
15
18
|
|
16
|
-
'bibtex_options'
|
17
|
-
'bibtex_filters'
|
18
|
-
'bibtex_skip_fields'
|
19
|
+
'bibtex_options' => { :strip => false, :parse_months => true },
|
20
|
+
'bibtex_filters' => [ :latex ],
|
21
|
+
'bibtex_skip_fields' => [ :abstract, :month_numeric ],
|
19
22
|
|
20
|
-
'replace_strings'
|
21
|
-
'join_strings'
|
23
|
+
'replace_strings' => true,
|
24
|
+
'join_strings' => true,
|
22
25
|
|
23
|
-
'details_dir'
|
24
|
-
'details_layout'
|
25
|
-
'details_link'
|
26
|
-
'use_raw_bibtex_entry'
|
26
|
+
'details_dir' => 'bibliography',
|
27
|
+
'details_layout' => 'bibtex.html',
|
28
|
+
'details_link' => 'Details',
|
29
|
+
'use_raw_bibtex_entry' => false,
|
27
30
|
|
28
|
-
'bibliography_class'
|
29
|
-
'bibliography_template'
|
31
|
+
'bibliography_class' => 'bibliography',
|
32
|
+
'bibliography_template' => '{{reference}}',
|
30
33
|
|
31
|
-
'reference_tagname'
|
32
|
-
'missing_reference'
|
34
|
+
'reference_tagname' => 'span',
|
35
|
+
'missing_reference' => '(missing reference)',
|
33
36
|
|
34
|
-
'details_link_class'
|
37
|
+
'details_link_class' => 'details',
|
35
38
|
|
36
|
-
'query'
|
39
|
+
'query' => '@*',
|
37
40
|
|
41
|
+
'type_names' => {
|
42
|
+
'article' => 'Journal Articles',
|
43
|
+
'book' => 'Books',
|
44
|
+
'incollection' => 'Book Chapters',
|
45
|
+
'inproceedings' => 'Conference Articles',
|
46
|
+
'thesis' => 'Theses',
|
47
|
+
'mastersthesis' => 'Master\'s Theses',
|
48
|
+
'phdthesis' => 'PhD Theses',
|
49
|
+
'manual' => 'Manuals',
|
50
|
+
'techreport' => 'Technical Reports',
|
51
|
+
'misc' => 'Miscellaneous',
|
52
|
+
'unpublished' => 'Unpublished',
|
53
|
+
},
|
54
|
+
'type_aliases' => {
|
55
|
+
'phdthesis' => 'thesis',
|
56
|
+
'mastersthesis' => 'thesis',
|
57
|
+
},
|
58
|
+
'type_order' => [],
|
59
|
+
|
60
|
+
'month_names' => nil,
|
38
61
|
}.freeze
|
39
62
|
|
40
63
|
class << self
|
@@ -42,8 +42,45 @@ module Jekyll
|
|
42
42
|
cited_keys.clear
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
if group?
|
46
|
+
groups = group(items)
|
47
|
+
bibliography = render_groups(groups)
|
48
|
+
else
|
49
|
+
items = items[offset..max] if limit_entries?
|
50
|
+
bibliography = render_items(items)
|
51
|
+
end
|
52
|
+
|
53
|
+
bibliography
|
54
|
+
end
|
46
55
|
|
56
|
+
def render_groups(groups)
|
57
|
+
def group_renderer(groupsOrItems,keys,order,tags)
|
58
|
+
if keys.count == 0
|
59
|
+
renderer(force = true)
|
60
|
+
render_items(groupsOrItems)
|
61
|
+
else
|
62
|
+
groupsOrItems
|
63
|
+
.sort do |e1,e2|
|
64
|
+
if (order.first || group_order.last) =~ /^(desc|reverse)/i
|
65
|
+
group_compare(keys.first,e2[0],e1[0])
|
66
|
+
else
|
67
|
+
group_compare(keys.first,e1[0],e2[0])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
.map do |e|
|
71
|
+
bibhead = content_tag(tags.first || group_tags.last,
|
72
|
+
group_name(keys.first, e[0]),
|
73
|
+
:class => config['bibliography_class'])
|
74
|
+
bibentries = group_renderer(e[1], keys.drop(1), order.drop(1), tags.drop(1))
|
75
|
+
bibhead + "\n" + bibentries
|
76
|
+
end
|
77
|
+
.join("\n")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
group_renderer(groups,group_keys,group_order,group_tags)
|
81
|
+
end
|
82
|
+
|
83
|
+
def render_items(items)
|
47
84
|
bibliography = items.each_with_index.map { |entry, index|
|
48
85
|
reference = bibliography_tag(entry, index + 1)
|
49
86
|
|
@@ -56,8 +93,8 @@ module Jekyll
|
|
56
93
|
}.join("\n")
|
57
94
|
|
58
95
|
content_tag config['bibliography_list_tag'], bibliography, :class => config['bibliography_class']
|
59
|
-
|
60
96
|
end
|
97
|
+
|
61
98
|
end
|
62
99
|
|
63
100
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Jekyll
|
2
2
|
class Scholar
|
3
|
+
require 'date'
|
3
4
|
|
4
5
|
# Load styles into static memory.
|
5
6
|
# They should be thread safe as long as they are
|
@@ -156,11 +157,20 @@ module Jekyll
|
|
156
157
|
def sort(unsorted)
|
157
158
|
return unsorted if skip_sort?
|
158
159
|
|
159
|
-
sorted = unsorted.
|
160
|
-
|
160
|
+
sorted = unsorted.sort do |e1, e2|
|
161
|
+
sort_keys
|
162
|
+
.map.with_index do |key, idx|
|
163
|
+
v1 = e1[key].nil? ? BibTeX::Value.new : e1[key]
|
164
|
+
v2 = e2[key].nil? ? BibTeX::Value.new : e2[key]
|
165
|
+
if (sort_order[idx] || sort_order.last) =~ /^(desc|reverse)/i
|
166
|
+
v2 <=> v1
|
167
|
+
else
|
168
|
+
v1 <=> v2
|
169
|
+
end
|
170
|
+
end
|
171
|
+
.find { |c| c != 0 } || 0
|
161
172
|
end
|
162
|
-
|
163
|
-
sorted.reverse! if config['order'] =~ /^(desc|reverse)/i
|
173
|
+
|
164
174
|
sorted
|
165
175
|
end
|
166
176
|
|
@@ -173,6 +183,124 @@ module Jekyll
|
|
173
183
|
.map { |key| key == 'month' ? 'month_numeric' : key }
|
174
184
|
end
|
175
185
|
|
186
|
+
def sort_order
|
187
|
+
return @sort_order unless @sort_order.nil?
|
188
|
+
|
189
|
+
@sort_order = Array(config['order'])
|
190
|
+
.map { |key| key.to_s.split(/\s*,\s*/) }
|
191
|
+
.flatten
|
192
|
+
end
|
193
|
+
|
194
|
+
def group?
|
195
|
+
config['group_by'] != 'none'
|
196
|
+
end
|
197
|
+
|
198
|
+
def group(ungrouped)
|
199
|
+
def grouper(items,keys,order)
|
200
|
+
groups = items
|
201
|
+
.group_by do |item|
|
202
|
+
group_value(keys.first,item)
|
203
|
+
end
|
204
|
+
if keys.count == 1
|
205
|
+
groups
|
206
|
+
else
|
207
|
+
groups.merge(groups) do |key,items|
|
208
|
+
grouper(items,keys.drop(1),order.drop(1))
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
grouper(ungrouped,group_keys,group_order)
|
213
|
+
end
|
214
|
+
|
215
|
+
def group_keys
|
216
|
+
return @group_keys unless @group_keys.nil?
|
217
|
+
|
218
|
+
@group_keys = Array(config['group_by'])
|
219
|
+
.map { |key| key.to_s.split(/\s*,\s*/) }
|
220
|
+
.flatten
|
221
|
+
.map { |key| key == 'month' ? 'month_numeric' : key }
|
222
|
+
end
|
223
|
+
|
224
|
+
def group_order
|
225
|
+
return @group_order unless @group_order.nil?
|
226
|
+
|
227
|
+
@group_order = Array(config['group_order'])
|
228
|
+
.map { |key| key.to_s.split(/\s*,\s*/) }
|
229
|
+
.flatten
|
230
|
+
end
|
231
|
+
|
232
|
+
def group_compare(key,v1,v2)
|
233
|
+
case key
|
234
|
+
when 'type'
|
235
|
+
o1 = type_order.find_index(v1)
|
236
|
+
o2 = type_order.find_index(v2)
|
237
|
+
if o1.nil? && o2.nil?
|
238
|
+
0
|
239
|
+
elsif o1.nil?
|
240
|
+
1
|
241
|
+
elsif o2.nil?
|
242
|
+
-1
|
243
|
+
else
|
244
|
+
o1 <=> o2
|
245
|
+
end
|
246
|
+
else
|
247
|
+
v1 <=> v2
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def group_value(key,item)
|
252
|
+
case key
|
253
|
+
when 'type'
|
254
|
+
type_aliases[item.type.to_s] || item.type.to_s
|
255
|
+
else
|
256
|
+
value = item[key]
|
257
|
+
if value.numeric?
|
258
|
+
value.to_i
|
259
|
+
elsif value.date?
|
260
|
+
value.to_date
|
261
|
+
else
|
262
|
+
value.to_s
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def group_tags
|
268
|
+
return @group_tags unless @group_tags.nil?
|
269
|
+
|
270
|
+
@group_tags = Array(config['bibliography_group_tag'])
|
271
|
+
.map { |key| key.to_s.split(/\s*,\s*/) }
|
272
|
+
.flatten
|
273
|
+
end
|
274
|
+
|
275
|
+
def group_name(key,value)
|
276
|
+
case key
|
277
|
+
when 'type'
|
278
|
+
type_names[value] || value.to_s
|
279
|
+
when 'month_numeric'
|
280
|
+
month_names[value] || "(unknown)"
|
281
|
+
else
|
282
|
+
value.to_s
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def type_order
|
287
|
+
@type_order ||= config['type_order']
|
288
|
+
end
|
289
|
+
|
290
|
+
def type_aliases
|
291
|
+
@type_aliases ||= Scholar.defaults['type_aliases'].merge(config['type_aliases'])
|
292
|
+
end
|
293
|
+
|
294
|
+
def type_names
|
295
|
+
@type_names ||= Scholar.defaults['type_names'].merge(config['type_names'])
|
296
|
+
end
|
297
|
+
|
298
|
+
def month_names
|
299
|
+
return @month_names unless @month_names.nil?
|
300
|
+
|
301
|
+
@month_names = config['month_names'].nil? ? Date::MONTHNAMES : config['month_names'].unshift(nil)
|
302
|
+
end
|
303
|
+
|
176
304
|
def suppress_author?
|
177
305
|
!!@suppress_author
|
178
306
|
end
|
@@ -399,8 +527,10 @@ module Jekyll
|
|
399
527
|
config['details_dir']
|
400
528
|
end
|
401
529
|
|
402
|
-
def renderer
|
403
|
-
@renderer
|
530
|
+
def renderer(force = false)
|
531
|
+
return @renderer if @renderer && !force
|
532
|
+
|
533
|
+
@renderer = CiteProc::Ruby::Renderer.new :format => 'html',
|
404
534
|
:style => style, :locale => config['locale']
|
405
535
|
end
|
406
536
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-scholar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- features/cited_only.feature
|
97
97
|
- features/details.feature
|
98
98
|
- features/filter.feature
|
99
|
+
- features/grouping.feature
|
99
100
|
- features/multiple_files.feature
|
100
101
|
- features/reference.feature
|
101
102
|
- features/repository.feature
|
@@ -150,6 +151,7 @@ test_files:
|
|
150
151
|
- features/cited_only.feature
|
151
152
|
- features/details.feature
|
152
153
|
- features/filter.feature
|
154
|
+
- features/grouping.feature
|
153
155
|
- features/multiple_files.feature
|
154
156
|
- features/reference.feature
|
155
157
|
- features/repository.feature
|