From 90c6839d5d022229151bd3fe9432ed104bae39f9 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Thu, 19 Sep 2024 08:16:54 +0200 Subject: [PATCH] feat: Print filenames in webpage, not full paths --- src/utils.rs | 11 +++++++++++ templates/list.html | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 13ba6ac..31c58aa 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -27,6 +27,17 @@ pub struct FileEntry { pub tags: Vec, } +impl FileEntry { + pub fn filename(&self) -> &str { + Path::new(&self.path) + .file_name() + .to_owned() + .unwrap() + .to_str() + .unwrap() + } +} + fn load_tag_file(path: &PathBuf) -> Result> { let mut file = File::open(path)?; let mut contents = String::new(); diff --git a/templates/list.html b/templates/list.html index 1378269..345f292 100644 --- a/templates/list.html +++ b/templates/list.html @@ -4,6 +4,7 @@