From a34df9980facec6d4cd302a96bc879aa9e5ecdff Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 16 Aug 2024 11:45:15 +0300 Subject: [PATCH] refactor: add helper to add the usual stuff to the HEAD element Signed-off-by: Lars Wirzenius --- src/pages.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/pages.rs b/src/pages.rs index b6c8d3cf..ee8497e4 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -116,18 +116,9 @@ impl PageData { fn status_page_as_html(&self) -> Result { 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 {