0.2.0-beta dark mode, organize css, no index support, some icon and 500 error handle

This commit is contained in:
Tim-Paik 2021-08-16 01:23:54 +08:00
parent 61ae8af122
commit 77103c6670
4 changed files with 303 additions and 78 deletions

22
Cargo.lock generated
View File

@ -849,6 +849,16 @@ version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mime_guess"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "mio"
version = "0.6.23"
@ -2055,6 +2065,15 @@ dependencies = [
"unic-common",
]
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
@ -2174,12 +2193,13 @@ checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
[[package]]
name = "web"
version = "0.1.9-beta"
version = "0.2.0-beta"
dependencies = [
"chrono",
"clap",
"colored",
"lazy_static",
"mime_guess",
"rocket",
"rocket_dyn_templates",
]

View File

@ -3,12 +3,13 @@ authors = ["Tim_Paik <timpaikc@outlook.com>"]
description = "simple http server written in rust"
edition = "2018"
name = "web"
version = "0.1.9-beta"
version = "0.2.0-beta"
[dependencies]
chrono = "0.4"
clap = {version = "3.0.0-beta.2", features = ["wrap_help", "color"]}
colored = "2"
lazy_static = "1.4.0"
mime_guess = "2.0.3"
rocket = {version = "0.5.0-rc.1", features = ["tls"]}
rocket_dyn_templates = {version = "0.1.0-rc.1", features = ["tera"]}

View File

