aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboasting-squirrel <boasting.squirrel@gmail.com>2019-02-02 15:38:28 +0000
committerboasting-squirrel <boasting.squirrel@gmail.com>2019-02-02 15:38:28 +0000
commit868b90eacbd3b7f1dc3fb505066891437fbbef91 (patch)
tree176d0bcdf0d86d9f4aa18974249c5557892b5cdf
parentMerge pull request #25 from boastful-squirrel/fancy-listing (diff)
downloadminiserve-868b90eacbd3b7f1dc3fb505066891437fbbef91.tar.gz
miniserve-868b90eacbd3b7f1dc3fb505066891437fbbef91.zip
Added '..' on file listing to browse parent folder
Diffstat (limited to '')
-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;\
}}\