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
80e27522
Commit
80e27522
authored
Apr 30, 2012
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added filter/query settings
#1
parent
ee753709
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
12 deletions
+72
-12
features/details.feature
features/details.feature
+1
-1
features/filter.feature
features/filter.feature
+39
-0
features/step_definitions/jekyll_steps.rb
features/step_definitions/jekyll_steps.rb
+6
-0
lib/jekyll/scholar.rb
lib/jekyll/scholar.rb
+3
-0
lib/jekyll/scholar/converters/bibtex.rb
lib/jekyll/scholar/converters/bibtex.rb
+9
-7
lib/jekyll/scholar/generators/details.rb
lib/jekyll/scholar/generators/details.rb
+1
-1
lib/jekyll/scholar/tags/bibliography.rb
lib/jekyll/scholar/tags/bibliography.rb
+3
-3
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+10
-0
No files found.
features/details.feature
View file @
80e27522
...
...
@@ -34,4 +34,4 @@ Feature: BibTeX
When
I run jekyll
Then
the _site directory 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|
end
Then
/^I should see "(.*)" in "(.*)"$/
do
|
text
,
file
|
puts
File
.
open
(
file
).
readlines
.
join
assert_match
Regexp
.
new
(
text
),
File
.
open
(
file
).
readlines
.
join
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
|
assert
File
.
file?
(
file
)
end
...
...
lib/jekyll/scholar.rb
View file @
80e27522
...
...
@@ -5,6 +5,7 @@ require 'bibtex'
require
'citeproc'
require
'jekyll/scholar/version'
require
'jekyll/scholar/utilities'
require
'jekyll/scholar/converters/bibtex'
require
'jekyll/scholar/tags/bibliography'
require
'jekyll/scholar/tags/cite'
...
...
@@ -27,6 +28,8 @@ module Jekyll
details_dir ./bibliography
details_layout bibtex.html
query @*
}
].
freeze
class
<<
self
...
...
lib/jekyll/scholar/converters/bibtex.rb
View file @
80e27522
...
...
@@ -2,9 +2,10 @@ module Jekyll
class
Scholar
class
BibTeXConverter
<
Converter
safe
true
priority
:highest
attr_reader
:config
@pattern
=
(
/bib(tex)?$/i
).
freeze
@extension
=
'.html'
.
freeze
...
...
@@ -12,10 +13,10 @@ module Jekyll
attr_reader
:pattern
,
:extension
end
def
initialize
(
config
=
{})
def
initialize
(
config
=
{})
super
@config
[
'scholar'
]
=
Scholar
.
defaults
.
merge
(
@config
[
'scholar'
]
||
{})
@markdown
=
MarkdownConverter
.
new
config
@markdown
=
MarkdownConverter
.
new
(
config
)
end
def
matches
(
extension
)
...
...
@@ -26,15 +27,16 @@ module Jekyll
BibTeXConverter
.
extension
end
def
convert
(
content
)
def
convert
(
content
)
content
=
BibTeX
.
parse
(
content
,
:strict
=>
true
,
:include
=>
[
:meta_content
],
:filter
=>
[
:latex
]).
map
do
|
b
|
if
b
.
respond_to?
(
:to_citeproc
)
CiteProc
.
process
b
.
to_citeproc
,
:style
=>
@
config
[
'style'
],
:locale
=>
@
config
[
'locale'
],
:format
=>
'html'
CiteProc
.
process
b
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
else
b
.
is_a?
(
BibTeX
::
MetaContent
)
?
b
.
to_s
:
''
end
end
@markdown
.
convert
(
content
.
join
(
"
\n
"
))
end
...
...
lib/jekyll/scholar/generators/details.rb
View file @
80e27522
...
...
@@ -50,7 +50,7 @@ module Jekyll
@config
=
Scholar
.
defaults
.
merge
(
site
.
config
[
'scholar'
]
||
{})
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
.
render
(
site
.
layouts
,
site
.
site_payload
)
details
.
write
(
site
.
dest
)
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
80e27522
...
...
@@ -42,7 +42,7 @@ module Jekyll
end
def
entries
b
=
bibliography
[
'@*'
]
b
=
bibliography
[
config
[
'query'
]
]
unless
config
[
'sort_by'
]
==
'none'
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
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