refactor: add a helper function to add an H1 element

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-08-16 11:57:59 +03:00
parent 39b5c0a2fe
commit 404a8dcd97
+7 -3
View File
@@ -121,7 +121,7 @@ impl PageData {
doc.push_to_body(Element::new(Tag::H1).with_text(&title));
doc.push_to_body(Element::new(Tag::H2).with_text("Broker status"));
Self::h1(&mut doc, "Broker status");
doc.push_to_body(
Element::new(Tag::P)
.with_text("Last updated: ")
@@ -134,7 +134,7 @@ impl PageData {
.with_text(")"),
);
doc.push_to_body(Element::new(Tag::H2).with_text("Repositories"));
Self::h1(&mut doc, "Repositories");
doc.push_to_body(Element::new(Tag::P).with_text("Latest CI run for each repository."));
@@ -226,7 +226,7 @@ impl PageData {
}
doc.push_to_body(list);
doc.push_to_body(Element::new(Tag::H2).with_text("Recent status"));
Self::h1(&mut doc, "Recent status");
let status = StatusData::from(self).as_json()?;
doc.push_to_body(
Element::new(Tag::P)
@@ -255,6 +255,10 @@ impl PageData {
);
}
fn h1(page: &mut HtmlPage, text: &str) {
page.push_to_body(Element::new(Tag::H2).with_text(text));
}
fn whence_as_html(whence: &Whence) -> Element {
match whence {
Whence::Branch {