mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
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:
+14
-7
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user