jekyll-scholar 0.0.1 → 0.0.2
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.
- data/README.md +67 -19
- data/features/bibtex.feature +53 -3
- data/features/citation.feature +57 -0
- data/features/sorting.feature +69 -0
- data/features/step_definitions/jekyll_steps.rb +0 -10
- data/features/step_definitions/scholar_steps.rb +35 -2
- data/jekyll-scholar.gemspec +10 -10
- data/lib/jekyll/scholar.rb +25 -0
- data/lib/jekyll/scholar/converters/bibtex.rb +17 -17
- data/lib/jekyll/scholar/tags/bibliography.rb +55 -0
- data/lib/jekyll/scholar/tags/cite.rb +45 -0
- data/lib/jekyll/scholar/version.rb +2 -2
- metadata +55 -49
data/README.md
CHANGED
@@ -22,10 +22,18 @@ to a file in your plugin directory (e.g., to `_plugins/ext.rb`):
|
|
22
22
|
|
23
23
|
require 'jekyll/scholar'
|
24
24
|
|
25
|
-
In your configuration you can now adjust the Jekyll-Scholar settings
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
In your configuration you can now adjust the Jekyll-Scholar settings. The
|
26
|
+
default configuration is as follows:
|
27
|
+
|
28
|
+
scholar:
|
29
|
+
style: apa
|
30
|
+
locale: en
|
31
|
+
|
32
|
+
sort_by: none
|
33
|
+
order: ascending
|
34
|
+
|
35
|
+
source: ./_bibliography
|
36
|
+
bibliography: references.bib
|
29
37
|
|
30
38
|
You can use any style that ships with
|
31
39
|
[CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g.,
|
@@ -33,10 +41,14 @@ apa, mla, chicago-fullnote-bibliography), or else you can add a link
|
|
33
41
|
to any CSL style (e.g., you could link to any of the styles available at
|
34
42
|
the official [CSL style repository](https://github.com/citation-style-language/styles)).
|
35
43
|
|
36
|
-
The `
|
44
|
+
The `locale` settings defines what language to use when formatting
|
37
45
|
your references (this typically applies to localized terms, e.g., 'Eds.' for
|
38
46
|
editors in English).
|
39
47
|
|
48
|
+
The `source` option indicates where your bibliographies are stored;
|
49
|
+
`bibliography` is the name of your default bibliography.
|
50
|
+
|
51
|
+
|
40
52
|
### Bibliographies
|
41
53
|
|
42
54
|
Once you have loaded Jekyll-Scholar, all files with the extension `.bib` or
|
@@ -47,17 +59,17 @@ the citation style and language defined in your configuration file.
|
|
47
59
|
|
48
60
|
For example, if you had a file `bibliography.bib` in your root directory:
|
49
61
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
---
|
63
|
+
---
|
64
|
+
References
|
65
|
+
==========
|
66
|
+
|
67
|
+
@book{ruby,
|
68
|
+
title = {The Ruby Programming Language},
|
69
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
70
|
+
year = {2008},
|
71
|
+
publisher = {O'Reilly Media}
|
72
|
+
}
|
61
73
|
|
62
74
|
It would be converted to `bibliography.html` with the following content:
|
63
75
|
|
@@ -65,14 +77,50 @@ It would be converted to `bibliography.html` with the following content:
|
|
65
77
|
|
66
78
|
<p>Flanagan, D., & Matsumoto, Y. (2008). <i>The Ruby Programming Language</i>. O’Reilly Media.</p>
|
67
79
|
|
68
|
-
This makes it very easy for you to add
|
80
|
+
This makes it very easy for you to add your bibliography to your Jekyll-powered
|
69
81
|
blog or website.
|
70
82
|
|
83
|
+
If your using other converters to generate your site, don't worry, you can
|
84
|
+
still generate bibliographies using the `bibliography` tag. In your site
|
85
|
+
or blog post, simply call:
|
86
|
+
|
87
|
+
{% bibliography %}
|
88
|
+
|
89
|
+
This will generate your default bibliography; if you use multiple, you can
|
90
|
+
also pass in a name to tell Jekyll-Scholar which bibliography it should render.
|
91
|
+
|
92
|
+
Let's say you have two bibliographies stored in `_bibliography/books.bib` and
|
93
|
+
`_bibliography/papers.bib`; you can include the bibliographies on your site
|
94
|
+
by respectively calling:
|
95
|
+
|
96
|
+
{% bibliography books %}
|
97
|
+
|
98
|
+
{% bibliography papers %}
|
99
|
+
|
71
100
|
|
72
101
|
### Citations
|
73
102
|
|
74
|
-
|
75
|
-
|
103
|
+
If you want to reference books or papers from your bibliography in your blog
|
104
|
+
posts, Jekyll-Scholar can help you, too. Simply use the `cite` tag with
|
105
|
+
the appropriate key of the item you want to cite and Jekyll-Scholar will
|
106
|
+
create a formatted citation reference for you. For example:
|
107
|
+
|
108
|
+
"Once upon a midnight dreary..." {{% cite poe %}}
|
109
|
+
|
110
|
+
|
111
|
+
Contributing
|
112
|
+
------------
|
113
|
+
|
114
|
+
The Jekyll-Scholar source code is
|
115
|
+
[hosted on GitHub](http://github.com/inukshuk/jekyll-scholar/).
|
116
|
+
You can check out a copy of the latest code using Git:
|
117
|
+
|
118
|
+
$ git clone https://github.com/inukshuk/jekyll-scholar.git
|
119
|
+
|
120
|
+
If you've found a bug or have a question, please open an issue on the
|
121
|
+
[Jekyll-Scholar issue tracker](http://github.com/inukshuk/jekyll-scholar/issues).
|
122
|
+
Or, for extra credit, clone the Jekyll-Scholar repository, write a failing
|
123
|
+
example, fix the bug and submit a pull request.
|
76
124
|
|
77
125
|
|
78
126
|
License
|
data/features/bibtex.feature
CHANGED
@@ -3,9 +3,12 @@ Feature: BibTeX
|
|
3
3
|
I want to publish my BibTeX bibliography on my blog
|
4
4
|
In order to share my awesome references with my peers
|
5
5
|
|
6
|
+
@converters
|
6
7
|
Scenario: Simple Bibliography
|
7
|
-
|
8
|
-
|
8
|
+
Given I have a scholar configuration with:
|
9
|
+
| key | value |
|
10
|
+
| style | apa |
|
11
|
+
And I have a page "references.bib":
|
9
12
|
"""
|
10
13
|
---
|
11
14
|
---
|
@@ -21,8 +24,11 @@ Feature: BibTeX
|
|
21
24
|
And the "_site/references.html" file should exist
|
22
25
|
And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"
|
23
26
|
|
27
|
+
@converters
|
24
28
|
Scenario: Markdown Formatted Bibliography
|
25
|
-
|
29
|
+
Given I have a scholar configuration with:
|
30
|
+
| key | value |
|
31
|
+
| style | apa |
|
26
32
|
And I have a page "references.bib":
|
27
33
|
"""
|
28
34
|
---
|
@@ -39,3 +45,47 @@ Feature: BibTeX
|
|
39
45
|
"""
|
40
46
|
When I run jekyll
|
41
47
|
Then I should see "<h1[^>]*>References</h1>" in "_site/references.html"
|
48
|
+
|
49
|
+
@latex
|
50
|
+
Scenario: Simple Bibliography with LaTeX directives
|
51
|
+
Given I have a scholar configuration with:
|
52
|
+
| key | value |
|
53
|
+
| style | apa |
|
54
|
+
And I have a page "references.bib":
|
55
|
+
"""
|
56
|
+
---
|
57
|
+
---
|
58
|
+
@misc{umlaut,
|
59
|
+
title = {Look, an umlaut: \"u!},
|
60
|
+
}
|
61
|
+
"""
|
62
|
+
When I run jekyll
|
63
|
+
Then the _site directory should exist
|
64
|
+
And the "_site/references.html" file should exist
|
65
|
+
And I should see "Look, an umlaut: ü!" in "_site/references.html"
|
66
|
+
|
67
|
+
@tags
|
68
|
+
Scenario: Simple Bibliography Loaded From Default Directory
|
69
|
+
Given I have a scholar configuration with:
|
70
|
+
| key | value |
|
71
|
+
| source | ./_bibliography |
|
72
|
+
And I have a "_bibliography" directory
|
73
|
+
And I have a file "_bibliography/references.bib":
|
74
|
+
"""
|
75
|
+
@book{ruby,
|
76
|
+
title = {The Ruby Programming Language},
|
77
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
78
|
+
year = {2008},
|
79
|
+
publisher = {O'Reilly Media}
|
80
|
+
}
|
81
|
+
"""
|
82
|
+
And I have a page "scholar.html":
|
83
|
+
"""
|
84
|
+
---
|
85
|
+
---
|
86
|
+
{% bibliography references %}
|
87
|
+
"""
|
88
|
+
When I run jekyll
|
89
|
+
Then the _site directory should exist
|
90
|
+
And the "_site/scholar.html" file should exist
|
91
|
+
And I should see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Feature: Citations
|
2
|
+
As a scholar who likes to blog
|
3
|
+
I want to reference cool papers and books from my bibliography
|
4
|
+
|
5
|
+
@tags
|
6
|
+
Scenario: A Simple Citation
|
7
|
+
Given I have a scholar configuration with:
|
8
|
+
| key | value |
|
9
|
+
| source | ./_bibliography |
|
10
|
+
| bibliography | my_references |
|
11
|
+
And I have a "_bibliography" directory
|
12
|
+
And I have a file "_bibliography/my_references.bib":
|
13
|
+
"""
|
14
|
+
@book{ruby,
|
15
|
+
title = {The Ruby Programming Language},
|
16
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
17
|
+
year = {2008},
|
18
|
+
publisher = {O'Reilly Media}
|
19
|
+
}
|
20
|
+
"""
|
21
|
+
And I have a page "scholar.html":
|
22
|
+
"""
|
23
|
+
---
|
24
|
+
---
|
25
|
+
{% cite ruby %}
|
26
|
+
"""
|
27
|
+
When I run jekyll
|
28
|
+
Then the _site directory should exist
|
29
|
+
And the "_site/scholar.html" file should exist
|
30
|
+
And I should see "Flanagan" in "_site/scholar.html"
|
31
|
+
|
32
|
+
@tags
|
33
|
+
Scenario: Missing references
|
34
|
+
Given I have a scholar configuration with:
|
35
|
+
| key | value |
|
36
|
+
| source | ./_bibliography |
|
37
|
+
| bibliography | my_references |
|
38
|
+
And I have a "_bibliography" directory
|
39
|
+
And I have a file "_bibliography/my_references.bib":
|
40
|
+
"""
|
41
|
+
@book{ruby,
|
42
|
+
title = {The Ruby Programming Language},
|
43
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
44
|
+
year = {2008},
|
45
|
+
publisher = {O'Reilly Media}
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
And I have a page "scholar.html":
|
49
|
+
"""
|
50
|
+
---
|
51
|
+
---
|
52
|
+
{% cite java %}
|
53
|
+
"""
|
54
|
+
When I run jekyll
|
55
|
+
Then the _site directory should exist
|
56
|
+
And the "_site/scholar.html" file should exist
|
57
|
+
And I should see "missing reference" in "_site/scholar.html"
|
@@ -0,0 +1,69 @@
|
|
1
|
+
Feature: Sorting BibTeX Bibliographies
|
2
|
+
As a scholar who likes to blog
|
3
|
+
I want to sort my bibliographies according to configurable parameters
|
4
|
+
|
5
|
+
@tags @sorting
|
6
|
+
Scenario: Sort By Year
|
7
|
+
Given I have a scholar configuration with:
|
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 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 "2007" should come before "2008" in "_site/scholar.html"
|
36
|
+
|
37
|
+
@tags @sorting
|
38
|
+
Scenario: Reverse Sort Order
|
39
|
+
Given I have a scholar configuration with:
|
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 references %}
|
64
|
+
"""
|
65
|
+
When I run jekyll
|
66
|
+
Then the _site directory should exist
|
67
|
+
And the "_site/scholar.html" file should exist
|
68
|
+
Then "2008" should come before "2007" in "_site/scholar.html"
|
69
|
+
|
@@ -45,16 +45,6 @@ Given /^I have a configuration file with:$/ do |table|
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
|
49
|
-
File.open('_config.yml', 'w') do |f|
|
50
|
-
f.write("#{key}:\n")
|
51
|
-
table.hashes.each do |row|
|
52
|
-
f.write("- #{row["value"]}\n")
|
53
|
-
end
|
54
|
-
f.close
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
48
|
When /^I run jekyll$/ do
|
59
49
|
run_jekyll
|
60
50
|
end
|
@@ -1,6 +1,39 @@
|
|
1
1
|
|
2
|
-
Given /^I have a
|
2
|
+
Given /^I have a "([^"]*)" directory/ do |dir|
|
3
|
+
FileUtils.mkdir(dir)
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^I have a (?:page|file) "([^"]*)":$/ do |file, string|
|
3
7
|
File.open(file, 'w') do |f|
|
4
|
-
|
8
|
+
f.write(string)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
|
13
|
+
File.open('_config.yml', 'w') do |f|
|
14
|
+
f.write("#{key}:\n")
|
15
|
+
table.hashes.each do |row|
|
16
|
+
f.write(" #{row["key"]}: #{row["value"]}\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Given /^I have a scholar configuration with:$/ do |table|
|
22
|
+
File.open('_config.yml', 'w') do |f|
|
23
|
+
f.write("scholar:\n")
|
24
|
+
table.hashes.each do |row|
|
25
|
+
f.write(" #{row["key"]}: #{row["value"]}\n")
|
26
|
+
end
|
5
27
|
end
|
6
28
|
end
|
29
|
+
|
30
|
+
|
31
|
+
Then /^"(.*)" should come before "(.*)" in "(.*)"$/ do |p1, p2, file|
|
32
|
+
data = File.open(file).readlines.join('')
|
33
|
+
|
34
|
+
m1 = data.match(p1)
|
35
|
+
m2 = data.match(p2)
|
36
|
+
|
37
|
+
assert m1.offset(0)[0] < m2.offset(0)[0]
|
38
|
+
end
|
39
|
+
|
data/jekyll-scholar.gemspec
CHANGED
@@ -21,16 +21,16 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency('jekyll', '~> 0.10')
|
22
22
|
s.add_runtime_dependency('citeproc-ruby', '~> 0.0.6')
|
23
23
|
s.add_runtime_dependency('bibtex-ruby', '~> 2.0.5')
|
24
|
-
|
25
|
-
s.add_development_dependency('
|
26
|
-
s.add_development_dependency('rdoc',
|
27
|
-
s.add_development_dependency('
|
28
|
-
s.add_development_dependency('
|
29
|
-
s.add_development_dependency('
|
30
|
-
s.add_development_dependency('
|
31
|
-
s.add_development_dependency('
|
32
|
-
s.add_development_dependency('
|
33
|
-
s.add_development_dependency('
|
24
|
+
|
25
|
+
s.add_development_dependency('rake', "~> 0.9")
|
26
|
+
s.add_development_dependency('rdoc', "~> 3.11")
|
27
|
+
s.add_development_dependency('redgreen', "~> 1.2")
|
28
|
+
s.add_development_dependency('shoulda', "~> 2.11")
|
29
|
+
s.add_development_dependency('rr', "~> 1.0")
|
30
|
+
s.add_development_dependency('cucumber', "1.1")
|
31
|
+
s.add_development_dependency('RedCloth', "~> 4.2")
|
32
|
+
s.add_development_dependency('rdiscount', "~> 1.6")
|
33
|
+
s.add_development_dependency('redcarpet', "~> 1.9")
|
34
34
|
|
35
35
|
s.files = `git ls-files`.split("\n")
|
36
36
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/jekyll/scholar.rb
CHANGED
@@ -1,4 +1,29 @@
|
|
1
1
|
|
2
2
|
require 'jekyll'
|
3
|
+
|
4
|
+
require 'bibtex'
|
5
|
+
require 'citeproc'
|
6
|
+
|
3
7
|
require 'jekyll/scholar/version'
|
4
8
|
require 'jekyll/scholar/converters/bibtex'
|
9
|
+
require 'jekyll/scholar/tags/bibliography'
|
10
|
+
require 'jekyll/scholar/tags/cite'
|
11
|
+
|
12
|
+
module Jekyll
|
13
|
+
class Scholar
|
14
|
+
|
15
|
+
@defaults = Hash[*%w{
|
16
|
+
style apa
|
17
|
+
locale en
|
18
|
+
sort_by none
|
19
|
+
order ascending
|
20
|
+
source ./_bibliography
|
21
|
+
bibliography references.bib
|
22
|
+
}].freeze
|
23
|
+
|
24
|
+
class << self
|
25
|
+
attr_reader :defaults
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
require 'bibtex'
|
2
|
-
require 'citeproc'
|
3
|
-
|
4
1
|
module Jekyll
|
5
|
-
|
2
|
+
class Scholar
|
6
3
|
class BibTeXConverter < Converter
|
7
4
|
safe true
|
8
5
|
|
9
6
|
priority :highest
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
citation_locale en
|
14
|
-
}].freeze
|
15
|
-
|
16
|
-
PATTERN = (/bib(tex)?$/i).freeze
|
17
|
-
EXTENSION = '.html'.freeze
|
8
|
+
@pattern = (/bib(tex)?$/i).freeze
|
9
|
+
@extension = '.html'.freeze
|
18
10
|
|
11
|
+
class << self
|
12
|
+
attr_reader :pattern, :extension
|
13
|
+
end
|
14
|
+
|
19
15
|
def initialize (config = {})
|
20
16
|
super
|
21
|
-
@config['scholar'] =
|
17
|
+
@config['scholar'] = Scholar.defaults.merge(@config['scholar'] || {})
|
22
18
|
@markdown = MarkdownConverter.new config
|
23
19
|
end
|
24
20
|
|
25
|
-
def matches
|
21
|
+
def matches(extension)
|
22
|
+
extension =~ BibTeXConverter.pattern
|
23
|
+
end
|
26
24
|
|
27
|
-
def output_ext
|
25
|
+
def output_ext(extension)
|
26
|
+
BibTeXConverter.extension
|
27
|
+
end
|
28
28
|
|
29
29
|
def convert (content)
|
30
|
-
content = BibTeX.parse(content, :include => [:meta_content]).map do |b|
|
30
|
+
content = BibTeX.parse(content, :strict => true, :include => [:meta_content], :filter => [:latex]).map do |b|
|
31
31
|
if b.respond_to?(:to_citeproc)
|
32
|
-
CiteProc.process b.to_citeproc, :style => @config['
|
33
|
-
:locale => @config['
|
32
|
+
CiteProc.process b.to_citeproc, :style => @config['style'],
|
33
|
+
:locale => @config['locale'], :format => 'html'
|
34
34
|
else
|
35
35
|
b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
|
36
36
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class Scholar
|
3
|
+
|
4
|
+
class BibliographyTag < Liquid::Tag
|
5
|
+
|
6
|
+
attr_reader :file, :config
|
7
|
+
|
8
|
+
def initialize(tag_name, arguments, tokens)
|
9
|
+
super
|
10
|
+
|
11
|
+
@config = Scholar.defaults.dup
|
12
|
+
@file = arguments.strip
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(context)
|
16
|
+
config.merge!(context.registers[:site].config['scholar'] || {})
|
17
|
+
|
18
|
+
entries.map { |e|
|
19
|
+
CiteProc.process e.to_citeproc, :style => config['style'],
|
20
|
+
:locale => config['locale'], :format => 'html'
|
21
|
+
}.join("\n")
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def bibliography
|
27
|
+
@bibliography ||= BibTeX.open(extend_path(file), :filter => :latex)
|
28
|
+
end
|
29
|
+
|
30
|
+
def entries
|
31
|
+
b = bibliography['@*']
|
32
|
+
|
33
|
+
unless config['sort_by'] == 'none'
|
34
|
+
b.sort_by! { |e| e[config['sort_by']] }
|
35
|
+
b.reverse! if config['order'] =~ /^(desc|reverse)/i
|
36
|
+
end
|
37
|
+
|
38
|
+
b
|
39
|
+
end
|
40
|
+
|
41
|
+
def extend_path(name)
|
42
|
+
if name.nil? || name.empty?
|
43
|
+
name = config['bibliography']
|
44
|
+
end
|
45
|
+
|
46
|
+
p = File.join(config['source'], name)
|
47
|
+
p << '.bib' unless File.exists?(p)
|
48
|
+
p
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Liquid::Template.register_tag('bibliography', Jekyll::Scholar::BibliographyTag)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class Scholar
|
3
|
+
|
4
|
+
class CiteTag < Liquid::Tag
|
5
|
+
|
6
|
+
attr_reader :key, :pages, :config
|
7
|
+
|
8
|
+
def initialize(tag_name, arguments, tokens)
|
9
|
+
super
|
10
|
+
|
11
|
+
@config = Scholar.defaults.dup
|
12
|
+
@key = arguments.strip.split(/\s+/)[0]
|
13
|
+
end
|
14
|
+
|
15
|
+
def render(context)
|
16
|
+
config.merge!(context.registers[:site].config['scholar'] || {})
|
17
|
+
|
18
|
+
puts key
|
19
|
+
e = bibliography[key]
|
20
|
+
puts e
|
21
|
+
if e
|
22
|
+
CiteProc.process e.to_citeproc, :style => config['style'],
|
23
|
+
:locale => config['locale'], :format => 'html', :mode => :citation
|
24
|
+
else
|
25
|
+
"(missing reference)"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def bibliography
|
32
|
+
@bibliography ||= BibTeX.open(extend_path(config['bibliography']), :filter => :latex)
|
33
|
+
end
|
34
|
+
|
35
|
+
def extend_path(name)
|
36
|
+
p = File.join(config['source'], name)
|
37
|
+
p << '.bib' unless File.exists?(p)
|
38
|
+
p
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Liquid::Template.register_tag('cite', Jekyll::Scholar::CiteTag)
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
16
|
-
requirement: &
|
16
|
+
requirement: &70141486252080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.10'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70141486252080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: citeproc-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &70141486251300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.0.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70141486251300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bibtex-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70141486249780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,106 +43,106 @@ dependencies:
|
|
43
43
|
version: 2.0.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70141486249780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: rake
|
49
|
+
requirement: &70141486264360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0.9'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70141486264360
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &70141486263420 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '3.
|
65
|
+
version: '3.11'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70141486263420
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: &
|
70
|
+
name: redgreen
|
71
|
+
requirement: &70141486262680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '1.2'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70141486262680
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
requirement: &
|
81
|
+
name: shoulda
|
82
|
+
requirement: &70141486261140 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ~>
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: '2.11'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70141486261140
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
93
|
-
requirement: &
|
92
|
+
name: rr
|
93
|
+
requirement: &70141486260640 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ~>
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
98
|
+
version: '1.0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70141486260640
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
|
-
name:
|
104
|
-
requirement: &
|
103
|
+
name: cucumber
|
104
|
+
requirement: &70141486259820 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - =
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
109
|
+
version: '1.1'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70141486259820
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
115
|
-
requirement: &
|
114
|
+
name: RedCloth
|
115
|
+
requirement: &70141486258100 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ~>
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: '4.2'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70141486258100
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
|
-
name:
|
126
|
-
requirement: &
|
125
|
+
name: rdiscount
|
126
|
+
requirement: &70141486273300 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '1.6'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70141486273300
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
|
-
name:
|
137
|
-
requirement: &
|
136
|
+
name: redcarpet
|
137
|
+
requirement: &70141486271560 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
|
-
- -
|
140
|
+
- - ~>
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version: 1.
|
142
|
+
version: '1.9'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70141486271560
|
146
146
|
description: A set of jekyll extensions for academic blogging.
|
147
147
|
email: http://sylvester.keil.or.at
|
148
148
|
executables: []
|
@@ -154,12 +154,16 @@ files:
|
|
154
154
|
- LICENSE
|
155
155
|
- README.md
|
156
156
|
- features/bibtex.feature
|
157
|
+
- features/citation.feature
|
158
|
+
- features/sorting.feature
|
157
159
|
- features/step_definitions/jekyll_steps.rb
|
158
160
|
- features/step_definitions/scholar_steps.rb
|
159
161
|
- features/support/env.rb
|
160
162
|
- jekyll-scholar.gemspec
|
161
163
|
- lib/jekyll/scholar.rb
|
162
164
|
- lib/jekyll/scholar/converters/bibtex.rb
|
165
|
+
- lib/jekyll/scholar/tags/bibliography.rb
|
166
|
+
- lib/jekyll/scholar/tags/cite.rb
|
163
167
|
- lib/jekyll/scholar/version.rb
|
164
168
|
homepage: http://github.com/inukshuk/jekyll-scholar
|
165
169
|
licenses: []
|
@@ -187,6 +191,8 @@ specification_version: 3
|
|
187
191
|
summary: Jekyll extensions for the academic blogger.
|
188
192
|
test_files:
|
189
193
|
- features/bibtex.feature
|
194
|
+
- features/citation.feature
|
195
|
+
- features/sorting.feature
|
190
196
|
- features/step_definitions/jekyll_steps.rb
|
191
197
|
- features/step_definitions/scholar_steps.rb
|
192
198
|
- features/support/env.rb
|