Skip to content

Commit

Permalink
✨ Version injection on website
Browse files Browse the repository at this point in the history
  • Loading branch information
mawoka-myblock committed Jan 16, 2025
1 parent f0bf282 commit 0f77063
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@
<h1>Td-Free</h1>
<div id="status" class="status">Connecting...</div>
<p id="content"></p>
<div style="display: flex;">
<div style="display: flex; flex-direction: column; margin-top: auto;">
<a href="/wifi" class="wifi-link" onclick="wifi_cfg">Wifi Config</a>
<p class="wifi-link" style="color: gray; font-size: smaller;">Verion {{VERSION}}</p>
<!-- <a href="/update" class="wifi-link" onclick="update_fw">Update Firmware</a> -->
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0f77063

Please sign in to comment.