From 0f77063173dfdfa1e0da90c414a234a98404e39d Mon Sep 17 00:00:00 2001 From: Mawoka Date: Thu, 16 Jan 2025 13:38:46 +0100 Subject: [PATCH] :sparkles: Version injection on website --- build.rs | 4 ++++ src/index.html | 3 ++- src/main.rs | 9 ++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index ab72393..e68bf9c 100644 --- a/build.rs +++ b/build.rs @@ -10,5 +10,9 @@ fn main() -> Result<()> { .add_instructions(&rustc)? .emit()?; embuild::espidf::sysenv::output(); + println!( + "cargo:rustc-env=VERSION={}", + std::env::var("TD_FREE_VERSION").unwrap_or("UNKNOWN".to_string()) + ); Ok(()) } diff --git a/src/index.html b/src/index.html index 380c3a8..62e33c1 100644 --- a/src/index.html +++ b/src/index.html @@ -83,8 +83,9 @@

Td-Free

Connecting...

-
+
Wifi Config +
diff --git a/src/main.rs b/src/main.rs index 1f7dee7..c328a7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,7 +156,14 @@ fn main() -> Result<(), ()> { server .fn_handler("/", Method::Get, |req| { req.into_ok_response()? - .write_all(INDEX_HTML.as_bytes()) + .write_all( + INDEX_HTML + .replace( + "{{VERSION}}", + option_env!("TD_FREE_VERSION").unwrap_or("UNKNOWN"), + ) + .as_bytes(), + ) .map(|_| ()) }) .unwrap();