diff --git a/src/bin/cib.rs b/src/bin/cib.rs index 458b12cc..9987962f 100644 --- a/src/bin/cib.rs +++ b/src/bin/cib.rs @@ -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); } diff --git a/src/bin/cibtoolcmd/report.rs b/src/bin/cibtoolcmd/report.rs index ae48ec3c..57c0713f 100644 --- a/src/bin/cibtoolcmd/report.rs +++ b/src/bin/cibtoolcmd/report.rs @@ -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, } 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); diff --git a/src/config.rs b/src/config.rs index 60f7a2a5..c080a908 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,6 +52,8 @@ pub struct Config { #[serde(default)] concurrent_adapters: Option, + + description: Option, } 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() } diff --git a/src/pages.rs b/src/pages.rs index 4022d6df..6ecab2e1 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -88,6 +88,7 @@ struct PageData { broker_event_counter: usize, latest_broker_event: Option, latest_ci_run: Option, + desc_snippet: Option, } 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, } 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");