jekyll-scholar 0.0.5 → 0.0.6
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 +24 -3
- data/features/citation.feature +31 -2
- data/features/details.feature +40 -0
- data/lib/jekyll/scholar/tags/bibliography.rb +10 -11
- data/lib/jekyll/scholar/tags/cite.rb +3 -13
- data/lib/jekyll/scholar/tags/quote.rb +34 -0
- data/lib/jekyll/scholar/utilities.rb +44 -2
- data/lib/jekyll/scholar/version.rb +1 -1
- data/lib/jekyll/scholar.rb +1 -0
- metadata +26 -25
data/README.md
CHANGED
@@ -39,7 +39,7 @@ default configuration is as follows:
|
|
39
39
|
details_layout: bibtex.html
|
40
40
|
details_link: Details
|
41
41
|
|
42
|
-
|
42
|
+
query: "@*"
|
43
43
|
|
44
44
|
You can use any style that ships with
|
45
45
|
[CiteProc-Ruby](https://github.com/inukshuk/citeproc-ruby) by name (e.g.,
|
@@ -153,6 +153,27 @@ following blog post:
|
|
153
153
|
|
154
154
|
{% bibliography %}
|
155
155
|
|
156
|
+
For longer quotes, Jekyll-Scholar provides a `quote` tag:
|
157
|
+
|
158
|
+
{% quote derrida:purveyor %}
|
159
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
|
160
|
+
sed do eiusmod tempor.
|
161
|
+
|
162
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing.
|
163
|
+
{% endquote %}
|
164
|
+
|
165
|
+
For example, this could be rendered as:
|
166
|
+
|
167
|
+
<blockquote>
|
168
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br/>
|
169
|
+
sed do eiusmod tempor.</p>
|
170
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing.</p>
|
171
|
+
<cite>
|
172
|
+
<a href="#derrida:purveyor">(Derrida, 1975)</a>
|
173
|
+
</cite>
|
174
|
+
</blockquote>
|
175
|
+
|
176
|
+
|
156
177
|
### Detail Pages
|
157
178
|
|
158
179
|
If your layouts directory contains a layout file for bibliography details
|
@@ -177,8 +198,8 @@ of your BibTeX entry. Here is an example of a details page layout:
|
|
177
198
|
<head></head>
|
178
199
|
<body>
|
179
200
|
<h1>{{ page.entry.title }}</h1>
|
180
|
-
|
181
|
-
|
201
|
+
<h2>{{ page.entry.author }}</h2>
|
202
|
+
<p>{{ page.entry.abstract }}</p>
|
182
203
|
</body>
|
183
204
|
</html>
|
184
205
|
|
data/features/citation.feature
CHANGED
@@ -2,7 +2,7 @@ Feature: Citations
|
|
2
2
|
As a scholar who likes to blog
|
3
3
|
I want to reference cool papers and books from my bibliography
|
4
4
|
|
5
|
-
@tags
|
5
|
+
@tags @cite
|
6
6
|
Scenario: A Simple Citation
|
7
7
|
Given I have a scholar configuration with:
|
8
8
|
| key | value |
|
@@ -29,7 +29,7 @@ Feature: Citations
|
|
29
29
|
And the "_site/scholar.html" file should exist
|
30
30
|
And I should see "Flanagan" in "_site/scholar.html"
|
31
31
|
|
32
|
-
@tags
|
32
|
+
@tags @cite
|
33
33
|
Scenario: Missing references
|
34
34
|
Given I have a scholar configuration with:
|
35
35
|
| key | value |
|
@@ -55,3 +55,32 @@ Feature: Citations
|
|
55
55
|
Then the _site directory should exist
|
56
56
|
And the "_site/scholar.html" file should exist
|
57
57
|
And I should see "missing reference" in "_site/scholar.html"
|
58
|
+
|
59
|
+
@tags @quote
|
60
|
+
Scenario: A Simple Block-Quote
|
61
|
+
Given I have a scholar configuration with:
|
62
|
+
| key | value |
|
63
|
+
| source | ./_bibliography |
|
64
|
+
| bibliography | my_references |
|
65
|
+
And I have a "_bibliography" directory
|
66
|
+
And I have a file "_bibliography/my_references.bib":
|
67
|
+
"""
|
68
|
+
@book{ruby,
|
69
|
+
title = {The Ruby Programming Language},
|
70
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
71
|
+
year = {2008},
|
72
|
+
publisher = {O'Reilly Media}
|
73
|
+
}
|
74
|
+
"""
|
75
|
+
And I have a page "scholar.html":
|
76
|
+
"""
|
77
|
+
---
|
78
|
+
---
|
79
|
+
{% quote ruby %}
|
80
|
+
We <3 Ruby
|
81
|
+
{% endquote %}
|
82
|
+
"""
|
83
|
+
When I run jekyll
|
84
|
+
Then the _site directory should exist
|
85
|
+
And the "_site/scholar.html" file should exist
|
86
|
+
And I should see "<blockquote><p>We <3 Ruby</p><cite><a .*#ruby.+\(Flanagan" in "_site/scholar.html"
|
data/features/details.feature
CHANGED
@@ -35,3 +35,43 @@ Feature: BibTeX
|
|
35
35
|
Then the _site directory should exist
|
36
36
|
And the "_site/bibliography/ruby.html" file should exist
|
37
37
|
And I should see "The Ruby Programming Language" in "_site/bibliography/ruby.html"
|
38
|
+
|
39
|
+
@tags @details
|
40
|
+
Scenario: Links to Detail Pages are Generated Automatically
|
41
|
+
Given I have a scholar configuration with:
|
42
|
+
| key | value |
|
43
|
+
| source | ./_bibliography |
|
44
|
+
| bibliogaphy | references |
|
45
|
+
| details_layout | details.html |
|
46
|
+
And I have a "_bibliography" directory
|
47
|
+
And I have a file "_bibliography/references.bib":
|
48
|
+
"""
|
49
|
+
@book{ruby,
|
50
|
+
title = {The Ruby Programming Language},
|
51
|
+
author = {Flanagan, David and Matsumoto, Yukihiro},
|
52
|
+
year = {2008},
|
53
|
+
publisher = {O'Reilly Media}
|
54
|
+
}
|
55
|
+
"""
|
56
|
+
And I have a "_layouts" directory
|
57
|
+
And I have a file "_layouts/details.html":
|
58
|
+
"""
|
59
|
+
---
|
60
|
+
---
|
61
|
+
<html>
|
62
|
+
<head></head>
|
63
|
+
<body>
|
64
|
+
{{ page.entry.title }}
|
65
|
+
</body>
|
66
|
+
</html>
|
67
|
+
"""
|
68
|
+
And I have a page "scholar.html":
|
69
|
+
"""
|
70
|
+
---
|
71
|
+
---
|
72
|
+
{% bibliography %}
|
73
|
+
"""
|
74
|
+
When I run jekyll
|
75
|
+
Then the _site directory should exist
|
76
|
+
And the "_site/scholar.html" file should exist
|
77
|
+
And I should see "<a href=\"/bibliography/ruby.html\">" in "_site/scholar.html"
|
@@ -12,23 +12,22 @@ module Jekyll
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def render(context)
|
15
|
-
|
16
|
-
config.merge!(site.config['scholar'] || {})
|
15
|
+
set_context_to context
|
17
16
|
|
18
|
-
references = entries.map do |
|
19
|
-
reference = CiteProc.process
|
17
|
+
references = entries.map do |entry|
|
18
|
+
reference = CiteProc.process entry.to_citeproc, :style => config['style'],
|
20
19
|
:locale => config['locale'], :format => 'html'
|
21
|
-
|
22
|
-
reference =
|
23
|
-
|
20
|
+
|
21
|
+
reference = content_tag :span, reference, :id => entry.key
|
22
|
+
|
24
23
|
if generate_details?
|
25
|
-
reference <<
|
24
|
+
reference << link_to(details_link_for(entry), config['details_link'])
|
26
25
|
end
|
27
|
-
|
28
|
-
|
26
|
+
|
27
|
+
content_tag :li, reference
|
29
28
|
end
|
30
29
|
|
31
|
-
|
30
|
+
content_tag :ol, references.join("\n")
|
32
31
|
end
|
33
32
|
|
34
33
|
end
|
@@ -4,7 +4,7 @@ module Jekyll
|
|
4
4
|
class CiteTag < Liquid::Tag
|
5
5
|
include Scholar::Utilities
|
6
6
|
|
7
|
-
attr_reader :key, :pages
|
7
|
+
attr_reader :key, :pages
|
8
8
|
|
9
9
|
def initialize(tag_name, arguments, tokens)
|
10
10
|
super
|
@@ -14,18 +14,8 @@ module Jekyll
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def render(context)
|
17
|
-
|
18
|
-
|
19
|
-
entry = bibliography[key]
|
20
|
-
|
21
|
-
if entry
|
22
|
-
c = CiteProc.process entry.to_citeproc, :style => config['style'],
|
23
|
-
:locale => config['locale'], :format => 'html', :mode => :citation
|
24
|
-
|
25
|
-
"<a href='##{entry.key}'>#{c}</a>"
|
26
|
-
else
|
27
|
-
"(missing reference)"
|
28
|
-
end
|
17
|
+
set_context_to context
|
18
|
+
cite key
|
29
19
|
end
|
30
20
|
|
31
21
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class Scholar
|
3
|
+
|
4
|
+
class QuoteTag < Liquid::Block
|
5
|
+
include Scholar::Utilities
|
6
|
+
|
7
|
+
attr_reader :key, :pages
|
8
|
+
|
9
|
+
def initialize(tag_name, arguments, tokens)
|
10
|
+
super
|
11
|
+
|
12
|
+
@config = Scholar.defaults.dup
|
13
|
+
@key = arguments.strip.split(/\s+/)[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def render(context)
|
17
|
+
set_context_to context
|
18
|
+
|
19
|
+
quote = super.strip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')
|
20
|
+
quote = content_tag :p, quote
|
21
|
+
|
22
|
+
citation = cite(key)
|
23
|
+
|
24
|
+
quote << content_tag(:cite, citation)
|
25
|
+
|
26
|
+
content_tag :blockquote, quote
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Liquid::Template.register_tag('quote', Jekyll::Scholar::QuoteTag)
|
@@ -53,14 +53,56 @@ module Jekyll
|
|
53
53
|
[name, 'html'].join('.')
|
54
54
|
end
|
55
55
|
|
56
|
-
def details_link_for(entry)
|
57
|
-
[
|
56
|
+
def details_link_for(entry, base = base_url)
|
57
|
+
[base, details_path, details_file_for(entry)].join('/')
|
58
|
+
end
|
59
|
+
|
60
|
+
def base_url
|
61
|
+
@base_url ||= site.config['baseurl'] || site.config['base_url'] || nil
|
58
62
|
end
|
59
63
|
|
60
64
|
def details_path
|
61
65
|
config['details_dir']
|
62
66
|
end
|
63
67
|
|
68
|
+
def cite(key)
|
69
|
+
entry = bibliography[key]
|
70
|
+
|
71
|
+
if bibliography.key?(key)
|
72
|
+
citation = CiteProc.process entry.to_citeproc, :style => config['style'],
|
73
|
+
:locale => config['locale'], :format => 'html', :mode => :citation
|
74
|
+
|
75
|
+
link_to "##{entry.key}", citation.join
|
76
|
+
else
|
77
|
+
"(missing reference)"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def content_tag(name, content_or_attributes, attributes = {})
|
82
|
+
if content_or_attributes.is_a?(Hash)
|
83
|
+
content, attributes = nil, content_or_attributes
|
84
|
+
else
|
85
|
+
content = content_or_attributes
|
86
|
+
end
|
87
|
+
|
88
|
+
attributes = attributes.map { |k,v| %Q(#{k}="#{v}") }
|
89
|
+
|
90
|
+
if content.nil?
|
91
|
+
"<#{[name, attributes].flatten.compact.join(' ')}/>"
|
92
|
+
else
|
93
|
+
"<#{[name, attributes].flatten.compact.join(' ')}>#{content}</#{name}>"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def link_to(href, content, attributes = {})
|
98
|
+
content_tag :a, content || href, attributes.merge(:href => href)
|
99
|
+
end
|
100
|
+
|
101
|
+
def set_context_to(context)
|
102
|
+
@site = context.registers[:site]
|
103
|
+
config.merge!(site.config['scholar'] || {})
|
104
|
+
end
|
105
|
+
|
64
106
|
end
|
65
107
|
|
66
108
|
end
|
data/lib/jekyll/scholar.rb
CHANGED
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
16
|
-
requirement: &
|
16
|
+
requirement: &70290593823440 !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: *70290593823440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: citeproc-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &70290593822900 !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: *70290593822900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bibtex-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70290593821840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.0.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70290593821840
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70290593820240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.9'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70290593820240
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &70290593817500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.11'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70290593817500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: redgreen
|
71
|
-
requirement: &
|
71
|
+
requirement: &70290593832100 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '1.2'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70290593832100
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: shoulda
|
82
|
-
requirement: &
|
82
|
+
requirement: &70290593831400 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.11'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70290593831400
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rr
|
93
|
-
requirement: &
|
93
|
+
requirement: &70290593830920 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '1.0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70290593830920
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: cucumber
|
104
|
-
requirement: &
|
104
|
+
requirement: &70290593830400 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - =
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '1.1'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70290593830400
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: RedCloth
|
115
|
-
requirement: &
|
115
|
+
requirement: &70290593829840 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '4.2'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70290593829840
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rdiscount
|
126
|
-
requirement: &
|
126
|
+
requirement: &70290593829260 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '1.6'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70290593829260
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: redcarpet
|
137
|
-
requirement: &
|
137
|
+
requirement: &70290593828580 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ~>
|
@@ -142,7 +142,7 @@ dependencies:
|
|
142
142
|
version: '1.9'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70290593828580
|
146
146
|
description: A set of jekyll extensions for academic blogging.
|
147
147
|
email: http://sylvester.keil.or.at
|
148
148
|
executables: []
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/jekyll/scholar/generators/details.rb
|
169
169
|
- lib/jekyll/scholar/tags/bibliography.rb
|
170
170
|
- lib/jekyll/scholar/tags/cite.rb
|
171
|
+
- lib/jekyll/scholar/tags/quote.rb
|
171
172
|
- lib/jekyll/scholar/utilities.rb
|
172
173
|
- lib/jekyll/scholar/version.rb
|
173
174
|
homepage: http://github.com/inukshuk/jekyll-scholar
|