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
56208901
Commit
56208901
authored
Jul 15, 2012
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added css classes to bibliography and links
parent
2b984387
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
34 deletions
+48
-34
features/details.feature
features/details.feature
+1
-1
lib/jekyll/scholar/defaults.rb
lib/jekyll/scholar/defaults.rb
+3
-0
lib/jekyll/scholar/tags/bibliography.rb
lib/jekyll/scholar/tags/bibliography.rb
+16
-7
lib/jekyll/scholar/utilities.rb
lib/jekyll/scholar/utilities.rb
+28
-26
No files found.
features/details.feature
View file @
56208901
...
@@ -74,4 +74,4 @@ Feature: BibTeX
...
@@ -74,4 +74,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/scholar.html"
file should exist
And
the
"_site/scholar.html"
file should exist
And
I should see
"<a
href=\"
/bibliography/ruby.html\">" in
"_site/scholar.html"
And
I should see
"<a
[^>]+
href=\"
/bibliography/ruby.html\">" in
"_site/scholar.html"
lib/jekyll/scholar/defaults.rb
View file @
56208901
...
@@ -15,6 +15,9 @@ module Jekyll
...
@@ -15,6 +15,9 @@ module Jekyll
details_layout bibtex.html
details_layout bibtex.html
details_link Details
details_link Details
bibliography_class bibliography
details_link_class details
query @*
query @*
}
].
freeze
}
].
freeze
...
...
lib/jekyll/scholar/tags/bibliography.rb
View file @
56208901
...
@@ -17,21 +17,30 @@ module Jekyll
...
@@ -17,21 +17,30 @@ module Jekyll
references
=
entries
.
map
do
|
entry
|
references
=
entries
.
map
do
|
entry
|
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
reference
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
:locale
=>
config
[
'locale'
],
:format
=>
'html'
reference
=
content_tag
:span
,
reference
,
:id
=>
entry
.
key
reference
=
content_tag
:span
,
reference
,
:id
=>
entry
.
key
if
generate_details?
if
generate_details?
reference
<<
link_to
(
details_link_for
(
entry
),
config
[
'details_link'
])
reference
<<
link_to
(
details_link_for
(
entry
),
config
[
'details_link'
],
:class
=>
config
[
'details_link_class'
])
end
end
content_tag
:li
,
reference
content_tag
:li
,
reference
end
end
content_tag
:ol
,
references
.
join
(
"
\n
"
)
content_tag
:ol
,
references
.
join
(
"
\n
"
),
:class
=>
config
[
'bibliography_class'
]
end
end
end
end
private
def
citeproc
@citeproc
||=
CiteProc
::
Processor
.
new
do
|
p
|
p
.
style
=
config
[
'style'
]
p
.
format
=
'html'
p
.
locale
=
config
[
'locale'
]
end
end
end
end
end
end
...
...
lib/jekyll/scholar/utilities.rb
View file @
56208901
module
Jekyll
module
Jekyll
class
Scholar
class
Scholar
# Utility methods used by several Scholar plugins. The methods in this
# Utility methods used by several Scholar plugins. The methods in this
# module may depend on the presence of #config, #bibtex_file, and
# module may depend on the presence of #config, #bibtex_file, and
# #site readers
# #site readers
module
Utilities
module
Utilities
attr_reader
:bibtex_file
,
:config
,
:site
attr_reader
:bibtex_file
,
:config
,
:site
def
bibtex_options
def
bibtex_options
@bibtex_options
||=
{
:filter
=>
:latex
}
@bibtex_options
||=
{
:filter
=>
:latex
}
end
end
def
bibtex_path
def
bibtex_path
@bibtex_path
||=
extend_path
(
bibtex_file
)
@bibtex_path
||=
extend_path
(
bibtex_file
)
end
end
def
bibliography
def
bibliography
@bibliography
||=
BibTeX
.
open
(
bibtex_path
,
bibtex_options
)
@bibliography
||=
BibTeX
.
open
(
bibtex_path
,
bibtex_options
)
end
end
def
entries
def
entries
b
=
bibliography
[
config
[
'query'
]]
b
=
bibliography
[
config
[
'query'
]]
...
@@ -27,83 +27,85 @@ module Jekyll
...
@@ -27,83 +27,85 @@ module Jekyll
b
=
b
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
=
b
.
sort_by
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
b
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
end
end
b
b
end
end
def
extend_path
(
name
)
def
extend_path
(
name
)
if
name
.
nil?
||
name
.
empty?
if
name
.
nil?
||
name
.
empty?
name
=
config
[
'bibliography'
]
name
=
config
[
'bibliography'
]
end
end
p
=
File
.
join
(
config
[
'source'
],
name
)
p
=
File
.
join
(
config
[
'source'
],
name
)
p
<<
'.bib'
unless
File
.
exists?
(
p
)
p
<<
'.bib'
unless
File
.
exists?
(
p
)
p
p
end
end
def
generate_details?
def
generate_details?
site
.
layouts
.
key?
(
File
.
basename
(
config
[
'details_layout'
],
'.html'
))
site
.
layouts
.
key?
(
File
.
basename
(
config
[
'details_layout'
],
'.html'
))
end
end
def
details_file_for
(
entry
)
def
details_file_for
(
entry
)
name
=
entry
.
key
.
to_s
.
dup
name
=
entry
.
key
.
to_s
.
dup
name
.
gsub!
(
/[:\s]+/
,
'_'
)
name
.
gsub!
(
/[:\s]+/
,
'_'
)
[
name
,
'html'
].
join
(
'.'
)
[
name
,
'html'
].
join
(
'.'
)
end
end
def
details_link_for
(
entry
,
base
=
base_url
)
def
details_link_for
(
entry
,
base
=
base_url
)
File
.
join
(
base
,
details_path
,
details_file_for
(
entry
))
File
.
join
(
base
,
details_path
,
details_file_for
(
entry
))
end
end
def
base_url
def
base_url
@base_url
||=
site
.
config
[
'baseurl'
]
||
site
.
config
[
'base_url'
]
||
''
@base_url
||=
site
.
config
[
'baseurl'
]
||
site
.
config
[
'base_url'
]
||
''
end
end
def
details_path
def
details_path
config
[
'details_dir'
]
config
[
'details_dir'
]
end
end
def
cite
(
key
)
def
cite
(
key
)
entry
=
bibliography
[
key
]
entry
=
bibliography
[
key
]
if
bibliography
.
key?
(
key
)
if
bibliography
.
key?
(
key
)
citation
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
citation
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
,
:mode
=>
:citation
:locale
=>
config
[
'locale'
],
:format
=>
'html'
,
:mode
=>
:citation
link_to
"#
#{
entry
.
key
}
"
,
citation
.
join
link_to
"#
#{
entry
.
key
}
"
,
citation
.
join
else
else
"(missing reference)"
"(missing reference)"
end
end
rescue
"(
#{
key
}
)"
end
end
def
content_tag
(
name
,
content_or_attributes
,
attributes
=
{})
def
content_tag
(
name
,
content_or_attributes
,
attributes
=
{})
if
content_or_attributes
.
is_a?
(
Hash
)
if
content_or_attributes
.
is_a?
(
Hash
)
content
,
attributes
=
nil
,
content_or_attributes
content
,
attributes
=
nil
,
content_or_attributes
else
else
content
=
content_or_attributes
content
=
content_or_attributes
end
end
attributes
=
attributes
.
map
{
|
k
,
v
|
%Q(
#{
k
}
="
#{
v
}
")
}
attributes
=
attributes
.
map
{
|
k
,
v
|
%Q(
#{
k
}
="
#{
v
}
")
}
if
content
.
nil?
if
content
.
nil?
"<
#{
[
name
,
attributes
].
flatten
.
compact
.
join
(
' '
)
}
/>"
"<
#{
[
name
,
attributes
].
flatten
.
compact
.
join
(
' '
)
}
/>"
else
else
"<
#{
[
name
,
attributes
].
flatten
.
compact
.
join
(
' '
)
}
>
#{
content
}
</
#{
name
}
>"
"<
#{
[
name
,
attributes
].
flatten
.
compact
.
join
(
' '
)
}
>
#{
content
}
</
#{
name
}
>"
end
end
end
end
def
link_to
(
href
,
content
,
attributes
=
{})
def
link_to
(
href
,
content
,
attributes
=
{})
content_tag
:a
,
content
||
href
,
attributes
.
merge
(
:href
=>
href
)
content_tag
:a
,
content
||
href
,
attributes
.
merge
(
:href
=>
href
)
end
end
def
set_context_to
(
context
)
def
set_context_to
(
context
)
@site
=
context
.
registers
[
:site
]
@site
=
context
.
registers
[
:site
]
config
.
merge!
(
site
.
config
[
'scholar'
]
||
{})
config
.
merge!
(
site
.
config
[
'scholar'
]
||
{})
end
end
end
end
end
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