diff --git a/.env.example b/.env.example
index f31c3ac..4ff5944 100644
--- a/.env.example
+++ b/.env.example
@@ -2,4 +2,6 @@ SALT=64_byte_string
DATABASE_URL=postgres://xxx:xxx@localhost/xxx
METALS_API_KEY=xxx
-NUMISTA_API_KEY=xxx
\ No newline at end of file
+NUMISTA_API_KEY=xxx
+
+ASSET_DIR=/opt/melt/public
diff --git a/src/middleware.rs b/src/middleware.rs
index 48b4e89..d1e6e86 100644
--- a/src/middleware.rs
+++ b/src/middleware.rs
@@ -82,6 +82,33 @@ impl ClientCtx {
format!("{:.2}", AU_TO_USD.load(Ordering::Relaxed) as f32 / 1000.0)
}
+ pub fn get_asset_timestamp(&self) -> u64 {
+ let asset = "assets/style.css";
+ match std::fs::metadata(format!(
+ "{}/{}",
+ std::env::var("ASSET_DIR").unwrap_or_else(|_| ".".to_string()),
+ asset
+ )) {
+ Ok(metadata) => match metadata.modified() {
+ Ok(time) => match time.duration_since(std::time::UNIX_EPOCH) {
+ Ok(distance) => distance.as_secs(),
+ Err(_) => {
+ log::warn!("Unable to do math on webpack chat.js modified at timestamp");
+ 0
+ }
+ },
+ Err(_) => {
+ log::warn!("Unable to read metadata on webpack chat.js");
+ 0
+ }
+ },
+ Err(_) => {
+ log::warn!("Unable to open webpack chat.js for timestamp");
+ 0
+ }
+ }
+ }
+
/// Returns Duration representing request time.
pub fn request_time(&self) -> Duration {
Instant::now() - self.0.request_start
diff --git a/templates/container/public.html b/templates/container/public.html
index af89d27..57ed8b3 100644
--- a/templates/container/public.html
+++ b/templates/container/public.html
@@ -15,7 +15,8 @@
{% block stylesheets %}
-
+
{#
#}
{% endblock %}