Refactor typst cv generation to make use of generalized entries

This commit is contained in:
Marty Oehme 2024-09-15 17:56:18 +02:00
parent d518eb9087
commit e53d5ca386
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

138
cv.typ
View file

@ -32,31 +32,6 @@
] ]
} }
// Feel free to change the margin below to best fit your own CV
#set page(
paper: "a4",
margin: (x: 0.9cm, y: 1.3cm),
footer: [
#set text(
fill: luma(200),
size: 8pt,
)
#_columns_3[
#smallcaps[#datetime.today().display("[month repr:long] [day], [year]")]
][
#smallcaps[
Marty Oehme
// #sym.dot.c
// CV
]
][
#counter(page).display()
]
],
)
#set par(justify: true)
#let header(about, columns: (1.5fr, 1fr, 1fr)) = { #let header(about, columns: (1.5fr, 1fr, 1fr)) = {
[= #about.fullname]; [= #about.fullname];
let contact_fields = (for c in about.contact { let contact_fields = (for c in about.contact {
@ -73,41 +48,63 @@
); );
} }
#let horizon_line() = {v(-3pt); line(length: 100%); v(-5pt)} #let subdued(body) = {
block(inset: 5%, width: 85%, text(fill:luma(150), body))
}
#let section_header(title) = {[== #title]; horizon_line()}; #let entry(item: ()) = {
if "title" in item {
#let section(title: "Section", body) = { [*#item.title.at(lang)*]
section_header(title); }
body if "place" in item {
}; if "title" in item {
[, ]
#let work_item(item: ()) = { }
if "client" in item { [_#item.place.at(lang)_]
[*#item.title.at(lang)*, _#item.client.at(lang)_ #h(1fr)]; }
} else { [#h(1fr)]
[*#item.title.at(lang)* #h(1fr)]; if "date" in item {
}; [ _#item.date.at(lang)_ \ ]
[ _#item.date.at(lang)_ \ ]; }
if "bullets" in item { if "bullets" in item {
for bullet in item.bullets { for bullet in item.bullets {
[- #bullet.at(lang)] [- #bullet.at(lang)]
} }
} }
if "publication" in item { if "publication" in item {
block(inset: 5%, width: 85%, text(fill:luma(150))[#item.publication.at(lang) \ ]) subdued[#item.publication.at(lang) \ ]
}; };
if "abstract" in item {
subdued[#item.abstract.at(lang) \ ]
}
} }
#let education_item(item: ()) = { #let horizon_line() = {v(-3pt); line(length: 100%); v(-5pt)}
assert("place" in item and "program" in item and "date" in item, message: "Education items require place, program and date.");
[*#item.place.at(lang)*, #item.program.at(lang) #h(1fr)]; #let section_header(title) = {[== #title]; horizon_line()};
#let section(title: "Section", entries: (), body) = {
section_header(title);
if body == none or body == [] {
for e in entries {
entry(item:e)
}
} else {
body
}
};
// Slightly re-styled entry with PLACE first and TITLE second
#let education_entry(item: ()) = {
assert("place" in item and "title" in item and "date" in item, message: "Education items require place, program and date.");
[*#item.place.at(lang)*, #item.title.at(lang) #h(1fr)];
[ _#item.date.at(lang)_ \ ]; [ _#item.date.at(lang)_ \ ];
} }
#let thesis_item(item: ()) = { // Restyled entry with PLACE not emphasized like usual, and no date but an abstract
assert("type" in item and "title" in item, message: "Thesis items require type and title."); #let thesis_entry(item: ()) = {
[*#item.type.at(lang)* #item.title.at(lang) #h(1fr)]; assert("title" in item and "place" in item, message: "Thesis items require type and title.");
[*#item.title.at(lang)* #item.place.at(lang) #h(1fr)];
[#par(item.abstract.at(lang))] [#par(item.abstract.at(lang))]
} }
@ -119,6 +116,7 @@
} }
} }
// Old-style presentation of skills and qualifications, to be overhauled
#let skill_item(item: ()) = { #let skill_item(item: ()) = {
[*#item.at(lang)*: \ ] [*#item.at(lang)*: \ ]
for skill in item.content { for skill in item.content {
@ -133,9 +131,35 @@
} }
} }
#let resume(contents) = { #let resume(contents) = {
// Feel free to change the margin below to best fit your own CV
set page(
paper: "a4",
margin: (x: 0.9cm, y: 1.3cm),
footer: [
#set text(
fill: luma(200),
size: 8pt,
)
#_columns_3[
#smallcaps[#datetime.today().display("[month repr:long] [day], [year]")]
][
#smallcaps[
// FIXME: Source from about.fullname variable
Marty Oehme
// #sym.dot.c
// CV
]
][
#counter(page).display()
]
],
)
set par(justify: true)
header(contents.about) header(contents.about)
if "summary" in contents { if "summary" in contents {
section(title:"", { section(title:"", {
contents.summary.at(lang) contents.summary.at(lang)
@ -144,23 +168,17 @@
if "experience" in contents { if "experience" in contents {
let title = sel_word_lang(en:"Professional Experience", de:"Berufserfahrung") let title = sel_word_lang(en:"Professional Experience", de:"Berufserfahrung")
section(title: title, { section(title: title, entries:contents.experience)[]
for entry in contents.experience {
work_item(item:entry)
}
})
} }
if "education" in contents { if "education" in contents {
let title = sel_word_lang(en:"Education", de:"Ausbildung") let title = sel_word_lang(en:"Education", de:"Ausbildung")
section(title: "Education", { section(title: title, entries:contents.thesis + contents.education)[]
for entry in contents.thesis {
thesis_item(item:entry)
} }
for entry in contents.education {
education_item(item:entry) if "volunteering" in contents {
} let title = sel_word_lang(en:"Volunteer Work", de:"Ehrenamt")
}) section(title: title, entries:contents.volunteering)[]
} }
if "skills" in contents { if "skills" in contents {