jekyll-scholar 4.0.2 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b4bc03a55f59b2ff1546d6ae1932afd3e9d662
4
- data.tar.gz: 61c9c0815aad016ee18ddbabd4937950705ea3ed
3
+ metadata.gz: 9fd48f190b2abc3b973877fee2e909b65efc61bb
4
+ data.tar.gz: 0c0736c080e65a1d5366ae492c85ec70ef3a80e3
5
5
  SHA512:
6
- metadata.gz: cefd79645e48e268df1ef87c91a86c293af6167f68fa76307fdba20c8c9e986138cad03f5199b031d220738e3bb91aa8ac7caede94d34614726967a7c1c68ff1
7
- data.tar.gz: e6d3dec27c119926edc628ba59c97757ed762d8aabae00e2c5e5497433977f6464b077537c15bfc293e78ba43cda9d2a149a05096dc29022d5f1d40a2003ee58
6
+ metadata.gz: 24aad2ada7dd544baae2c8c1832de09f3d31e81d4543c621e8ecfbb9e2b834ff1a583a7e1fe2e1a17cb5330241bb57ecb2bfa5fa21c8be15228ab53d3753b79c
7
+ data.tar.gz: 06d0ed70b9e9b33deda291b05f0bc787ca302abdaf013ee762058c98a89114836605b7845f28fc3c5d80d41f8651710b2ebd8c393a8958e39310827eca3b96ef
data/README.md CHANGED
@@ -248,6 +248,12 @@ the `cited` option to the bibliography tag:
248
248
 
249
249
  {% bibliography --cited %}
250
250
 
251
+ By default, the `--cited` option will still sort your bibliography if you set
252
+ the sort option. Especially for styles using citation numbers, this is usually
253
+ not the desired behaviour. In such cases you can use `--cited_in_order` instead
254
+ of `--cited` and your bibliography will contain all cited items in the order
255
+ they were cited on the page.
256
+
251
257
  For longer quotes, Jekyll-Scholar provides a `quote` tag:
252
258
 
253
259
  {% quote derrida:purveyor %}
@@ -94,7 +94,7 @@ Feature: BibTeX
94
94
  Given I have a scholar configuration with:
95
95
  | key | value |
96
96
  | source | ./_bibliography |
97
- | bibliography_template | <abbr>{{index}} [{{key}}]</abbr>{{reference}} |
97
+ | bibliography_template | <abbr>{{index}} {{entry.type}} [{{key}}]</abbr>{{reference}} |
98
98
  And I have a "_bibliography" directory
99
99
  And I have a file "_bibliography/references.bib":
