From 129fcefa9eefad6c3e3f89afd1ad810da3d227b2 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Thu, 13 Jun 2024 17:52:56 +0200 Subject: [PATCH] Fix people page --- _data/0_update_people_data.jl | 15 ++++++++------- _data/people.toml | 4 +++- utils.jl | 29 +++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/_data/0_update_people_data.jl b/_data/0_update_people_data.jl index e622144b..cb9dde41 100644 --- a/_data/0_update_people_data.jl +++ b/_data/0_update_people_data.jl @@ -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 diff --git a/_data/people.toml b/_data/people.toml index d12f574f..e899551a 100644 --- a/_data/people.toml +++ b/_data/people.toml @@ -77,14 +77,16 @@ website = "https://cedrictravelletti.github.io/" [sun-bonan] arxiv = "" current = false +destination = """PhD at MPI Madgeburg""" email = "bsun@mpi-magdeburg.mpg.de" 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/" diff --git a/utils.jl b/utils.jl index 9d684ec9..77eb4945 100644 --- a/utils.jl +++ b/utils.jl @@ -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), "-") @@ -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, "") # 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, """""") print(io, """""") print(io, """""") @@ -172,11 +179,21 @@ function people_row(data::AbstractDict; showroom=true) print(io, """$(data["firstname"]) """ * """$(data["name"])""") print(io, """
$(data["position"])""") - print(io, """
Email: """ * - """$(protected_email_link(data["email"]))""") + + if showemail + print(io, """
Email: """ * + """$(protected_email_link(data["email"]))""") + maxsocial += 1 + end if showroom print(io, """
Office: """ * """$(roomlink(data["room"]))""") + maxsocial += 1 + end + if haskey(data, "destination") && showdestination + print(io, """
Now: """ * + """$(data["destination"])""") + maxsocial += 1 end print(io, """""") @@ -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()