Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
jekyll-scholar-extras
Commits
830bc07a
Commit
830bc07a
authored
Jun 25, 2012
by
root
Committed by
Hiren Patel
Jun 25, 2012
Browse files
customize cite
parent
bd1cceb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
23 deletions
+85
-23
lib/jekyll/scholar/extras.rb
lib/jekyll/scholar/extras.rb
+1
-0
lib/jekyll/scholar/extras/extra_utils.rb
lib/jekyll/scholar/extras/extra_utils.rb
+57
-23
lib/jekyll/scholar/tags/cite_details.rb
lib/jekyll/scholar/tags/cite_details.rb
+27
-0
No files found.
lib/jekyll/scholar/extras.rb
View file @
830bc07a
...
...
@@ -3,3 +3,4 @@ require 'jekyll/scholar/extras/extra_utils'
require
'jekyll/scholar/extras/bibliography_hdp'
require
'jekyll/scholar/extras/bibliography_bytype'
require
'jekyll/scholar/extras/details_hdp'
require
'jekyll/scholar/tags/cite_details'
lib/jekyll/scholar/extras/extra_utils.rb
View file @
830bc07a
module
Jekyll
class
ScholarExtras
module
Utilities
attr_reader
:bibtex_file
,
:config
,
:site
def
bibtex_options
@bibtex_options
||=
{
:filter
=>
:latex
}
end
@bibtex_options
||=
{
:filter
=>
:latex
}
end
def
bibtex_path
@bibtex_path
||=
extend_path
(
bibtex_file
)
end
def
bibliography
@bibliography
||=
BibTeX
.
open
(
bibtex_path
,
bibtex_options
)
end
def
get_entries
(
and_list
)
b
=
bibliography
[
'@*'
]
and_list
.
each
{
|
t
|
b
=
bibliography
[
t
]
&
b
}
puts
b
.
length
unless
config
[
'sort_by'
]
==
'none'
b
.
sort_by!
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
end
b
end
b
end
def
public_journal_entries
def
public_journal_entries
bart
=
bibliography
[
'@article'
]
bpub
=
bibliography
[
'@*[public!=no]'
]
b
=
bart
&
bpub
...
...
@@ -40,27 +40,61 @@ module Jekyll
puts
bart
.
length
puts
bpub
.
length
puts
b
.
length
unless
config
[
'sort_by'
]
==
'none'
b
.
sort_by!
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
end
b
end
b
end
def
public_entries
b
=
bibliography
[
'@*[public!=no]'
]
unless
config
[
'sort_by'
]
==
'none'
b
.
sort_by!
{
|
e
|
e
[
config
[
'sort_by'
]].
to_s
}
b
.
reverse!
if
config
[
'order'
]
=~
/^(desc|reverse)/i
end
b
end
b
end
def
details_file_for
(
entry
)
name
=
entry
.
key
.
to_s
.
dup
name
.
gsub!
(
/[:\s]+/
,
'_'
)
[
name
,
'html'
].
join
(
'.'
)
end
def
details_link_for
(
entry
,
base
=
base_url
)
[
base
,
details_path
,
details_file_for
(
entry
)].
join
(
'/'
)
end
def
base_url
@base_url
||=
site
.
config
[
'baseurl'
]
||
site
.
config
[
'base_url'
]
||
nil
end
def
details_path
config
[
'details_dir'
]
end
def
cite
(
key
)
entry
=
bibliography
[
key
]
if
bibliography
.
key?
(
key
)
citation
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
,
:mode
=>
:citation
link_to
"#
#{
entry
.
key
}
"
,
citation
.
join
else
"(missing reference)"
end
end
end
end
end
lib/jekyll/scholar/tags/cite_details.rb
0 → 100644
View file @
830bc07a
module
Jekyll
class
Scholar
class
CiteTagDetails
<
Liquid
::
Tag
include
Scholar
::
Utilities
include
ScholarExtras
::
Utilities
attr_reader
:key
,
:pages
def
initialize
(
tag_name
,
arguments
,
tokens
)
super
@config
=
Scholar
.
defaults
.
dup
@key
=
arguments
.
strip
.
split
(
/\s+/
)[
0
]
end
def
render
(
context
)
set_context_to
context
cite_details
key
end
end
end
end
Liquid
::
Template
.
register_tag
(
'cite_details'
,
Jekyll
::
Scholar
::
CiteTagDetails
)
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