use systemd::unit; use horrorshow::prelude::*; use horrorshow::Raw; fn render_in_page<'a>(content: Box) -> String { (html!{ : Raw(""); html { head { title: "Systemhttpd"; link(rel="stylesheet", type="text/css", href="static/main.css"); } body { : content } } }).into_string().unwrap() } fn unit_table<'a>(units: &'a [&unit::Unit]) -> Box { fn render_unit<'a>(unit: &'a unit::Unit) -> Box { box_html! { tr { td { a(href=format_args!("/status/{}", &unit.name)) { : &unit.name } } td { : format_args!("{} ({})", &unit.active_state, &unit.sub_state) } } } } box_html! { table { tr { th { : "Unit" } th { : "Active" } } @ for unit in units { : render_unit(unit) } } } } pub fn system_status(sections: &[(String, Vec<&unit::Unit>)]) -> String { let b = box_html! { @ for &(ref type_, ref units) in sections { h1 { : type_ } : unit_table(&units) } }; render_in_page(b) }