aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer.rs')
-rw-r--r--src/renderer.rs35
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;