refactor: improve directory listing styling for html display
Diff
src/directory_listing.rs | 14 +++++---------
tests/toml/config.toml | 2 +-
2 files changed, 6 insertions(+), 10 deletions(-)
@@ -118,8 +118,9 @@ pub fn auto_index(
})
}
const STYLE: &str = r#"<style>html{background-color:#fff;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;min-width:20rem;text-rendering:optimizeLegibility;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}body{padding:1rem;font-family:Consolas,'Liberation Mono',Menlo,monospace;font-size:.875rem;max-width:70rem;margin:0 auto;color:#4a4a4a;font-weight:400;line-height:1.5}h1{margin:0;padding:0;font-size:1.375rem;line-height:1.25;margin-bottom:0.5rem;}table{width:100%;border-spacing: 0;}table th,table td{padding:.2rem .5rem;white-space:nowrap;vertical-align:top}table th a,table td a{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:95%;vertical-align:top}table tr:hover td{background-color:#f5f5f5}footer{padding-top:0.5rem}table tr th{text-align:left;}</style>"#;
const FOOTER: &str = r#"<footer>Powered by <a target="_blank" href="https://static-web-server.net">Static Web Server</a> | MIT & Apache 2.0</footer>"#;
const STYLE: &str = r#"<style>html{background-color:#fff;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;min-width:20rem;text-rendering:optimizeLegibility;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}body{padding:1rem;font-family:Consolas,'Liberation Mono',Menlo,monospace;font-size:.75rem;max-width:70rem;margin:0 auto;color:#4a4a4a;font-weight:400;line-height:1.5}h1{margin:0;padding:0;font-size:1.375rem;line-height:1.25;margin-bottom:0.5rem;}table{width:100%;border-spacing: 0;}table th,table td{padding:.15rem 0;white-space:nowrap;vertical-align:top}table th a,table td a{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:95%;vertical-align:top;}table tr:hover td{background-color:#f5f5f5}footer{padding-top:0.5rem}table tr th{text-align:left;}</style>"#;
const FOOTER: &str =
r#"<footer><em>Powered by Static Web Server (SWS) / static-web-server.net</em></footer>"#;
const DATETIME_FORMAT_UTC: &str = "%FT%TZ";
const DATETIME_FORMAT_LOCAL: &str = "%F %T";
@@ -458,14 +459,9 @@ fn html_auto_index<'a>(
}
let current_path = percent_decode_str(base_path).decode_utf8()?.to_string();
let dirs_str = if dirs_count == 1 {
"directory"
} else {
"directories"
};
let summary = format!(
"<div>{} {}, {} {}</div>",
dirs_count, dirs_str, files_count, "file(s)"
"<div>directories: {}, files: {}</div>",
dirs_count, files_count,
);
let html_page = format!(
@@ -38,7 +38,7 @@ directory-listing = true
directory-listing-order = 1
directory-listing-format = "json"
directory-listing-format = "html"
basic-auth = ""