From 868b90eacbd3b7f1dc3fb505066891437fbbef91 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sat, 2 Feb 2019 16:38:28 +0100 Subject: Added '..' on file listing to browse parent folder --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b392856..11d02fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -369,6 +369,14 @@ fn directory_listing( let index_of = format!("Index of {}", req.path()); let mut body = String::new(); let base = Path::new(req.path()); + if let Some(parent) = base.parent() { + let _ = write!( + body, + "..", + "root", + parent.display() + ); + } for entry in dir.path.read_dir()? { if dir.is_visible(&entry) { @@ -452,6 +460,10 @@ fn directory_listing( text-decoration: none;\ color: #3498db;\ }}\ + a.root, a.root:visited {{\ + font-weight: bold;\ + color: #777c82;\ + }} a.directory {{\ font-weight: bold;\ }}\ -- cgit v1.2.3