@ -34,6 +34,7 @@ struct Dir {
struct File {
name: String,
size: u64,
filetype: String,
modified: String,
}
@ -78,7 +79,7 @@ async fn not_found(request: &rocket::Request<'_>) -> Resp {
{
return Resp::File(NamedFile::open(&root.join("index.html")).await.ok());
}
if !localpath.is_dir() {
if !localpath.is_dir() || std::env::var("NOINDEX").unwrap_or("false".to_string()) == "true" {
return Resp::NotFound("");
}
if !path.ends_with("/") {
@ -107,14 +108,14 @@ async fn not_found(request: &rocket::Request<'_>) -> Resp {
continue;
}
};
let filename = match path.file_name().to_str() {
let name = match path.file_name().to_str() {
Some(str) => str.to_string(),
None => {
println!("{} {}", "Error".bright_red(), "Read filename error");
continue;
}
};
if !show_dot_files && filename.starts_with(".") {
if !show_dot_files && name.starts_with(".") {
continue;
}
let metadata = match path.metadata() {
@ -125,23 +126,58 @@ async fn not_found(request: &rocket::Request<'_>) -> Resp {
}
};
let modified = match metadata.modified() {
Ok(time) => chrono::DateTime::<chrono::Local>::from(time).to_string(),
Ok(time) => chrono::DateTime::<chrono::Local>::from(time)
.format("%Y-%m-%d %H:%M:%S")
.to_string(),
Err(e) => {
println!("{} {}", "Error".bright_red(), e.to_string());
continue;
}
};
if metadata.is_dir() {
context.dirs.push(Dir {
name: filename,
modified: modified,
})
context.dirs.push(Dir { name, modified });
} else if metadata.is_file() {
let size = metadata.len();
let filetype = match path.path().extension() {
Some(os_str) => match os_str.to_str().unwrap_or("") {
"7z" => "archive",
"bz" => "archive",
"bz2" => "archive",
"cab" => "archive",
"gz" => "archive",
"rar" => "archive",
"xz" => "archive",
"zip" => "archive",
"zstd" => "archive",
"doc" => "word",
"docx" => "word",
"ppt" => "powerpoint",
"pptx" => "powerpoint",
"xls" => "excel",
"xlsx" => "excel",
_ => {
match mime_guess::from_path(path.path())
.first_or_octet_stream()
.type_()
{
mime_guess::mime::AUDIO => "audio",
mime_guess::mime::IMAGE => "image",
mime_guess::mime::PDF => "pdf",
mime_guess::mime::VIDEO => "video",
mime_guess::mime::TEXT => "alt",
_ => "file",
}
}
},
None => "file",
}
.to_string();
context.files.push(File {
name: filename,
size: metadata.len(),
modified: modified,
})
name,
size,
filetype,
modified,
});
}
}
}
@ -152,6 +188,9 @@ async fn not_found(request: &rocket::Request<'_>) -> Resp {
Resp::Index(Template::render("index", &context))
}
#[catch(500)]
fn internal_server_error() {}
struct Logger {}
#[rocket::async_trait]
@ -246,7 +285,7 @@ async fn main() {
(version: crate_version!())
(author: crate_authors!())
(about: crate_description!())
(@arg index: -i --index "Enable automatic index page generation")
(@arg noindex: --noindex "Disable automatic index page generation")
(@arg upload: -u --upload "Enable file upload")
(@arg nocache: --nocache "Disable HTTP cache")
(@arg nocolor: --nocolor "Disable cli colors")
@ -322,6 +361,7 @@ async fn main() {
display_path(Path::new(matches.value_of("ROOT").unwrap_or("."))),
);
std::env::set_var("NOINDEX", matches.is_present("noindex").to_string());
std::env::set_var("SPA", matches.is_present("spa").to_string());
std::env::set_var("DOTFILES", matches.is_present("dotfiles").to_string());
@ -408,7 +448,7 @@ async fn main() {
.attach(CORS {})
.attach(Logger {})
.mount("/", routes![file_server])
.register("/", catchers![not_found])
.register("/", catchers![not_found, internal_server_error])
.launch()
.await
{

View File

@ -7,36 +7,44 @@
<meta name="force-rendering" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light dark">
<title>{{ title }}</title>
<!--[if lt IE 9
]><script src="https://cdn.jsdelivr.net/npm/html5shiv/dist/html5shiv.min.js"></script
><![endif]-->
<style>
* {
html,
body,
#header,
#meta,
#listing {
padding: 0;
margin: 0;
border-spacing: 0;
background: #ffffff;
}
a {
#header a,
#listing a {
text-decoration: none;
color: #2A52BE;
color: #2a52be;
}
a:hover {
color: #1E90FF;
#header a:hover,
#listing a:hover {
color: #1e90ff;
}
nav span a {
#header nav span a {
color: #000000;
}
nav span a:hover {
color: #2A52BE;
#header nav span a:hover {
color: #2a52be;
}
th,
td {
#listing th,
#listing td {
height: 1.6rem;
text-align: left;
padding: 0.4rem 0;
@ -44,88 +52,233 @@
font-size: 1rem;
border-bottom: 1px dashed #cccccc;
}
#header {
padding: 1.5rem 5% 1rem;
background-color: #f2f2f2;
}
#header h1 {
font-size: 1.25rem;
font-weight: normal;
margin: 0;
}
#meta {
font-size: 0.75rem;
padding: 1.05rem 5%;
}
#meta:first-child {
margin-right: 1rem;
}
#listing svg {
vertical-align: middle;
}
#listing table {
border-top: 1px dashed #cccccc;
width: 100%;
}
#listing table thead {
height: 3rem;
}
#listing th:first-child,
#listing td:first-child {
width: 5%;
}
#listing th:last-child,
#listing td:last-child {
width: 5%;
text-align: right;
}
#listing th:nth-child(2),
#listing td:nth-child(2) {
width: 80%;
white-space: normal;
overflow-wrap: anywhere;
word-break: normal;
}
#listing th:nth-child(3),
#listing td:nth-child(3) {
padding: 0 1.25rem;
}
#listing .goup svg,
#listing .file svg {
fill: #000000;
}
@media (max-width: 600px) {
#listing .hideable {
display: none;
}
#listing td:nth-child(2) {
width: auto;
}
#listing th:nth-child(3),
#listing td:nth-child(3) {
padding: 0 0.5rem;
}
}
@media (prefers-color-scheme: dark) {
html {
color: #444444;
filter: invert(1);
}
#listing a span {
filter: invert(1);
}
#listing .goup svg,
#listing .file svg {
fill: #444444;
}
#listing .dir svg {
filter: invert(1);
}
#header a,
#listing a {
color: #1e90ff;
}
#header a:hover,
#listing a:hover {
color: #00bfff;
}
#header nav span a:hover {
color: #1e90ff;
}
}
</style>
</head>
<body>
{% set paths_length = paths | length %}
<header style="padding: 1.5rem 5% 1rem; background-color: #f2f2f2">
<h1 style="font-size: 1.25rem; font-weight: normal">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="0" width="0"
style="position: absolute;">
<defs>
<path id="goup"
d="M 25 7.21875 L 23.59375 8.65625 L 13.6875 18.53125 C 12.902344 19.316406 12.902344 20.589844 13.6875 21.375 C 14.472656 22.160156 15.746094 22.160156 16.53125 21.375 L 23 14.875 L 23 40 C 22.988281 40.722656 23.367188 41.390625 23.992188 41.753906 C 24.613281 42.121094 25.386719 42.121094 26.007813 41.753906 C 26.632813 41.390625 27.011719 40.722656 27 40 L 27 14.875 L 33.46875 21.375 C 34.253906 22.160156 35.527344 22.160156 36.3125 21.375 C 37.097656 20.589844 37.097656 19.316406 36.3125 18.53125 L 26.40625 8.65625 Z">
</path>
<path id="folder1" fill="#FFA000" d="M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z" />
<path id="folder2" fill="#FFCA28"
d="M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z" />
<path id="alt"
d="M288 248v28c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-28c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm-12 72H108c-6.6 0-12 5.4-12 12v28c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-28c0-6.6-5.4-12-12-12zm108-188.1V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V48C0 21.5 21.5 0 48 0h204.1C264.8 0 277 5.1 286 14.1L369.9 98c9 8.9 14.1 21.2 14.1 33.9zm-128-80V128h76.1L256 51.9zM336 464V176H232c-13.3 0-24-10.7-24-24V48H48v416h288z" />
<path id="archive"
d="M128.3 160v32h32v-32zm64-96h-32v32h32zm-64 32v32h32V96zm64 32h-32v32h32zm177.6-30.1L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM256 51.9l76.1 76.1H256zM336 464H48V48h79.7v16h32V48H208v104c0 13.3 10.7 24 24 24h104zM194.2 265.7c-1.1-5.6-6-9.7-11.8-9.7h-22.1v-32h-32v32l-19.7 97.1C102 385.6 126.8 416 160 416c33.1 0 57.9-30.2 51.5-62.6zm-33.9 124.4c-17.9 0-32.4-12.1-32.4-27s14.5-27 32.4-27 32.4 12.1 32.4 27-14.5 27-32.4 27zm32-198.1h-32v32h32z" />
<path id="audio"
d="M369.941 97.941l-83.882-83.882A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v416c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48V131.882a48 48 0 0 0-14.059-33.941zM332.118 128H256V51.882L332.118 128zM48 464V48h160v104c0 13.255 10.745 24 24 24h104v288H48zm144-76.024c0 10.691-12.926 16.045-20.485 8.485L136 360.486h-28c-6.627 0-12-5.373-12-12v-56c0-6.627 5.373-12 12-12h28l35.515-36.947c7.56-7.56 20.485-2.206 20.485 8.485v135.952zm41.201-47.13c9.051-9.297 9.06-24.133.001-33.439-22.149-22.752 12.235-56.246 34.395-33.481 27.198 27.94 27.212 72.444.001 100.401-21.793 22.386-56.947-10.315-34.397-33.481z" />
<path id="code"
d="M149.9 349.1l-.2-.2-32.8-28.9 32.8-28.9c3.6-3.2 4-8.8.8-12.4l-.2-.2-17.4-18.6c-3.4-3.6-9-3.7-12.4-.4l-57.7 54.1c-3.7 3.5-3.7 9.4 0 12.8l57.7 54.1c1.6 1.5 3.8 2.4 6 2.4 2.4 0 4.8-1 6.4-2.8l17.4-18.6c3.3-3.5 3.1-9.1-.4-12.4zm220-251.2L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM256 51.9l76.1 76.1H256zM336 464H48V48h160v104c0 13.3 10.7 24 24 24h104zM209.6 214c-4.7-1.4-9.5 1.3-10.9 6L144 408.1c-1.4 4.7 1.3 9.6 6 10.9l24.4 7.1c4.7 1.4 9.6-1.4 10.9-6L240 231.9c1.4-4.7-1.3-9.6-6-10.9zm24.5 76.9l.2.2 32.8 28.9-32.8 28.9c-3.6 3.2-4 8.8-.8 12.4l.2.2 17.4 18.6c3.3 3.5 8.9 3.7 12.4.4l57.7-54.1c3.7-3.5 3.7-9.4 0-12.8l-57.7-54.1c-3.5-3.3-9.1-3.2-12.4.4l-17.4 18.6c-3.3 3.5-3.1 9.1.4 12.4z" />
<path id="excel"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm212-240h-28.8c-4.4 0-8.4 2.4-10.5 6.3-18 33.1-22.2 42.4-28.6 57.7-13.9-29.1-6.9-17.3-28.6-57.7-2.1-3.9-6.2-6.3-10.6-6.3H124c-9.3 0-15 10-10.4 18l46.3 78-46.3 78c-4.7 8 1.1 18 10.4 18h28.9c4.4 0 8.4-2.4 10.5-6.3 21.7-40 23-45 28.6-57.7 14.9 30.2 5.9 15.9 28.6 57.7 2.1 3.9 6.2 6.3 10.6 6.3H260c9.3 0 15-10 10.4-18L224 320c.7-1.1 30.3-50.5 46.3-78 4.7-8-1.1-18-10.3-18z" />
<path id="file"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48z" />
<path id="image"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z" />
<path id="pdf"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm250.2-143.7c-12.2-12-47-8.7-64.4-6.5-17.2-10.5-28.7-25-36.8-46.3 3.9-16.1 10.1-40.6 5.4-56-4.2-26.2-37.8-23.6-42.6-5.9-4.4 16.1-.4 38.5 7 67.1-10 23.9-24.9 56-35.4 74.4-20 10.3-47 26.2-51 46.2-3.3 15.8 26 55.2 76.1-31.2 22.4-7.4 46.8-16.5 68.4-20.1 18.9 10.2 41 17 55.8 17 25.5 0 28-28.2 17.5-38.7zm-198.1 77.8c5.1-13.7 24.5-29.5 30.4-35-19 30.3-30.4 35.7-30.4 35zm81.6-190.6c7.4 0 6.7 32.1 1.8 40.8-4.4-13.9-4.3-40.8-1.8-40.8zm-24.4 136.6c9.7-16.9 18-37 24.7-54.7 8.3 15.1 18.9 27.2 30.1 35.5-20.8 4.3-38.9 13.1-54.8 19.2zm131.6-5s-5 6-37.3-7.8c35.1-2.6 40.9 5.4 37.3 7.8z" />
<path id="powerpoint"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm72-60V236c0-6.6 5.4-12 12-12h69.2c36.7 0 62.8 27 62.8 66.3 0 74.3-68.7 66.5-95.5 66.5V404c0 6.6-5.4 12-12 12H132c-6.6 0-12-5.4-12-12zm48.5-87.4h23c7.9 0 13.9-2.4 18.1-7.2 8.5-9.8 8.4-28.5.1-37.8-4.1-4.6-9.9-7-17.4-7h-23.9v52z" />
<path id="video"
d="M369.941 97.941l-83.882-83.882A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v416c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48V131.882a48 48 0 0 0-14.059-33.941zM332.118 128H256V51.882L332.118 128zM48 464V48h160v104c0 13.255 10.745 24 24 24h104v288H48zm228.687-211.303L224 305.374V268c0-11.046-8.954-20-20-20H100c-11.046 0-20 8.954-20 20v104c0 11.046 8.954 20 20 20h104c11.046 0 20-8.954 20-20v-37.374l52.687 52.674C286.704 397.318 304 390.28 304 375.986V264.011c0-14.311-17.309-21.319-27.313-11.314z" />
<path id="word"
d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm220.1-208c-5.7 0-10.6 4-11.7 9.5-20.6 97.7-20.4 95.4-21 103.5-.2-1.2-.4-2.6-.7-4.3-.8-5.1.3.2-23.6-99.5-1.3-5.4-6.1-9.2-11.7-9.2h-13.3c-5.5 0-10.3 3.8-11.7 9.1-24.4 99-24 96.2-24.8 103.7-.1-1.1-.2-2.5-.5-4.2-.7-5.2-14.1-73.3-19.1-99-1.1-5.6-6-9.7-11.8-9.7h-16.8c-7.8 0-13.5 7.3-11.7 14.8 8 32.6 26.7 109.5 33.2 136 1.3 5.4 6.1 9.1 11.7 9.1h25.2c5.5 0 10.3-3.7 11.6-9.1l17.9-71.4c1.5-6.2 2.5-12 3-17.3l2.9 17.3c.1.4 12.6 50.5 17.9 71.4 1.3 5.3 6.1 9.1 11.6 9.1h24.7c5.5 0 10.3-3.7 11.6-9.1 20.8-81.9 30.2-119 34.5-136 1.9-7.6-3.8-14.9-11.6-14.9h-15.8z" />
</defs>
</svg>
{% set paths_length = paths | length -%}
<header id="header">
<h1>
<nav>
<span>
<a href="/"> / </a>
</span>
{% for path in paths %}
{% for path in paths -%}
<span>
<a href="./{% for i in range(end=paths | length - loop.index) %}../{% endfor %}">{{ path }} /
</a>
</span>
{% endfor %}
{% endfor -%}
</nav>
</h1>
</header>
<main>
<div id="meta" style="font-size: 0.75rem; padding: 1.05rem 5%">
<span style="margin-right: 1rem"><b>{{ dirs | length }}</b> directories</span>
<span><b>{{ files | length }}</b> files</span>
<div id="meta">
{% set dir_length = dirs | length -%}
{% set file_length = files | length -%}
<span><b>{{ dir_length }}</b> directories</span>
<span><b>{{ file_length }}</b> files</span>
</div>
<div id="listing">
<table style="border-top: 1px dashed #cccccc">
<thead style="height: 3rem">
<table>
<thead>
<tr>
<th style="width: 5%"></th>
<th style="width: 80%">Name</th>
<th style="padding: 0 1.25rem">Size</th>
<th class="hideable" style="text-align: right">Modified</th>
<th class="hideable" style="width: 5%"></th>
<th></th>
<th>Name</th>
<th>Size</th>
<th class="hideable">Modified</th>
<th class="hideable"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 5%"></td>
<td style="width: 80%">
<a href="../"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="1.5rem" height="100%"
style="vertical-align: middle">
<path
d="M 25 7.21875 L 23.59375 8.65625 L 13.6875 18.53125 C 12.902344 19.316406 12.902344 20.589844 13.6875 21.375 C 14.472656 22.160156 15.746094 22.160156 16.53125 21.375 L 23 14.875 L 23 40 C 22.988281 40.722656 23.367188 41.390625 23.992188 41.753906 C 24.613281 42.121094 25.386719 42.121094 26.007813 41.753906 C 26.632813 41.390625 27.011719 40.722656 27 40 L 27 14.875 L 33.46875 21.375 C 34.253906 22.160156 35.527344 22.160156 36.3125 21.375 C 37.097656 20.589844 37.097656 19.316406 36.3125 18.53125 L 26.40625 8.65625 Z">
</path>
<tr class="goup">
<td></td>
<td>
<a href="../">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="1.5rem" height="100%">
<use xlink:href="#goup"></use>
</svg>
<span>Go up</span></a>
<span>Go up</span>
</a>
</td>
<td data-order="-1" style="padding: 0 1.25rem">-</td>
<td class="hideable" style="text-align: right">-</td>
<td style="width: 5%"></td>
<td data-order="-1">-</td>
<td class="hideable">-</td>
<td class="hideable"></td>
</tr>
{% for dir in dirs %}
{% for dir in dirs -%}
<tr class="dir">
<td style="width: 5%"></td>
<td style="width: 80%">
<a href="./{{ dir.name }}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="1.5rem"
height="100%" style="vertical-align: middle">
<path fill="#FFA000" d="M40,12H22l-4-4H8c-2.2,0-4,1.8-4,4v8h40v-4C44,13.8,42.2,12,40,12z" />
<path fill="#FFCA28"
d="M40,12H8c-2.2,0-4,1.8-4,4v20c0,2.2,1.8,4,4,4h32c2.2,0,4-1.8,4-4V16C44,13.8,42.2,12,40,12z" />
<td></td>
<td>
<a href="./{{ dir.name }}/">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="1.5rem" height="100%">
<use xlink:href="#folder1"></use>
<use xlink:href="#folder2"></use>
</svg>
<span>{{ dir.name }}</span></a>
<span>{{ dir.name }}</span>
</a>
</td>
<td data-order="-1" style="padding: 0 1.25rem">-</td>
<td class="hideable" style="text-align: right">
{{ dir.modified }}
<td data-order="-1">-</td>
<td class="hideable">
<time class="date" datetime="{{ dir.modified }}">{{ dir.modified }}</time>
</td>
<td class="hideable" style="width: 5%"></td>
<td class="hideable"></td>
</tr>
{% endfor %} {% for file in files %}
{% endfor -%}
{% for file in files -%}
<tr class="file">
<td style="width: 5%"></td>
<td style="width: 80%">
<a href="./{{ file.name }}"><svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
width="1.5rem" height="100%" style="vertical-align: middle">
<path
d="M 6 2 C 4.9057453 2 4 2.9057453 4 4 L 4 20 C 4 21.094255 4.9057453 22 6 22 L 18 22 C 19.094255 22 20 21.094255 20 20 L 20 8 L 14 2 L 6 2 z M 6 4 L 13 4 L 13 9 L 18 9 L 18 20 L 6 20 L 6 4 z" />
<td></td>
<td>
<a href="./{{ file.name }}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" width="1.5rem"
height="100%">
<use xlink:href="#{{ file.filetype }}"></use>
</svg>
<span>{{ file.name }}</span></a>
</td>
<td data-order="-1" style="padding: 0 1.25rem">
<td data-order="-1">
{{ file.size | filesizeformat |
replace(from="KB", to="KiB") |
replace(from="MB", to="MiB") |
@ -136,17 +289,28 @@
replace(from="ZB", to="ZiB") |
replace(from="YB", to="YiB") }}
</td>
<td class="hideable" style="text-align: right">
{{ file.modified }}
<td class="hideable">
<time class="date" datetime="{{ file.modified }}">{{ file.modified }}</time>
</td>
<td class="hideable" style="width: 5%"></td>
<td class="hideable"></td>
</tr>
{% endfor %}
{% endfor -%}
<tr></tr>
</tbody>
</table>
{% if dir_length + file_length == 0 -%}
<div style="text-align: center; margin: 1rem; color: #cccccc;">Nothing here</div>
{% endif -%}
</div>
</main>
<script>
(function () {
let dates = document.getElementsByClassName("date");
for (var date of dates) {
date.innerHTML = new Date(date.dateTime).toLocaleString([], { day: "2-digit", month: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit" })
};
})()
</script>
</body>
</html>