diff --git a/build.rs b/build.rs index cbae47a..a2fd25e 100644 --- a/build.rs +++ b/build.rs @@ -23,7 +23,7 @@ fn try_get_commit() -> eyre::Result { let stdout = String::from_utf8(stdout)?; - Ok(stdout.trim().to_owned()) + Ok(stdout.trim()[0..8].to_owned()) } fn has_no_changes() -> eyre::Result { diff --git a/src/lib.rs b/src/lib.rs index 7295599..5e27255 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,8 @@ use client::Client; pub use config::{read_config, Config, WebsiteConfig}; pub use web::axum_server; -const USER_AGENT: &str = concat!("uptime/", env!("GIT_COMMIT")); +const USER_AGENT: &str = concat!("github:Nilstrieb/uptime/", env!("GIT_COMMIT")); +const VERSION: &str = env!("GIT_COMMIT"); pub async fn check_timer(config: Config, db: Arc>) -> Result<ⵑ> { let req_client = reqwest::Client::builder() diff --git a/src/web.rs b/src/web.rs index 0ccf15e..314e1e3 100644 --- a/src/web.rs +++ b/src/web.rs @@ -51,7 +51,7 @@ async fn render_root(db: Arc>) -> Result { let status = compute_status(checks); - let html = RootTemplate { status } + let html = RootTemplate { status, version: crate::VERSION } .render() .wrap_err("error rendering template")?; Ok(html) @@ -212,4 +212,5 @@ struct WebsiteStatus { #[template(path = "index.html")] struct RootTemplate { status: Vec, + version: &'static str, } diff --git a/templates/index.html b/templates/index.html index b6c0d00..48a8566 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,97 +1,135 @@ - - - - + + + + Uptime - - + +
- {% for check in status %} + {% for check in status %} -

{{ check.website }}

-

Uptime: {{ check.ok_ratio }} ({{ check.count_ok }}/{{ check.total_requests }})

- {% if check.last_ok.is_some() %} -

Last OK: {{ check.last_ok.as_deref().unwrap() }}

- {% endif %} +

{{ check.website }}

+

+ Uptime: {{ check.ok_ratio }} ({{ check.count_ok }}/{{ + check.total_requests }}) +

+ {% if check.last_ok.is_some() %} +

+ Last OK: + {{ check.last_ok.as_deref().unwrap() }} +

+ {% endif %} -
-
- {% for result in check.bar_info.elems %} -
- {% endfor %} -
- {% if check.bar_info.first_time.is_some() && check.bar_info.last_time.is_some() %} -
- {{ check.bar_info.first_time.unwrap().render_nicely() }} - {{ check.bar_info.last_time.unwrap().render_nicely() }} -
- {% endif %} +
+
+ {% for result in check.bar_info.elems %} +
+ {% endfor %}
+ {% if check.bar_info.first_time.is_some() && + check.bar_info.last_time.is_some() %} +
+ {{ check.bar_info.first_time.unwrap().render_nicely() }} + {{ check.bar_info.last_time.unwrap().render_nicely() }} +
+ {% endif %} +
- {% endfor %} + {% endfor %}
+ + - - \ No newline at end of file + +