if super-long station names get trendy, our fancy station overview pdf can handle them now... except if there is no whitespace :O
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m22s
CI/CD Pipeline / deploy (push) Successful in 6m31s

This commit is contained in:
Philipp Hofer 2025-04-21 20:14:56 +02:00
parent 6c36e534b9
commit a0614726cc

View File

@ -21,6 +21,14 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
#let card_width = 105mm // A4 width (210mm) divided by 2 #let card_width = 105mm // A4 width (210mm) divided by 2
#let card_height = 74.25mm // A4 height (297mm) divided by 4 #let card_height = 74.25mm // A4 height (297mm) divided by 4
#let trimstring(text, max-length) = {
if text.len() <= max-length {
text
} else {
text.slice(0, max-length - 3) + "..."
}
}
// Custom function to create a card with title and QR code for a URL // Custom function to create a card with title and QR code for a URL
#let create_url_card(title, url) = { #let create_url_card(title, url) = {
box( box(
@ -33,9 +41,9 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
), ),
[ [
#align(center + horizon)[ #align(center + horizon)[
#text(weight: "bold", size: 14pt)[Station #title] #text(weight: "bold", size: 14pt)[Station #trimstring(title, 100)]
#qr-code(url, width: 4cm) #qr-code(url, width: 4cm)
#text(size: 8pt)[#link(url)] #text(size: 11pt)[#link(url)]
] ]
] ]
) )