diff --git a/build.rs b/build.rs index af62d14..8aed6c0 100644 --- a/build.rs +++ b/build.rs @@ -2,16 +2,27 @@ use sha2::{Digest, Sha256}; use walkdir::WalkDir; fn main() -> anyhow::Result<()> { - let mut hasher = Sha256::new(); + let mut css_hasher = Sha256::new(); for entry in WalkDir::new("static/css") { let entry = entry.unwrap(); if entry.file_type().is_file() { - hasher.update(std::fs::read_to_string(entry.path())?); + css_hasher.update(std::fs::read_to_string(entry.path())?); } } - let hash = hasher.finalize(); - println!("cargo:rustc-env=CSS_VERSION={:x}", hash); + let css_hash = css_hasher.finalize(); + println!("cargo:rustc-env=CSS_VERSION={:x}", css_hash); + + let mut js_hasher = Sha256::new(); + for entry in WalkDir::new("static/js") { + let entry = entry.unwrap(); + if entry.file_type().is_file() { + js_hasher.update(std::fs::read_to_string(entry.path())?); + } + } + + let js_hash = js_hasher.finalize(); + println!("cargo:rustc-env=JS_VERSION={:x}", js_hash); Ok(()) } diff --git a/src/main.rs b/src/main.rs index 56eb7c8..8a64720 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ pub struct Context { } const CSS_VERSION: &str = std::env!("CSS_VERSION"); +const JS_VERSION: &str = std::env!("JS_VERSION"); struct TplContext<'a> { is_admin: bool, @@ -42,6 +43,7 @@ struct TplContext<'a> { err_msg: Vec, warning_msg: Vec, css_version: &'a str, + js_version: &'a str, } impl<'a> TplContext<'a> { @@ -54,6 +56,7 @@ impl<'a> TplContext<'a> { err_msg: session.err_msg.drain(..).collect(), warning_msg: session.warning_msg.drain(..).collect(), css_version: CSS_VERSION, + js_version: JS_VERSION, }; session diff --git a/templates/base.html b/templates/base.html index ee32d81..d2a3d74 100644 --- a/templates/base.html +++ b/templates/base.html @@ -57,7 +57,7 @@ {% block main %}{% endblock main %} - + {% block scripts %} {% endblock scripts %} diff --git a/templates/room.html b/templates/room.html index a08292d..be41cc2 100644 --- a/templates/room.html +++ b/templates/room.html @@ -131,7 +131,7 @@ - + {% endblock %} {% block styles %}