-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.jl
99 lines (97 loc) · 3.68 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
using Dates
include("yaml.jl")
include("names.jl")
# The following 3 might depend on yaml and names
include("bib.jl")
include("talks.jl")
include("teaching.jl")
#
# Infoblock on projects
#
#
# Overview projects
#
function hfun_projectslist()
project_files = filter!(x -> endswith(x, ".md") && x != "index.md", readdir("projects"))
# collect dates
projects = [
Dict{String, Union{Nothing, String, Vector{String},Bool}}(
push!(
Pair{String,Union{Nothing, String, Vector{String},Bool}}[
var => pagevar("projects/$project", var) for var ∈ ["title", "subtitle", "collaborators", "end", "logo", "more", "start", "summary", "url", "url_text"]
],
"project" => project[1:end-3], # remove md
)
)
for project ∈ project_files
]
sorted_projects = sort(projects, lt = (a,b) -> isnothing(a["end"]) && !isnothing(b["end"]) || isnothing(a["end"]) && ( isnothing(a["start"]) && !isnothing(b["start"]) || Date(a["start"]) > Date(b["start"])) || !isnothing(a["end"]) && !isnothing(b["end"]) && (Date(a["end"]) > Date(b["end"])) )
s = ""
for project in sorted_projects
logospan = isnothing(project["logo"]) ? "" : """
<span class="logo"><img src="../assets/projects/$(project["logo"])"/></span>
"""
coll = ""
if !isnothing(project["collaborators"])
coll = """<span class="collaborators">
<ul>
<li>
$(join([ hfun_person([name, "link_shortname_fnorcid"]) for name in project["collaborators"]], "</li>\n<li>"))</li>
</ul>
"""
end
subtitlespan = ""
if !isnothing(project["subtitle"])
subtitlespan = """<span class="subtitle">$(project["subtitle"])</span>
"""
end
timespan = Dates.format(Date(project["start"]),"yyyy")
if !isnothing(project["end"])
timespan = """<span class="timespan">
$(timespan)—$(Dates.format(Date(project["end"]),"yyyy"))
</span>
"""
else
timespan = """<span class="timespan">
since $(timespan)
</span>
"""
end
urlspan = ""
if !isnothing(project["url"])
urltext = !isnothing(project["url_text"]) ? project["url_text"] : project["url"]
urlspan = """<span class="link"><a href="$(project["url"])">$(urltext)</a></span>"""
end
morelink = ""
if isnothing(project["more"]) || project["more"]
morelink = """<span class="more"><a href="$(project["project"])/">more>></a></span>"""
end
s = """$s<dt>
<span class="title">$(project["title"])</span>
$(subtitlespan)
</dt>
<dd>
<div class="info">
$logospan
$urlspan
$timespan
$coll
</div>
$(!(isnothing(project["summary"])) ? fd2html(project["summary"]; internal=true) : "")
$morelink
</dd>
"""
end
return """<dl class="projectlist">
$s
</dl>
"""
#= for post in first.(splitext.(posts))
url = splitext("/blog/$post/")[1]
title = pagevar(strip(url, '/'), :title)
date = Date(post[1:10])
date ≤ today() && write(io, "\n[$title]($url) $date \n")
end
return Franklin.fd2html(String(take!(io)), internal=true)
=#
end