Skip to content

Commit

Permalink
Fix people page
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed Jun 13, 2024
1 parent cecc908 commit 129fcef
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
15 changes: 8 additions & 7 deletions _data/0_update_people_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ function get_csv_data()
end

function augment_defaults!(data::AbstractDict)
get!(data, "priority", 0)
get!(data, "website", "https://people.epfl.ch/$(data["sciper"])")
get!(data, "gscholar", "")
get!(data, "orcid", "")
get!(data, "arxiv", "")
get!(data, "github", "")
get!(data, "current", true)
get!(data, "priority", 0)
get!(data, "website", "https://people.epfl.ch/$(data["sciper"])")
get!(data, "gscholar", "")
get!(data, "orcid", "")
get!(data, "arxiv", "")
get!(data, "github", "")
get!(data, "destination", "")
get!(data, "current", true)
data
end

Expand Down
4 changes: 3 additions & 1 deletion _data/people.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ website = "https://cedrictravelletti.github.io/"
[sun-bonan]
arxiv = ""
current = false
destination = """PhD at <a href="https://www.mpi-magdeburg.mpg.de/">MPI Madgeburg</a>"""
email = "[email protected]"
firstname = "Bonan"
github = "bonans"
gscholar = ""
image = "sun-bonan"
name = "Sun"
orcid = "0009-0002-2761-0661"
position = "Master Student"
priority = 20
room = ""
sciper = 000000
sciper = 999999
website = "https://bonans.github.io/"
29 changes: 23 additions & 6 deletions utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function hfun_newsheader()
end

function normalised_from_email(s::AbstractString)
@assert endswith(s, "@epfl.ch")
beginning = split(s, "@")[1]
components = split(beginning, ".")
join(reverse(components), "-")
Expand Down Expand Up @@ -156,14 +157,20 @@ function social_imagelink(key, value)
String(take!(io))
end

function people_row(data::AbstractDict; showroom=true)
maxsocial = showroom ? 4 : 3
function people_row(data::AbstractDict; showroom=true, showemail=true, showdestination=true)
maxsocial = 2

io = IOBuffer()
print(io, "<tr>")

# Profile picture
imgkey = normalised_from_email(data["email"])
if haskey(data, "image")
imgkey = data["image"]
elseif endswith(data["email"], "@epfl.ch")
imgkey = normalised_from_email(data["email"])
else
error("Need to either have an epfl email or specify the 'image' key")
end
print(io, """<td><a href="$(data["website"])">""")
print(io, """<img class="profile-img" src="/assets/people/$imgkey.jpg" />""")
print(io, """</a></td>""")
Expand All @@ -172,11 +179,21 @@ function people_row(data::AbstractDict; showroom=true)
print(io, """<td><strong><a href="$(data["website"])">$(data["firstname"]) """ *
"""$(data["name"])</a></strong>""")
print(io, """<br />$(data["position"])""")
print(io, """<br /><span class="weak-text">Email:</span> """ *
"""$(protected_email_link(data["email"]))""")

if showemail
print(io, """<br /><span class="weak-text">Email:</span> """ *
"""$(protected_email_link(data["email"]))""")
maxsocial += 1
end
if showroom
print(io, """<br /><span class="weak-text">Office:</span> """ *
"""$(roomlink(data["room"]))""")
maxsocial += 1
end
if haskey(data, "destination") && showdestination
print(io, """<br /><span class="weak-text">Now:</span> """ *
"""$(data["destination"])""")
maxsocial += 1
end
print(io, """</td>""")

Expand All @@ -199,7 +216,7 @@ function people_row(data::AbstractDict; showroom=true)
end

function hfun_people_table()
data = open(TOML.parse, "_data/people.toml", "r")
data = open(TOML.parse, "_data/people.toml", "r")
people = sort(collect(values(data)), by=d -> (get(d, "priority", 0), d["name"]))

io = IOBuffer()
Expand Down

0 comments on commit 129fcef

Please sign in to comment.