-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.jl
153 lines (136 loc) · 3.86 KB
/
utils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using YAML
using Dates
bibliography = YAML.load_file("data/bibliography.yaml")
talks = YAML.load_file("data/talks.yaml")
talks_expanded = collect(talks)
not_j = get.(last.(talks_expanded),"type", "nj") .== "nj"
talks_expanded = talks_expanded[not_j]
talk_names = first.(talks_expanded)
talk_dates = map(x-> Date("$(x["year"])-$(x["month"])", "y-U"), last.(talks_expanded))
_order = sortperm(talk_dates; rev=true)
sorted_talks = talk_names[_order]
icon_dict = Dict(
"arXiv" => ("ai ai-arxiv ai-lg", "arXiv"),
"book" => ("las la-book la-lg", "Book chapter"),
"openaccess" => ("ai ai-open-access ai-lg", "Journal paper"),
"closedaccess" => ("ai ai-closed-access ai-lg", "Journal paper"),
"conference" => ("ai ai-open-access ai-lg", "Conference paper"),
"julia_package" => ("icon-julia-dots", "Julia package"),
"reproduction_code" => ("las la-code la-lg", "Reproduction code"),
"bioRxiv" => ("ai ai-biorxiv ai-lg", "bioRxiv"),
"r_package" => ("lab la-r-project la-lg", "R package"),
"poster" => ("las la-chalkboard la-lg", "Poster"),
"video" => ("lab la-youtube la-lg", "Video"),
"slides" => ("las la-file-pdf la-lg", "Pdf slides"),
"link" => ("las la-external-link-alt la-lg", "Link")
)
function tooltip_code(url, class)
dict_entry = icon_dict[class]
class_text = dict_entry[1]
tooltip_text = dict_entry[2]
"""
<span class="tooltip">
<a href=$(url)><i class="$(class_text)"></i></a>
<span class="tooltiptext">$(tooltip_text)</span>
</span>
"""
end
function bibprint(yamlkey)
entry = bibliography[yamlkey]
names = join(["""<span class="person">$name</span>""" for name ∈ entry["author"] ], ", ")
year = """<span class="year">$(entry["year"])</span>"""
title = """<span class="title">$(entry["title"]).</span>"""
journal = """<span class="journal">$(entry["journal"]).</span>"""
html_string = """
<li>
$(names)
$(year)<br>
$(title)<br>
$(journal)<br>
"""
if haskey(entry, "note")
html_string = """
$(html_string)
<i> $(entry["note"]) </i> <br>
"""
end
bibkey_order = ["openaccess";
"closedaccess";
"conference";
"book";
"arXiv";
"bioRxiv";
"poster";
"reproduction_code";
"julia_package";
"r_package"]
for key in bibkey_order
if haskey(entry, key)
html_string = """
$(html_string)
$(tooltip_code(entry[key], key))
"""
end
end
html_string = """
$(html_string)
</li>
""";
html_string
end
function hfun_bibliographyprint(yamlkeys)
keys = locvar(yamlkeys[1])
html_string = """<ol>"""
for key in keys
html_string = """
$(html_string)
$(bibprint(key))
"""
end
"""
$(html_string)
</ol>
"""
end
function talkprint(yamlkey)
entry = talks[yamlkey]
title = """<span class="title">$(entry["title"]).</span>"""
event = "$(entry["event"])"
date_location = "$(entry["month"]) $(entry["year"]), $(entry["location"])"
html_string = """
<li>
$(title)<br>
$(event)<br>
$(date_location)<br>
"""
bibkey_order = ["link";
"video";
"slides"]
for key in bibkey_order
if haskey(entry, key)
html_string = """
$(html_string)
$(tooltip_code(entry[key], key))
"""
end
end
html_string = """
$(html_string)
</li>
<br>
""";
html_string
end
function hfun_alltalksprint()
html_string = """<ul>"""
for key in sorted_talks
html_string = """
$(html_string)
$(talkprint(key))
"""
end
"""
$(html_string)
</ul>
"""
end