diff --git a/confetti-box/Cargo.toml b/confetti-box/Cargo.toml index 9765646..db665ce 100644 --- a/confetti-box/Cargo.toml +++ b/confetti-box/Cargo.toml @@ -5,6 +5,7 @@ repository = "https://github.com/Dangoware/confetti-box" license = "AGPL-3.0-or-later" authors.workspace = true edition = "2024" +build = "build.rs" [lints] workspace = true @@ -25,3 +26,7 @@ toml = "0.8" unidecode = "0.3" urlencoding = "2.1" uuid = { version = "1.11", features = ["serde", "v4"] } + + +[build-dependencies] +vergen-gix = { version = "1.0", features = ["build", "cargo", "rustc", "si"] } diff --git a/confetti-box/build.rs b/confetti-box/build.rs new file mode 100644 index 0000000..f0b4e51 --- /dev/null +++ b/confetti-box/build.rs @@ -0,0 +1,23 @@ +use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder, RustcBuilder, SysinfoBuilder}; + +fn main() { + let build = BuildBuilder::all_build().unwrap(); + let cargo = CargoBuilder::all_cargo().unwrap(); + let gitcl = GixBuilder::all_git().unwrap(); + let rustc = RustcBuilder::all_rustc().unwrap(); + let si = SysinfoBuilder::all_sysinfo().unwrap(); + + Emitter::default() + .add_instructions(&build) + .unwrap() + .add_instructions(&cargo) + .unwrap() + .add_instructions(&gitcl) + .unwrap() + .add_instructions(&rustc) + .unwrap() + .add_instructions(&si) + .unwrap() + .emit() + .unwrap(); +} diff --git a/confetti-box/src/pages.rs b/confetti-box/src/pages.rs index 7235996..94bb85c 100644 --- a/confetti-box/src/pages.rs +++ b/confetti-box/src/pages.rs @@ -17,6 +17,14 @@ pub fn head(page_title: &str) -> Markup { } pub fn footer() -> Markup { + let hash = match option_env!("VERGEN_GIT_SHA") { + Some(hash) => &hash[0..7], + None => "", + }; + + let pkg_version = env!("CARGO_PKG_VERSION"); + let hash_link = "https://github.com/Dangoware/confetti-box/commit/".to_string() + hash; + html! { footer { div { @@ -26,7 +34,11 @@ pub fn footer() -> Markup { p {a href="https://github.com/Dangoware/confetti-box" {"Source"}} p {a href="https://github.com/Dangoware/" {"Dangoware"}} } - p.version { "Running Confetti-Box v" (env!("CARGO_PKG_VERSION")) } + p.version { "Running Confetti-Box v" (pkg_version) " " } + + @if !hash.is_empty() { + p.version style="font-size: 0.8em" { "(" a style="font-family:'Fira Code'" href=(hash_link) {(hash)} " - " (env!("VERGEN_BUILD_DATE")) ")" } + } } } } diff --git a/confetti-box/web/main.css b/confetti-box/web/main.css index 709daf0..dff996b 100644 --- a/confetti-box/web/main.css +++ b/confetti-box/web/main.css @@ -40,6 +40,7 @@ footer { p.version { margin-top: 0; + margin-bottom: 0; opacity: 45%; } }