100
100
  """
@@ -115,7 +115,7 @@ Feature: BibTeX
115
115
  Then the _site directory should exist
116
116
  And the "_site/scholar.html" file should exist
117
117
  And I should see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
118
- And I should see "<abbr>1 \[ruby\]</abbr><span" in "_site/scholar.html"
118
+ And I should see "<abbr>1 book \[ruby\]</abbr><span" in "_site/scholar.html"
119
119
 
120
120
  @tags @filter
121
121
  Scenario: Filtered Bibliography Loaded From Default Directory
@@ -151,6 +151,41 @@ Feature: BibTeX
151
151
  And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
152
152
  And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
153
153
 
154
+ @tags @filter @variables
155
+ Scenario: Filter using interpolated query variable
156
+ Given I have a scholar configuration with:
157
+ | key | value |
158
+ | source | ./_bibliography |
159
+ And I have a "_bibliography" directory
160
+ And I have a file "_bibliography/references.bib":
161
+ """
162
+ @book{ruby,
163
+ title = {The Ruby Programming Language},
164
+ author = {Flanagan, David and Matsumoto, Yukihiro},
165
+ year = {2008},
166
+ publisher = {O'Reilly Media}
167
+ },
168
+ @book{smalltalk,
169
+ title = {Smalltalk Best Practice Patterns},
170
+ author = {Kent Beck},
171
+ year = {1996},
172
+ publisher = {Prentice Hall}
173
+ }
174
+
175
+ """
176
+ And I have a page "scholar.html":
177
+ """
178
+ ---
179
+ ---
180
+ {% assign yr = 2000 %}
181
+ {% bibliography -f references --query @book[year <= {{ yr }}] %}
182
+ """
183
+ When I run jekyll
184
+ Then the _site directory should exist
185
+ And the "_site/scholar.html" file should exist
186
+ And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
187
+ And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
188
+
154
189
  @tags @bibliography @prefix
155
190
  Scenario: A Prefixed Bibliography
156
191
  Given I have a scholar configuration with:
@@ -277,3 +277,49 @@ Feature: Citations
277
277
  Then the _site directory should exist
278
278
  And the "_site/scholar.html" file should exist
279
279
  And I should see "Flanagan" in "_site/scholar.html"
280
+
281
+ @tags @cite @variables @data
282
+ Scenario: Multiple Citations in a list using liquid variables
283
+ Given I have a scholar configuration with:
284
+ | key | value |
285
+ | source | ./_bibliography |
286
+ | bibliography | my_references |
287
+ And I have a "_bibliography" directory
288
+ And I have a file "_bibliography/my_references.bib":
289
+ """
290
+ @book{ruby,
291
+ title = {The Ruby Programming Language},
292
+ author = {Flanagan, David and Matsumoto, Yukihiro},
293
+ year = {2008},
294
+ publisher = {O'Reilly Media}
295
+ }
296
+
297
+ @book{gof,
298
+ Author = {Erich Gamma and Richard Helm and Ralph Johnson and John Vlissides},
299
+ Title = {Design Patterns: Elements of Reusable Object-Oriented Software},
300
+ Publisher = {Addison-Wesley Professional},
301
+ Year = {1994},
302
+ }
303
+ """
304
+ And I have a "_data" directory
305
+ And I have a file "_data/covers.yml":
306
+ """
307
+ - reference: "ruby"
308
+ image: "/img/covers/cover_01.png"
309
+ - reference: "gof"
310
+ image: "/img/covers/cover_02.png"
311
+ """
312
+ And I have a page "scholar.html":
313
+ """
314
+ ---
315
+ ---
316
+ {% for cover in site.data.covers %}
317
+ {% cite cover.reference %}
318
+ {% endfor %}
319
+ """
320
+ When I run jekyll
321
+ Then the _site directory should exist
322
+ And the "_site/scholar.html" file should exist
323
+ And I should see "Flanagan" in "_site/scholar.html"
324
+ And I should see "Gamma" in "_site/scholar.html"
325
+
@@ -150,3 +150,43 @@ Feature: Sorting BibTeX Bibliographies
150
150
  Then "Ruby Programming" should come before "Smalltalk" in "_site/scholar.html"
151
151
  And I should not see "<i>Ruby Not Cited</i>" in "_site/scholar.html"
152
152
 
153
+ @tags @sorting @cited_in_order
154
+ Scenario: Sort By Year Cited in Order
155
+ Given I have a scholar configuration with:
156
+ | key | value |
157
+ | sort_by | year |
158
+ And I have a "_bibliography" directory
159
+ And I have a file "_bibliography/references.bib":
160
+ """
161
+ @book{ruby1,
162
+ title = {The Ruby Programming Language},
163
+ author = {Flanagan, David and Matsumoto, Yukihiro},
164
+ year = {2008},
165
+ publisher = {O'Reilly Media}
166
+ }
167
+ @book{ruby2,
168
+ title = {Ruby Not Cited},
169
+ author = {Flanagan, David and Matsumoto, Yukihiro},
170
+ year = {2007},
171
+ publisher = {O'Reilly Media}
172
+ }
173
+ @book{smalltalk,
174
+ title = {Smalltalk Best Practice Patterns},
175
+ author = {Kent Beck},
176
+ year = {1996},
177
+ publisher = {Prentice Hall}
178
+ }
179
+ """
180
+ And I have a page "scholar.html":
181
+ """
182
+ ---
183
+ ---
184
+ {% cite ruby1 %}
185
+ {% cite smalltalk %}
186
+ {% bibliography --cited_in_order %}
187
+ """
188
+ When I run jekyll
189
+ Then the _site directory should exist
190
+ And the "_site/scholar.html" file should exist
191
+ Then "Ruby Programming" should come before "Smalltalk" in "_site/scholar.html"
192
+ And I should not see "<i>Ruby Not Cited</i>" in "_site/scholar.html"
@@ -15,15 +15,23 @@ module Jekyll
15
15
  def render(context)
16
16
  set_context_to context
17
17
 
18
- references = entries
19
-
20
- references.select! do |e|
21
- cited_references.include? e.key
22
- end if cited_only?
18
+ items = entries
19
+
20
+ if cited_only?
21
+ items = if skip_sort?
22
+ cited_references.uniq.map do |key|
23
+ items.detect { |e| e.key == key }
24
+ end
25
+ else
26
+ entries.select do |e|
27
+ cited_references.include? e.key
28
+ end
29
+ end
30
+ end
23
31
 
24
- references = references.take(max.to_i) if limit_entries?
32
+ items = items.take(max.to_i) if limit_entries?
25
33
 
26
- bibliography = references.each_with_index.map { |entry, index|
34
+ bibliography = items.each_with_index.map { |entry, index|
27
35
  reference = bibliography_tag(entry, index + 1)
28
36
 
29
37
  if generate_details?
@@ -14,8 +14,7 @@ module Jekyll
14
14
  # #site readers
15
15
  module Utilities
16
16
 
17
- attr_reader :config, :site, :query,
18
- :context, :prefix, :keys, :text, :max
17
+ attr_reader :config, :site, :context, :prefix, :text, :max
19
18
 
20
19
  def split_arguments(arguments)
21
20
 
@@ -35,6 +34,10 @@ module Jekyll
35
34
  @cited = true
36
35
  end
37
36
 
37
+ opts.on('-C', '--cited_in_order') do |cited|
38
+ @cited, @skip_sort = true, true
39
+ end
40
+
38
41
  opts.on('-f', '--file FILE') do |file|
39
42
  @bibtex_files ||= []
40
43
  @bibtex_files << file
@@ -69,7 +72,7 @@ module Jekyll
69
72
  end
70
73
  end
71
74
 
72
- argv = arguments.split(/(\B-[cfqptTslm]|\B--(?:cited|file|query|prefix|text|style|template|locator|max|))/)
75
+ argv = arguments.split(/(\B-[cCfqptTslm]|\B--(?:cited(_in_order)?|file|query|prefix|text|style|template|locator|max|))/)
73
76
 
74
77
  parser.parse argv.map(&:strip).reject(&:empty?)
75
78
  end
@@ -119,6 +122,10 @@ module Jekyll
119
122
  @bibliography
120
123
  end
121
124
 
125
+ def query
126
+ interpolate @query
127
+ end
128
+
122
129
  def entries
123
130
  sort bibliography[query || config['query']]
124
131
  end
@@ -128,7 +135,7 @@ module Jekyll
128
135
  end
129
136
 
130
137
  def sort(unsorted)
131
- return unsorted if config['sort_by'] == 'none'
138
+ return unsorted if skip_sort?
132
139
 
133
140
  sorted = unsorted.sort_by { |e| e[config['sort_by']].to_s }
134
141
  sorted.reverse! if config['order'] =~ /^(desc|reverse)/i
@@ -167,6 +174,10 @@ module Jekyll
167
174
  !!@cited
168
175
  end
169
176
 
177
+ def skip_sort?
178
+ @skip_sort || config['sort_by'] == 'none'
179
+ end
180
+
170
181
  def extend_path(name)
171
182
  if name.nil? || name.empty?
172
183
  name = config['bibliography']
@@ -228,7 +239,7 @@ module Jekyll
228
239
  'entry' => liquidify(entry),
229
240
  'reference' => reference_tag(entry, index),
230
241
  'key' => entry.key,
231
- 'type' => entry.type,
242
+ 'type' => entry.type.to_s,
232
243
  'link' => repository_link_for(entry),
233
244
  'index' => index
234
245
  })
@@ -238,7 +249,7 @@ module Jekyll
238
249
  e = {}
239
250
 
240
251
  e['key'] = entry.key
241
- e['type'] = entry.type
252
+ e['type'] = entry.type.to_s
242
253
 
243
254
  if entry.field?(:abstract)
244
255
  tmp = entry.dup
@@ -327,9 +338,6 @@ module Jekyll
327
338
 
328
339
  def cite(keys)
329
340
  items = keys.map do |key|
330
- # dereference variables in current scope
331
- key = context.scopes.last[key] || key
332
-
333
341
  if bibliography.key?(key)
334
342
  entry = bibliography[key]
335
343
  entry = entry.convert(*bibtex_filters) unless bibtex_filters.empty?
@@ -373,15 +381,26 @@ module Jekyll
373
381
  context && context['cited'] || []
374
382
  end
375
383
 
384
+ def keys
385
+ # De-reference keys (in case they are variables)
386
+ # We need to do this every time, to support for loops,
387
+ # where the context can change for each invocation.
388
+ Array(@keys).map do |key|
389
+ context.send(:resolve, key) || key
390
+ end
391
+ end
392
+
393
+ def interpolate(string)
394
+ return unless string
395
+
396
+ string.gsub(/{{\s*([\w\.]+)\s*}}/) do |match|
397
+ context.send(:resolve, $1) || match
398
+ end
399
+ end
400
+
376
401
  def set_context_to(context)
377
402
  @context, @site, = context, context.registers[:site]
378
403
  config.merge!(site.config['scholar'] || {})
379
-
380
- # De-reference keys
381
- keys.map! do |key|
382
- context.send(:resolve, key) || key
383
- end unless keys.nil?
384
-
385
404
  self
386
405
  end
387
406
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '4.0.2'.freeze
3
+ VERSION = '4.0.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,84 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-scholar
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: citeproc-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :runtime
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.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: csl-styles
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bibtex-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
- description: " Jekyll-Scholar is for all the academic bloggers out there. It is a
69
+ description: ' Jekyll-Scholar is for all the academic bloggers out there. It is a
70
70
  set of extensions for Jekyll the awesome, blog aware, static site generator; it
71
71
  formats your BibTeX bibliographies for the web using CSL citation styles and generally
72
- gives your blog posts citation super-powers.' "
72
+ gives your blog posts citation super-powers.'' '
73
73
  email: http://sylvester.keil.or.at
74
74
  executables: []
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - ".coveralls.yml"
79
- - ".gitignore"
80
- - ".simplecov"
81
- - ".travis.yml"
78
+ - .coveralls.yml
79
+ - .gitignore
80
+ - .simplecov
81
+ - .travis.yml
82
82
  - Gemfile
83
83
  - LICENSE
84
84
  - README.md
@@ -121,12 +121,12 @@ require_paths:
121
121
  - lib
122
122
  required_ruby_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - '>='
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.3.6
132
132
  requirements: []