aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2019-02-02 16:22:27 +0000
committerGitHub <noreply@github.com>2019-02-02 16:22:27 +0000
commitbf3777290d7f18fdb1fc63bda215b43d5c2be9c4 (patch)
tree176d0bcdf0d86d9f4aa18974249c5557892b5cdf /src
parentMerge pull request #25 from boastful-squirrel/fancy-listing (diff)
parentAdded '..' on file listing to browse parent folder (diff)
downloadminiserve-bf3777290d7f18fdb1fc63bda215b43d5c2be9c4.tar.gz
miniserve-bf3777290d7f18fdb1fc63bda215b43d5c2be9c4.zip
Merge pull request #27 from boastful-squirrel/parent-directory
Added '..' on files listing to browse parent folder
Diffstat (limited to 'src')
-rw-r--r--src/main.rs12
1 files changed, 12 insertions, 0 deletions
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<S>(
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,
+ "<tr><td><a class=\"{}\" href=\"{}\">..</a></td><td></td></tr>",
+ "root",
+ parent.display()
+ );
+ }
for entry in dir.path.read_dir()? {
if dir.is_visible(&entry) {
@@ -452,6 +460,10 @@ fn directory_listing<S>(
text-decoration: none;\
color: #3498db;\
}}\
+ a.root, a.root:visited {{\
+ font-weight: bold;\
+ color: #777c82;\
+ }}
a.directory {{\
font-weight: bold;\
}}\