diff --git a/src/web.rs b/src/web.rs
index 7d0b473..33261ef 100644
--- a/src/web.rs
+++ b/src/web.rs
@@ -25,35 +25,38 @@ fn handle_directory<'a, 'b>(
.filter_map(|r| r.ok())
.collect();
paths.sort_by_key(|r| (!r.metadata().unwrap().file_type().is_dir(), r.file_name()));
- let mut t = String::from("
- 📁 ../ | Size |
\n");
+ let mut body = String::new();
+ body.push_str(&format!("Index of {index}
[.tar of whole directory]
+
+ 📁 ../ | Size |
\n", index=req.path()));
for entry in paths {
let meta = entry.metadata()?;
let file_url = utf8_percent_encode(&entry.file_name().to_string_lossy(), DEFAULT_ENCODE_SET).to_string();
let file_name = escape_html_entity(&entry.file_name().to_string_lossy());
let size = meta.len();
- t.push_str("");
+ body.push_str("
");
if meta.file_type().is_dir() {
- t.push_str(&format!("📂 {file_name}/ | ", file_name=file_name, file_url=file_url));
- t.push_str(&format!("[.tar] | \n", file_url=file_url));
+ body.push_str(&format!("📂 {file_name}/ | ", file_name=file_name, file_url=file_url));
+ body.push_str(&format!("[.tar] | ", file_url=file_url));
} else {
- t.push_str(&format!("🗎 {file_name} | ", file_name=file_name, file_url=file_url));
- t.push_str(&format!("{size} | ", size=size));
+ body.push_str(&format!("🗎 {file_name} | ", file_name=file_name, file_url=file_url));
+ body.push_str(&format!("{size} | ", size=size));
}
- t.push_str("
\n");
+ body.push_str("\n");
}
- t.push_str("
");
- let mut body = String::from(format!("
+ body.push_str("
\n");
+
+ let mut html = String::from(format!("
Index of {index}
-
+
-
- Index of {index}
\n", index=req.path()));
- body.push_str(t.as_str());
- body.push_str("
\n");
- Ok(HttpResponse::Ok().content_type("text/html; charset=utf-8").body(body))
+ \n", index=req.path()));
+ html.push_str(body.as_str());
+ html.push_str("\n");
+
+ Ok(HttpResponse::Ok().content_type("text/html; charset=utf-8").body(html))
}
fn handle_tar(req: &HttpRequest) -> impl Responder {