aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2019-03-23 12:49:46 +0000
committerGitHub <noreply@github.com>2019-03-23 12:49:46 +0000
commitc47a7773228e4e1beddfdcc6719cbc10acfbfdb5 (patch)
treeb5ebbb5a4c80f9736484f9cd9112ef30956e4178 /src/renderer.rs
parentMerge pull request #49 from svenstaro/dependabot/cargo/structopt-0.2.15 (diff)
parentUpdated README with known limitations (diff)
downloadminiserve-c47a7773228e4e1beddfdcc6719cbc10acfbfdb5.tar.gz
miniserve-c47a7773228e4e1beddfdcc6719cbc10acfbfdb5.zip
Merge pull request #48 from boastful-squirrel/targz
Download folders in .tar.gz format
Diffstat (limited to 'src/renderer.rs')
-rw-r--r--src/renderer.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index 89a9248..66fc714 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
@@ -18,7 +19,10 @@ pub fn page(
(page_header(page_title))
body {
span #top { }
- h1 { (page_title) }
+ h1.title { (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,
@@ -166,6 +182,9 @@ fn css() -> Markup {
margin: 0;
padding: 0;
}
+ h1 {
+ font-size: 1.5rem;
+ }
table {
margin-top: 2rem;
width: 100%;
@@ -259,6 +278,27 @@ fn css() -> Markup {
color: #3498db;
text-decoration: none;
}
+ .download {
+ display: flex;
+ flex-wrap: wrap;
+ margin-top: .5rem;
+ padding: 0.125rem;
+ }
+ .download a, .download a:visited {
+ color: #3498db;
+ }
+ .download a {
+ background: #efefef;
+ padding: 0.5rem;
+ border-radius: 0.2rem;
+ margin-top: 1rem;
+ }
+ .download a:hover {
+ background: #deeef7a6;
+ }
+ .download a:not(:last-of-type) {
+ margin-right: 1rem;
+ }
@media (max-width: 600px) {
h1 {
font-size: 1.375em;