refactor: add helper to add the usual stuff to the HEAD element

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-08-16 11:45:15 +03:00
parent 54029ae3e7
commit a34df9980f
+13 -12
View File
@@ -116,18 +116,9 @@ impl PageData {
fn status_page_as_html(&self) -> Result<HtmlPage, PageError> {
let mut doc = HtmlPage::default();
doc.push_to_head(
Element::new(Tag::Title)
.with_text("CI for Radicle node ")
.with_text(&self.node_alias),
);
doc.push_to_head(Element::new(Tag::Style).with_text(CSS));
doc.push_to_head(
Element::new(Tag::Meta)
.with_attribute("http-equiv", "refresh")
.with_attribute("content", REFERESH_INTERVAL),
Self::head(
&mut doc,
&format!("CI for Radicle node {}", self.node_alias),
);
doc.push_to_body(
@@ -260,6 +251,16 @@ impl PageData {
Ok(doc)
}
fn head(page: &mut HtmlPage, title: &str) {
page.push_to_head(Element::new(Tag::Title).with_text(title));
page.push_to_head(Element::new(Tag::Style).with_text(CSS));
page.push_to_head(
Element::new(Tag::Meta)
.with_attribute("http-equiv", "refresh")
.with_attribute("content", REFERESH_INTERVAL),
);
}
fn whence_as_html(whence: &Whence) -> Element {
match whence {
Whence::Branch {