Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
jekyll-scholar
Commits
80e27522
Commit
80e27522
authored
Apr 30, 2012
by
Sylvester Keil
Browse files
added filter/query settings
#1
parent
ee753709
Changes
8
Show whitespace changes
Inline
Side-by-side
features/details.feature
View file @
80e27522
...
@@ -34,4 +34,4 @@ Feature: BibTeX
...
@@ -34,4 +34,4 @@ Feature: BibTeX
When
I run jekyll
When
I run jekyll
Then
the _site directory should exist
Then
the _site directory should exist
And
the
"_site/bibliography/ruby.html"
file should exist
And
the
"_site/bibliography/ruby.html"
file should exist
And
I should see
"
<i>
The Ruby Programming Language
</i>
"
in
"_site/bibliography/ruby.html"
And
I should see
"The Ruby Programming Language"
in
"_site/bibliography/ruby.html"
features/filter.feature
0 → 100644
View file @
80e27522
Feature
:
BibTeX
As a scholar who likes to blog
I want to apply filters to my BibTeX bibliography
In order to have control over the references that go up on my website
@tags @filters
Scenario
:
Filter by Year
Given I have a scholar configuration with
:
|
key
|
value
|
|
source
|
./_bibliography
|
|
query
|
"@*[year=2009]"
|
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}
}
@book{pickaxe,
title = {Programming Ruby 1.9: The Pragmatic Programmer's Guide},
author = {Thomas, Dave and Fowler, Chad and Hunt, Andy},
year = {2009},
edition = 3,
publisher = {Pragmatic Bookshelf}
}
"""
And I have a page "scholar.html"
:
"""
---
---
{% bibliography %}
"""
When
I run jekyll
Then
the _site directory should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"Programming Ruby"
in
"_site/scholar.html"
And
I should not see
"The Ruby Programming Language"
in
"_site/scholar.html"
features/step_definitions/jekyll_steps.rb
View file @
80e27522
...
@@ -54,9 +54,15 @@ Then /^the (.*) directory should exist$/ do |dir|
...
@@ -54,9 +54,15 @@ Then /^the (.*) directory should exist$/ do |dir|
end
end
Then
/^I should see "(.*)" in "(.*)"$/
do
|
text
,
file
|
Then
/^I should see "(.*)" in "(.*)"$/
do
|
text
,
file
|
puts
File
.
open
(
file
).
readlines
.
join
assert_match
Regexp
.
new
(
text
),
File
.
open
(
file
).
readlines
.
join
assert_match
Regexp
.
new
(
text
),
File
.
open
(
file
).
readlines
.
join
end
end
Then
/^I should not see "(.*)" in "(.*)"$/
do
|
text
,
file
|
assert
!
File
.
open
(
file
).
readlines
.
join
.
match
(
Regexp
.
new
(
text
))
end
Then
/^the "(.*)" file should exist$/
do
|
file
|
Then
/^the "(.*)" file should exist$/
do
|
file
|
assert
File
.
file?
(
file
)
assert
File
.
file?
(
file
)
end
end
...
...
lib/jekyll/scholar.rb
View file @
80e27522
...
@@ -5,6 +5,7 @@ require 'bibtex'
...
@@ -5,6 +5,7 @@ require 'bibtex'
require
'citeproc'
require
'citeproc'
require
'jekyll/scholar/version'
require
'jekyll/scholar/version'
require
'jekyll/scholar/utilities'
require
'jekyll/scholar/converters/bibtex'
require
'jekyll/scholar/converters/bibtex'
require
'jekyll/scholar/tags/bibliography'
require
'jekyll/scholar/tags/bibliography'
require
'jekyll/scholar/tags/cite'
require
'jekyll/scholar/tags/cite'
...
@@ -27,6 +28,8 @@ module Jekyll
...
@@ -27,6 +28,8 @@ module Jekyll
details_dir ./bibliography
details_dir ./bibliography
details_layout bibtex.html
details_layout bibtex.html
query @*
}
].
freeze
}
].
freeze
class
<<
self
class
<<
self
...
...
lib/jekyll/scholar/converters/bibtex.rb
View file @
80e27522
...
@@ -2,9 +2,10 @@ module Jekyll
...
@@ -2,9 +2,10 @@ module Jekyll
class
Scholar
class
Scholar
class
BibTeXConverter
<
Converter
class
BibTeXConverter
<
Converter
safe
true
safe
true
priority
:highest
priority
:highest
attr_reader
:config
@pattern
=
(
/bib(tex)?$/i
).
freeze
@pattern
=
(
/bib(tex)?$/i
).
freeze
@extension
=
'.html'
.
freeze
@extension
=
'.html'
.
freeze
...
@@ -12,10 +13,10 @@ module Jekyll
...
@@ -12,10 +13,10 @@ module Jekyll
attr_reader
:pattern
,
:extension
attr_reader
:pattern
,
:extension
end
end
def
initialize
(
config
=
{})
def
initialize
(
config
=
{})
super
super
@config
[
'scholar'
]
=
Scholar
.
defaults
.
merge
(
@config
[
'scholar'
]
||
{})
@config
[
'scholar'
]
=
Scholar
.
defaults
.
merge
(
@config
[
'scholar'
]
||
{})
@markdown
=
MarkdownConverter
.
new
config
@markdown
=
MarkdownConverter
.
new
(
config
)
end
end
def
matches
(
extension
)
def
matches
(
extension
)
...
@@ -26,15 +27,16 @@ module Jekyll
...
@@ -26,15 +27,16 @@ module Jekyll
BibTeXConverter
.
extension
BibTeXConverter
.
extension
end
end
def
convert
(
content
)
def
convert
(
content
)
content
=
BibTeX
.
parse
(
content
,
:strict
=>
true
,
:include
=>
[
:meta_content
],
:filter
=>
[
:latex
]).
map
do
|
b
|
content
=
BibTeX
.
parse
(
content
,
:strict
=>
true
,
:include
=>
[
:meta_content
],
:filter
=>
[
:latex
]).
map
do
|
b
|
if
b
.
respond_to?
(
:to_citeproc
)
if
b
.
respond_to?
(
:to_citeproc
)
CiteProc
.
process
b
.
to_citeproc
,
:style
=>
@
config
[
'style'
],
CiteProc
.
process
b
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
@
config
[
'locale'
],
:format
=>
'html'
:locale
=>
config
[
'locale'
],
:format
=>
'html'
else
else
b
.
is_a?
(
BibTeX
::
MetaContent
)
?
b
.
to_s
:
''
b
.
is_a?
(
BibTeX
::
MetaContent
)
?
b
.
to_s
:
''
end
end
end
end
@markdown
.
convert
(
content
.
join
(
"
\n
"
))
@markdown
.
convert
(
content
.
join
(
"
\n
"
))
end
end
...
...
lib/jekyll/scholar/generators/details.rb
View file @
80e27522
...
@@ -50,7 +50,7 @@ module Jekyll
...
@@ -50,7 +50,7 @@ module Jekyll
@config
=
Scholar
.
defaults
.
merge
(
site
.
config
[
'scholar'
]
||
{})
@config
=
Scholar
.
defaults
.
merge
(
site
.
config
[
'scholar'
]
||
{})
if
site
.
layouts
.
key?
(
File
.
basename
(
config
[
'details_layout'
],
'.html'
))
if
site
.
layouts
.
key?
(
File
.
basename
(
config
[
'details_layout'
],
'.html'
))
bibliography
.
each
do
|
entry
|
bibliography
[
config
[
'query'
]]
.
each
do
|
entry
|
details
=
Details
.
new
(
site
,
site
.
source
,
config
[
'details_dir'
],
entry
)
details
=
Details
.
new
(
site
,
site
.
source
,
config
[
'details_dir'
],
entry
)
details
.
render
(
site
.
layouts
,
site
.
site_payload
)
details
.
render
(
site
.
layouts
,
site
.
site_payload
)
details
.
write
(
site
.
dest
)
details
.
write
(
site
.
dest
)
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
80e27522
...
@@ -42,7 +42,7 @@ module Jekyll
...
@@ -42,7 +42,7 @@ module Jekyll
end
end
def
entries
def
entries
b
=
bibliography
[
'@*
'
]
b
=
bibliography
[
config
[
'query
'
]
]
unless
config
[
'sort_by'
]
==
'none'
unless
config
[
'sort_by'
]
==
'none'
b
.
sort_by!
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
.
sort_by!
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
...
...
lib/jekyll/scholar/utilities.rb
0 → 100644
View file @
80e27522
module
Jekyll
class
Scholar
module
Utilities
end
end
end
\ No newline at end of file
Write
Preview
Supports
Markdown
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