Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
J
jekyll-scholar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
caesr-pub
jekyll-scholar
Commits
50c4ded7
Commit
50c4ded7
authored
Apr 06, 2013
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bibliography templates
#19
parent
e7108207
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
21 deletions
+104
-21
features/bibtex.feature
features/bibtex.feature
+28
-0
features/reference.feature
features/reference.feature
+31
-2
lib/jekyll/scholar/defaults.rb
lib/jekyll/scholar/defaults.rb
+20
-16
lib/jekyll/scholar/tags/bibliography.rb
lib/jekyll/scholar/tags/bibliography.rb
+1
-1
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+24
-2
No files found.
features/bibtex.feature
View file @
50c4ded7
...
@@ -90,6 +90,34 @@ Feature: BibTeX
...
@@ -90,6 +90,34 @@ Feature: BibTeX
And
the
"_site/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"<i>The Ruby Programming Language</i>"
in
"_site/scholar.html"
And
I should see
"<i>The Ruby Programming Language</i>"
in
"_site/scholar.html"
@tags
@bibliography
@config
Scenario
:
Simple Bibliography With Custom Template
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography_template
|
<abbr>[%{key}]</abbr>%{reference}
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/references.bib"
:
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography -f references %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"<i>The Ruby Programming Language</i>"
in
"_site/scholar.html"
And
I should see
"<abbr>\[ruby\]</abbr><span"
in
"_site/scholar.html"
@tags
@filter
@tags
@filter
Scenario
:
Filtered Bibliography Loaded From Default Directory
Scenario
:
Filtered Bibliography Loaded From Default Directory
Given I have a scholar configuration with
:
Given I have a scholar configuration with
:
...
...
features/reference.feature
View file @
50c4ded7
...
@@ -29,7 +29,7 @@ Feature: Formatted References
...
@@ -29,7 +29,7 @@ Feature: Formatted References
And
the
"_site/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"Matsumoto, Y. \(2008\). <i>The Ruby"
in
"_site/scholar.html"
And
I should see
"Matsumoto, Y. \(2008\). <i>The Ruby"
in
"_site/scholar.html"
@tags
@reference
@tags
@reference
@missing
Scenario
:
Missing references
Scenario
:
Missing references
Given I have a scholar configuration with
:
Given I have a scholar configuration with
:
|
key
|
value
|
|
key
|
value
|
...
@@ -54,4 +54,33 @@ Feature: Formatted References
...
@@ -54,4 +54,33 @@ Feature: Formatted References
When
I run jekyll
When
I run jekyll
Then
the _site directory should exist
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"missing reference"
in
"_site/scholar.html"
And
I should see
"(missing reference)"
in
"_site/scholar.html"
@tags
@reference
@missing
Scenario
:
Missing references with a custom text
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
bibliography
|
my_references
|
|
missing_reference
|
not
found!
|
And
I have a
"_bibliography"
directory
And I have a file "_bibliography/my_references.bib"
:
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% reference java %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"not found!"
in
"_site/scholar.html"
And
I should not see
"(missing reference)"
in
"_site/scholar.html"
lib/jekyll/scholar/defaults.rb
View file @
50c4ded7
module
Jekyll
module
Jekyll
class
Scholar
class
Scholar
@defaults
=
Hash
[
*
%w{
@defaults
=
{
'style'
=>
'apa'
,
'locale'
=>
'en'
,
style apa
'sort_by'
=>
'none'
,
locale en
'order'
=>
'ascending'
,
sort_by none
'source'
=>
'./_bibliography'
,
order ascending
'bibliography'
=>
'references.bib'
,
source ./_bibliography
'details_dir'
=>
'bibliography'
,
bibliography references.bib
'details_layout'
=>
'bibtex.html'
,
'details_link'
=>
'Details'
,
details_dir bibliography
'bibliography_class'
=>
'bibliography'
,
details_layout bibtex.html
'bibliography_template'
=>
'%{reference}'
,
details_link Details
bibliography_class bibliography
details_link_class details
query @*
'reference_tagname'
=>
'span'
,
'missing_reference'
=>
'(missing reference)'
,
}
].
freeze
'details_link_class'
=>
'details'
,
'query'
=>
'@*'
}.
freeze
class
<<
self
class
<<
self
attr_reader
:defaults
attr_reader
:defaults
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
50c4ded7
...
@@ -24,7 +24,7 @@ module Jekyll
...
@@ -24,7 +24,7 @@ module Jekyll
end
end
references
.
map!
do
|
entry
|
references
.
map!
do
|
entry
|
reference
=
reference
_tag
entry
reference
=
bibliography
_tag
entry
if
generate_details?
if
generate_details?
reference
<<
link_to
(
details_link_for
(
entry
),
reference
<<
link_to
(
details_link_for
(
entry
),
...
...
lib/jekyll/scholar/utilities.rb
View file @
50c4ded7
...
@@ -80,13 +80,35 @@ module Jekyll
...
@@ -80,13 +80,35 @@ module Jekyll
end
end
def
reference_tag
(
entry
)
def
reference_tag
(
entry
)
return
'(missing reference)'
unless
entry
return
missing_reference
unless
entry
entry
=
entry
.
convert
(
:latex
)
entry
=
entry
.
convert
(
:latex
)
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
content_tag
:span
,
reference
,
:id
=>
[
prefix
,
entry
.
key
].
compact
.
join
(
'-'
)
content_tag
reference_tagname
,
reference
,
:id
=>
[
prefix
,
entry
.
key
].
compact
.
join
(
'-'
)
end
def
missing_reference
config
[
'missing_reference'
]
end
def
reference_tagname
config
[
'reference_tagname'
]
||
:span
end
def
bibliography_template
config
[
'bibliography_template'
]
||
'%{reference}'
end
def
bibliography_tag
(
entry
)
return
missing_reference
unless
entry
bibliography_template
%
{
:reference
=>
reference_tag
(
entry
),
:key
=>
entry
.
key
}
end
end
def
generate_details?
def
generate_details?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment