fix: set report page title correctly

Previously the title claimed to be for a node, even when page was for
repository.
This commit is contained in:
Lars Wirzenius
2026-08-26 09:49:02 +03:00
parent 2e1fc47675
commit d5658ef558
+14 -7
View File
@@ -108,7 +108,8 @@ impl PageData {
}
fn status_page_as_html(&self, refresh_interval: usize) -> Result<HtmlPage, PageError> {
let mut doc = ReportPage::new(&self.node_alias, refresh_interval);
let mut doc = ReportPage::new(refresh_interval);
doc.set_title(format!("CI node {}", self.node_alias));
if let Some(snippet) = &self.desc_snippet {
doc.desc(snippet);
}
@@ -368,11 +369,12 @@ impl PageData {
fn per_repo_page_as_html(
&self,
rid: RepoId,
alias: &str,
name: &str,
timestamp: &str,
refresh_interval: usize,
) -> HtmlPage {
let mut doc = ReportPage::new(alias, refresh_interval);
let mut doc = ReportPage::new(refresh_interval);
doc.set_title(format!("CI for repository {name}"));
doc.push(
Element::new(Tag::P).with_child(
Element::new(Tag::A)
@@ -772,20 +774,25 @@ struct ReportPage {
}
impl ReportPage {
fn new(node_alias: &str, refresh_interval: usize) -> Self {
fn new(refresh_interval: usize) -> Self {
let mut page = HtmlPage::default();
let title = format!("CI for Radicle node {node_alias}");
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", refresh_interval.to_string()),
);
page.push_to_body(Element::new(Tag::H1).with_text(&title));
Self { page }
}
fn set_title(&mut self, title: impl Into<String>) {
let title = title.into();
self.page
.push_to_head(Element::new(Tag::Title).with_text(&title));
self.page
.push_to_body(Element::new(Tag::H1).with_text(&title));
}
fn desc(&mut self, snippet: &str) {
let mut desc = Element::new(Tag::Div);
desc.push_html(snippet);