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-extras
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
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
caesr-pub
jekyll-scholar-extras
Commits
8ba03602
Commit
8ba03602
authored
Feb 07, 2016
by
rmrf
Committed by
Hiren Patel
Feb 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting to up the version to match jekyll-scholar-5.7.x
parent
82067329
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
239 additions
and
42 deletions
+239
-42
lib/jekyll/scholar/extras.rb
lib/jekyll/scholar/extras.rb
+2
-2
lib/jekyll/scholar/extras/bibliography_bytype.rb
lib/jekyll/scholar/extras/bibliography_bytype.rb
+93
-40
lib/jekyll/scholar/extras/bibliography_year.rb
lib/jekyll/scholar/extras/bibliography_year.rb
+144
-0
No files found.
lib/jekyll/scholar/extras.rb
View file @
8ba03602
require
'jekyll/scholar'
require
'jekyll/scholar/extras/extra_utils'
#
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/extras/details_hdp'
#require 'jekyll/scholar/tags/cite_details_dep'
lib/jekyll/scholar/extras/bibliography_bytype.rb
View file @
8ba03602
module
Jekyll
class
Scholar
class
Bibliography
HDPByTypeTag
<
Liquid
::
Tag
class
Bibliography
TagByType
<
Liquid
::
Tag
include
Scholar
::
Utilities
include
ScholarExtras
::
Utilities
attr_reader
:type
,
:header
,
:arr_args
def
initialize
(
tag_name
,
arguments
,
tokens
)
super
@config
=
Scholar
.
defaults
.
dup
# Check for number of arguments.
#@arr_args = arguments.strip.split(/\s+/)
@type
,
@header
=
arguments
.
strip
.
split
(
/\s*,\s*/
,
2
)
#@type= arr_args[0]
#@header = arr_args[1]
optparse
(
arguments
)
end
def
initialize_type_labels
()
@type_labels
=
Hash
[{
"@article"
=>
"Journal Articles"
,
"@inproceedings"
=>
"Conference and Workshop Papers"
,
"@incollection"
=>
"Book Chapters"
,
"@techreport"
=>
"Technical Reports"
,
"@book"
=>
"Books"
}]
end
def
initialize_prefix_defaults
()
@prefix_defaults
=
Hash
[{
:article
=>
"J"
,
:inproceedings
=>
"C"
,
:incollection
=>
"BC"
,
:techreport
=>
"TR"
,
:book
=>
"B"
}]
end
def
set_type_counts
(
tc
)
@type_counts
=
tc
end
def
render_index
(
item
,
ref
)
si
=
'['
+
@prefix_defaults
[
item
.
type
].
to_s
+
@type_counts
.
to_s
+
']'
@type_counts
=
@type_counts
-
1
idx_html
=
content_tag
"div class=
\"
csl-index
\"
"
,
si
return
idx_html
+
ref
end
def
render_ref_img
(
item
)
css_points
=
Hash
[{
:article
=>
"csl-point-journal-icon"
,
:inproceedings
=>
"csl-point-conference-icon"
,
:incollection
=>
"csl-point-bookchapter-icon"
,
:techreport
=>
"csl-point-techreport-icon"
,
:book
=>
"csl-point-book-icon"
}]
s
=
css_points
[
item
.
type
]
return
s
end
def
render_header
(
y
)
ys
=
content_tag
"h2 class=
\"
csl-year-header
\"
"
,
y
ys
=
content_tag
"div class=
\"
csl-year-icon
\"
"
,
ys
end
def
render
(
context
)
set_context_to
context
year_section
=
''
opts
=
[
'@'
+
@type
,
'@*[public!=no]'
]
# Only select items that are public.
items
=
entries
.
select
{
|
e
|
e
.
public
==
'yes'
}
references
=
get_entries
(
opts
).
map
do
|
entry
|
reference
=
''
ref
=
''
initialize_prefix_defaults
()
initialize_type_labels
()
set_type_counts
(
items
.
size
())
ref
=
CiteProc
.
process
entry
.
to_citeproc
,
:style
=>
config
[
'style'
],
:locale
=>
config
[
'locale'
],
:format
=>
'html'
content_tag
:span
,
ref
,
:id
=>
entry
.
key
reference
<<
ref
if
generate_details?
reference
<<
"<br />"
reference
<<
link_to
(
details_link_for
(
entry
),
config
[
'details_link'
])
reference
<<
"."
if
cited_only?
items
=
if
skip_sort?
cited_references
.
uniq
.
map
do
|
key
|
items
.
detect
{
|
e
|
e
.
key
==
key
}
end
else
entries
.
select
do
|
e
|
cited_references
.
include?
e
.
key
end
end
end
if
entry
.
field?
(
:pdflink1
)
or
entry
.
field?
(
:slides
)
reference
<<
"<b> Downloads: </b>"
end
items
=
items
[
offset
..
max
]
if
limit_entries?
if
entry
.
field?
(
:pdflink1
)
reference
<<
"<a href=
\"
"
+
entry
[
:pdflink1
].
to_s
+
"
\"
>PDF</a>"
bibliography
=
render_header
(
@type_labels
[
query
])
bibliography
<<
items
.
each_with_index
.
map
{
|
entry
,
index
|
reference
=
render_index
(
entry
,
bibliography_tag
(
entry
,
nil
))
if
generate_details?
reference
<<
link_to
(
details_link_for
(
entry
),
config
[
'details_link'
],
:class
=>
config
[
'details_link_class'
])
end
if
entry
.
field?
(
:slides
)
reference
<<
"<a href=
\"
"
+
entry
[
:slides
].
to_s
+
"
\"
>Slides</a>"
if
entry
.
field?
(
:award
)
# TODO: Awkward -- Find position to insert it. Before the last </div>
ts
=
content_tag
"div class=
\"
csl-award
\"
"
,
entry
.
award
.
to_s
refPos
=
reference
.
rindex
(
'</div>'
)
if
refPos
.
nil?
puts
"NILL"
else
reference
.
insert
(
reference
.
rindex
(
'</div>'
),
ts
.
to_s
)
end
end
content_tag
:br
,
reference
end
section_header
=
"<h1>
#{
@header
}
</h1>"
references
.
insert
(
0
,
section_header
)
references
.
join
(
"
\n
"
)
content_tag
config
[
'bibliography_item_tag'
]
,
reference
content_tag
"li class=
\"
"
+
render_ref_img
(
entry
)
+
"
\"
"
,
reference
}.
join
(
"
\n
"
)
content_tag
config
[
'bibliography_list_tag'
],
bibliography
,
:class
=>
config
[
'bibliography_class'
]
end
end
end
end
Liquid
::
Template
.
register_tag
(
'bibliography_bytype'
,
Jekyll
::
Scholar
::
Bibliography
HDPByTypeTag
)
Liquid
::
Template
.
register_tag
(
'bibliography_bytype'
,
Jekyll
::
Scholar
::
Bibliography
TagByType
)
lib/jekyll/scholar/extras/bibliography_year.rb
0 → 100644
View file @
8ba03602
module
Jekyll
class
Scholar
class
BibliographyTagYear
<
Liquid
::
Tag
include
Scholar
::
Utilities
def
initialize
(
tag_name
,
arguments
,
tokens
)
super
@config
=
Scholar
.
defaults
.
dup
optparse
(
arguments
)
end
def
initialize_type_counts
()
@type_counts
=
Hash
[{
:article
=>
0
,
:inproceedings
=>
0
,
:incollection
=>
0
,
:techreport
=>
0
,
:book
=>
0
}]
@type_counts
.
keys
.
each
{
|
t
|
bib
=
bibliography
.
query
(
'@*'
)
{
|
b
|
(
b
.
public
==
'yes'
and
b
.
type
==
t
)
}
@type_counts
[
t
]
=
bib
.
size
}
end
def
initialize_type_order
()
@type_order
=
Hash
[{
:article
=>
0
,
:book
=>
0
,
:incollection
=>
0
,
:inproceedings
=>
0
,
:techreport
=>
0
}]
end
def
initialize_prefix_defaults
()
@prefix_defaults
=
Hash
[{
:article
=>
"J"
,
:inproceedings
=>
"C"
,
:incollection
=>
"BC"
,
:techreport
=>
"TR"
,
:book
=>
"B"
}]
end
def
render_ref_img
(
item
)
css_points
=
Hash
[{
:article
=>
"csl-point-journal-icon"
,
:inproceedings
=>
"csl-point-conference-icon"
,
:incollection
=>
"csl-point-bookchapter-icon"
,
:techreport
=>
"csl-point-techreport-icon"
,
:book
=>
"csl-point-book-icon"
}]
s
=
css_points
[
item
.
type
]
return
s
end
def
get_entries_by_type
(
year
,
type
)
b
=
bibliography
.
query
(
'@*'
)
{
|
item
|
(
item
.
year
==
year
and
item
.
type
==
type
)
}
end
def
render_year
(
y
)
ys
=
content_tag
"h2 class=
\"
csl-year-header
\"
"
,
y
ys
=
content_tag
"div class=
\"
csl-year-icon
\"
"
,
ys
# content_tag "h2", y
end
def
render_index
(
item
,
ref
)
si
=
'['
+
@prefix_defaults
[
item
.
type
].
to_s
+
@type_counts
[
item
.
type
].
to_s
+
']'
@type_counts
[
item
.
type
]
=
@type_counts
[
item
.
type
].
to_i
-
1
idx_html
=
content_tag
"div class=
\"
csl-index
\"
"
,
si
return
idx_html
+
ref
end
def
entries_year
(
year
)
b
=
bibliography
.
query
(
'@*'
)
{
|
a
|
(
a
.
year
==
year
and
a
.
public
==
'yes'
)
}
end
def
initialize_unique_years
()
# Get an array of years and then uniquify them.
items
=
entries
arr
=
Array
.
new
items
.
each
{
|
i
|
arr
.
push
(
i
.
year
.
to_s
)
}
@arr_unique
=
arr
.
uniq
end
def
render
(
context
)
set_context_to
context
# Initialize the number of each type of interest.
initialize_type_counts
()
initialize_type_order
()
initialize_prefix_defaults
()
initialize_unique_years
()
# Iterate over unique years, and produce the bib.
bibliography
=
""
@arr_unique
.
each
{
|
y
|
bibliography
<<
render_year
(
y
)
@type_order
.
keys
.
each
{
|
o
|
items
=
entries_year
(
y
).
select
{
|
e
|
e
.
type
==
o
}
bibliography
<<
items
.
each_with_index
.
map
{
|
entry
,
index
|
if
entry
.
type
==
o
then
reference
=
render_index
(
entry
,
bibliography_tag
(
entry
,
nil
))
if
entry
.
field?
(
:award
)
# TODO: Awkward -- Find position to insert it. Before the last </div>
ts
=
content_tag
"div class=
\"
csl-award
\"
"
,
entry
.
award
.
to_s
puts
ts
puts
ts
.
to_s
refPos
=
reference
.
rindex
(
'</div>'
)
if
refPos
.
nil?
puts
"NILL"
else
puts
"INSERT
\n
"
puts
ts
reference
.
insert
(
reference
.
rindex
(
'</div>'
),
ts
.
to_s
)
end
end
# Content tag is dependent on type of article.
content_tag
"li class=
\"
"
+
render_ref_img
(
entry
)
+
"
\"
"
,
reference
end
}.
join
(
"
\n
"
)
}.
join
(
"
\n
"
)
}.
join
(
""
)
return
content_tag
config
[
'bibliography_list_tag'
],
bibliography
,
:class
=>
config
[
'bibliography_class'
]
end
end
end
end
Liquid
::
Template
.
register_tag
(
'bibliography_year'
,
Jekyll
::
Scholar
::
BibliographyTagYear
)
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