jekyll-scholar 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -175,6 +175,12 @@ following blog post:
175
175
 
176
176
  {% bibliography %}
177
177
 
178
+ Note that this will print your entire bibliography in the Reference section.
179
+ If you would like to include only those entries you cited on the page, pass
180
+ the `cited` option to the bibliography tag:
181
+
182
+ {% bibliography cited %}
183
+
178
184
  For longer quotes, Jekyll-Scholar provides a `quote` tag:
179
185
 
180
186
  {% quote derrida:purveyor %}
@@ -9,12 +9,25 @@ module Jekyll
9
9
 
10
10
  @config = Scholar.defaults.dup
11
11
  @bibtex_file, @query = arguments.strip.split(/\s*filter:\s*/)
12
+
13
+ if @bibtex_file == 'cited'
14
+ @bibtex_file = nil
15
+ @cited = true
16
+ end
12
17
  end
13
18
 
14
19
  def render(context)
15
20
  set_context_to context
16
21
 
17
- references = entries.map do |entry|
22
+ references = entries
23
+
24
+ if @cited
25
+ references = cited_references.map do |key|
26
+ references.detect { |e| e.key == key }
27
+ end
28
+ end
29
+
30
+ references.map! do |entry|
18
31
  reference = CiteProc.process entry.to_citeproc, :style => config['style'],
19
32
  :locale => config['locale'], :format => 'html'
20
33
 
@@ -3,23 +3,27 @@ module Jekyll
3
3
 
4
4
  class CiteTag < Liquid::Tag
5
5
  include Scholar::Utilities
6
-
6
+
7
7
  attr_reader :key, :pages
8
-
8
+
9
9
  def initialize(tag_name, arguments, tokens)
10
10
  super
11
-
11
+
12
12
  @config = Scholar.defaults.dup
13
13
  @key = arguments.strip.split(/\s+/)[0]
14
14
  end
15
15
 
16
16
  def render(context)
17
17
  set_context_to context
18
+
19
+ context['cited'] ||= []
20
+ context['cited'] << key
21
+
18
22
  cite key
19
23
  end
20
-
24
+
21
25
  end
22
-
26
+
23
27
  end
24
28
  end
25
29
 
@@ -6,7 +6,7 @@ module Jekyll
6
6
  # #site readers
7
7
  module Utilities
8
8
 
9
- attr_reader :bibtex_file, :config, :site, :query
9
+ attr_reader :bibtex_file, :config, :site, :query, :context
10
10
 
11
11
  def bibtex_options
12
12
  @bibtex_options ||= { :filter => :latex }
@@ -108,8 +108,12 @@ module Jekyll
108
108
  content_tag :a, content || href, attributes.merge(:href => href)
109
109
  end
110
110
 
111
+ def cited_references
112
+ context && context['cited'] || []
113
+ end
114
+
111
115
  def set_context_to(context)
112
- @site = context.registers[:site]
116
+ @context, @site, = context, context.registers[:site]
113
117
  config.merge!(site.config['scholar'] || {})
114
118
  end
115
119
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  class Scholar
3
- VERSION = '0.3.1'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-scholar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-09 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll