From f7e69e5067c13d714bdb2334d9accbf7e901b934 Mon Sep 17 00:00:00 2001 From: blek Date: Mon, 9 Oct 2023 22:46:32 +1000 Subject: [PATCH] display the commit hash on the footer --- filed/Cargo.lock | 59 ++++++++++++++++++++++++++++++++++++++ filed/Cargo.toml | 1 + filed/src/env.rs | 4 +++ filed/templates/base.html | 2 +- filed/templates/index.html | 5 ++-- 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/filed/Cargo.lock b/filed/Cargo.lock index aeddbd4..a46b163 100644 --- a/filed/Cargo.lock +++ b/filed/Cargo.lock @@ -32,6 +32,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + [[package]] name = "askama" version = "0.12.0" @@ -280,6 +286,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "static_dir", "tokio", "warp", ] @@ -541,6 +548,29 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "include_dir" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab" +dependencies = [ + "include_dir_impl", + "proc-macro-hack", +] + +[[package]] +name = "include_dir_impl" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df" +dependencies = [ + "anyhow", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -812,6 +842,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.67" @@ -1018,6 +1054,23 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "static_dir" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8286dc044d09abcb8bf85440b94f2c41aee322733a58cd195cf830ee660cadf5" +dependencies = [ + "headers", + "http", + "hyper", + "include_dir", + "log", + "mime_guess", + "once_cell", + "urlencoding", + "warp", +] + [[package]] name = "sval" version = "2.9.1" @@ -1307,6 +1360,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a1f0175e03a0973cf4afd476bef05c26e228520400eb1fd473ad417b1c00ffb" + [[package]] name = "utf-8" version = "0.7.6" diff --git a/filed/Cargo.toml b/filed/Cargo.toml index e9c4b9b..7716659 100644 --- a/filed/Cargo.toml +++ b/filed/Cargo.toml @@ -20,5 +20,6 @@ redis = { version = "0.23.3", features = ["tokio"] } serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" sha2 = "0.10.8" +static_dir = "0.2.0" tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] } warp = "0.3.6" diff --git a/filed/src/env.rs b/filed/src/env.rs index 118ed0d..31d2fd2 100644 --- a/filed/src/env.rs +++ b/filed/src/env.rs @@ -70,4 +70,8 @@ impl Env { pub fn usercontent_dir(self: &Self) -> Box<&Path> { Box::new(Path::new(&self.filedir)) } + pub fn shortcommit(self: &Self) -> String { + let commit = self.last_commit.to_string().clone(); + commit.chars().take(6).collect() + } } \ No newline at end of file diff --git a/filed/templates/base.html b/filed/templates/base.html index 7698007..3039fa5 100644 --- a/filed/templates/base.html +++ b/filed/templates/base.html @@ -31,7 +31,7 @@ - Made with Rust + bleK! File {{ env.shortcommit() }} Released under GPLv3 diff --git a/filed/templates/index.html b/filed/templates/index.html index a6777b9..af3c417 100644 --- a/filed/templates/index.html +++ b/filed/templates/index.html @@ -50,8 +50,9 @@ I want to add a password to the file: - - Warning: the file WILL NOT be encrypted.
+ + Warning: the file WILL NOT be encrypted,
+ therefore this is not 100% secure.
Learn more