diff options
author | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-03-08 18:59:59 +0000 |
---|---|---|
committer | boasting-squirrel <boasting.squirrel@gmail.com> | 2019-03-08 18:59:59 +0000 |
commit | 9857f26bdd4e9e87b13a9755b1e00569e9459238 (patch) | |
tree | c4059052c21c3049666cc180321224ac217c83b2 /src/renderer.rs | |
parent | Merge pull request #44 from boastful-squirrel/header-sorting (diff) | |
download | miniserve-9857f26bdd4e9e87b13a9755b1e00569e9459238.tar.gz miniserve-9857f26bdd4e9e87b13a9755b1e00569e9459238.zip |
Download folder as a tar working
Diffstat (limited to 'src/renderer.rs')
-rw-r--r-- | src/renderer.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 89a9248..b83a67c 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -3,6 +3,7 @@ use chrono_humanize::{Accuracy, HumanTime, Tense}; use maud::{html, Markup, PreEscaped, DOCTYPE}; use std::time::SystemTime; +use crate::archive; use crate::listing; /// Renders the file listing @@ -19,6 +20,9 @@ pub fn page( body { span #top { } h1 { (page_title) } + div.download { + (archive_button(archive::CompressionMethod::TarGz)) + } table { thead { th { (build_link("name", "Name", &sort_method, &sort_order)) } @@ -50,6 +54,18 @@ pub fn page( } } +/// Partial: archive button +fn archive_button(compress_method: archive::CompressionMethod) -> Markup { + let link = format!("?download={}", compress_method.to_string()); + let text = format!("Download .{}", compress_method.extension()); + + html! { + a href=(link) { + (text) + } + } +} + /// Partial: table header link fn build_link( name: &str, @@ -259,6 +275,25 @@ fn css() -> Markup { color: #3498db; text-decoration: none; } + .download { + display: flex; + justify-content: flex-end; + padding: 0.125rem; + } + .download a, .download a:visited { + color: #3498db; + } + .download a { + background: #efefef; + padding: 0.5rem; + border-radius: 0.2rem; + } + .download a:hover { + background: #deeef7a6; + } + .download a:not(:last-of-type) { + margin-right: 1rem; + } @media (max-width: 600px) { h1 { font-size: 1.375em; |