feat: allow config file to set description in HTML report

This commit is contained in:
Lars Wirzenius
2025-10-07 08:47:26 +03:00
parent a73a1c7fe8
commit c459b6763a
4 changed files with 35 additions and 1 deletions
+6
View File
@@ -236,6 +236,9 @@ impl QueuedCmd {
db,
true,
);
if let Some(desc) = config.description() {
page.set_description(desc);
}
if let Some(dirname) = config.report_dir() {
page.set_output_dir(dirname);
}
@@ -281,6 +284,9 @@ impl ProcessEventsCmd {
db,
false,
);
if let Some(desc) = config.description() {
page.set_description(desc);
}
if let Some(dirname) = config.report_dir() {
page.set_output_dir(dirname);
}
+8
View File
@@ -9,6 +9,11 @@ pub struct ReportCmd {
/// it is not created automatically.
#[clap(long)]
output_dir: PathBuf,
/// HTML snippet to be inserted at top of generated front page,
/// for describing the CI node instance.
#[clap(long)]
description: Option<String>,
}
impl Leaf for ReportCmd {
@@ -24,6 +29,9 @@ impl Leaf for ReportCmd {
db,
true,
);
if let Some(desc) = &self.description {
page.set_description(desc);
}
page.set_output_dir(&self.output_dir);
let thread = start_thread(page);
+6
View File
@@ -52,6 +52,8 @@ pub struct Config {
#[serde(default)]
concurrent_adapters: Option<usize>,
description: Option<String>,
}
fn default_max_run_time() -> Duration {
@@ -91,6 +93,10 @@ impl Config {
Ok(())
}
pub fn description(&self) -> Option<&str> {
self.description.as_deref()
}
pub fn report_dir(&self) -> Option<&Path> {
self.report_dir.as_deref()
}
+15 -1
View File
@@ -88,6 +88,7 @@ struct PageData {
broker_event_counter: usize,
latest_broker_event: Option<CiEvent>,
latest_ci_run: Option<Run>,
desc_snippet: Option<String>,
}
impl PageData {
@@ -103,9 +104,15 @@ impl PageData {
doc.push_to_body(Element::new(Tag::H1).with_text(&title));
if let Some(snippet) = &self.desc_snippet {
let mut desc = Element::new(Tag::Div);
desc.push_html(snippet);
doc.push_to_body(desc);
}
doc.push_to_body(Element::new(Tag::H2).with_text("RSS feeds"));
doc.push_to_body(
Element::new(Tag::P)
.with_text("RSS feeds: ")
.with_child(
Element::new(Tag::A)
.with_text("all")
@@ -824,6 +831,7 @@ struct PageArgs {
profile: Profile,
db: Db,
once: bool,
desc_snippet: Option<String>,
}
impl StatusPage {
@@ -840,10 +848,15 @@ impl StatusPage {
profile,
db,
once,
desc_snippet: None,
},
}
}
pub fn set_description(&mut self, desc: &str) {
self.args.desc_snippet = Some(desc.to_string());
}
fn update_loop(&mut self) -> Result<(), PageError> {
'processing_loop: loop {
self.update_and_write()?;
@@ -914,6 +927,7 @@ impl StatusPage {
broker_event_counter: 0,
latest_broker_event: None,
latest_ci_run: None,
desc_snippet: self.args.desc_snippet.clone(),
};
let nameless = String::from("nameless repo");