aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock44
-rw-r--r--Cargo.toml2
-rw-r--r--src/listing.rs3
-rw-r--r--src/renderer.rs116
4 files changed, 93 insertions, 72 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1d0576c..86cc109 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -71,7 +71,7 @@ dependencies = [
"flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -112,7 +112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -143,7 +143,7 @@ dependencies = [
[[package]]
name = "arc-swap"
-version = "0.3.9"
+version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -187,7 +187,7 @@ dependencies = [
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -499,7 +499,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -564,7 +564,7 @@ dependencies = [
[[package]]
name = "h2"
-version = "0.1.17"
+version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -688,7 +688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libflate"
-version = "0.1.21"
+version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -792,7 +792,7 @@ dependencies = [
[[package]]
name = "miniserve"
-version = "0.4.0"
+version = "0.4.1"
dependencies = [
"actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -806,7 +806,7 @@ dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libflate 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"maud 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nanoid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1224,7 +1224,7 @@ dependencies = [
[[package]]
name = "rustc-demangle"
-version = "0.1.13"
+version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -1283,7 +1283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1317,7 +1317,7 @@ name = "signal-hook"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "arc-swap 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1389,7 +1389,7 @@ dependencies = [
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1405,12 +1405,12 @@ dependencies = [
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
-version = "0.15.30"
+version = "0.15.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1425,7 +1425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1850,7 +1850,7 @@ dependencies = [
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1953,7 +1953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c"
"checksum alphanumeric-sort 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7cd2580c95c654d681db0194a310af67a293f5e1c8bafa5b35b63269c4665a39"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
-"checksum arc-swap 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcee9b73d8a058eebb0b567fd3687f6761fb232049f92c23bdd2c82b6fe0c0cc"
+"checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841"
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392"
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
@@ -2005,7 +2005,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981"
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
-"checksum h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "910a5e7be6283a9c91b3982fa5188368c8719cce2a3cf3b86048673bf9d9c36b"
+"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e"
"checksum htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163"
@@ -2021,7 +2021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
-"checksum libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "7346a83e8a2c3958d44d24225d905385dc31fc16e89dffb356c457b278914d20"
+"checksum libflate 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c52384aeb22d0ce82a10d8ddf35f7fb4717d1b23eac5b94cd38d2050fb53766a"
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
"checksum literalext 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2f42dd699527975a1e0d722e0707998671188a0125f2051d2d192fc201184a81"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
@@ -2079,7 +2079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
"checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb"
"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a"
-"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
+"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
@@ -2105,7 +2105,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6"
"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f"
"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e"
-"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
+"checksum syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b4cfac95805274c6afdb12d8f770fa2d27c045953e7b630a81801953699a9a"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2167ff53da2a661702b3299f71a91b61b1dffef36b4b2884b1f9c67254c0133"
"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
diff --git a/Cargo.toml b/Cargo.toml
index 43a32f9..731927f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "miniserve"
-version = "0.4.0"
+version = "0.4.1"
description = "For when you really just want to serve some files over HTTP right now!"
authors = ["Sven-Hendrik Haase <svenstaro@gmail.com>", "Boastful Squirrel <boastful.squirrel@gmail.com>"]
repository = "https://github.com/svenstaro/miniserve"
diff --git a/src/listing.rs b/src/listing.rs
index fdabc48..aa0ba05 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -240,7 +240,7 @@ pub fn directory_listing<S>(
}
}
- let color_scheme = color_scheme.unwrap_or(default_color_scheme);
+ let color_scheme = color_scheme.unwrap_or(default_color_scheme.clone());
if let Some(compression_method) = &download {
log::info!(
@@ -280,6 +280,7 @@ pub fn directory_listing<S>(
page_parent,
sort_method,
sort_order,
+ default_color_scheme,
color_scheme,
file_upload,
&upload_route,
diff --git a/src/renderer.rs b/src/renderer.rs
index cf30d4a..bccfb05 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -4,19 +4,20 @@ use maud::{html, Markup, PreEscaped, DOCTYPE};
use std::time::SystemTime;
use strum::IntoEnumIterator;
-use crate::archive;
-use crate::listing;
-use crate::themes;
+use crate::archive::CompressionMethod;
+use crate::listing::{Entry, SortingMethod, SortingOrder};
+use crate::themes::ColorScheme;
/// Renders the file listing
pub fn page(
page_title: &str,
- entries: Vec<listing::Entry>,
+ entries: Vec<Entry>,
is_root: bool,
page_parent: Option<String>,
- sort_method: Option<listing::SortingMethod>,
- sort_order: Option<listing::SortingOrder>,
- color_scheme: themes::ColorScheme,
+ sort_method: Option<SortingMethod>,
+ sort_order: Option<SortingOrder>,
+ default_color_scheme: ColorScheme,
+ color_scheme: ColorScheme,
file_upload: bool,
upload_route: &str,
current_dir: &str,
@@ -31,13 +32,13 @@ pub fn page(
}
}
}
- (color_scheme_selector(&sort_method, &sort_order, &color_scheme))
+ (color_scheme_selector(&sort_method, &sort_order, &color_scheme, &default_color_scheme))
div.container {
span#top { }
h1.title { (page_title) }
div.toolbar {
div.download {
- @for compression_method in archive::CompressionMethod::iter() {
+ @for compression_method in CompressionMethod::iter() {
(archive_button(compression_method))
}
}
@@ -55,9 +56,9 @@ pub fn page(
}
table {
thead {
- th { (build_link("name", "Name", &sort_method, &sort_order, &color_scheme)) }
- th { (build_link("size", "Size", &sort_method, &sort_order, &color_scheme)) }
- th { (build_link("date", "Last modification", &sort_method, &sort_order, &color_scheme)) }
+ th { (build_link("name", "Name", &sort_method, &sort_order, &color_scheme, &default_color_scheme)) }
+ th { (build_link("size", "Size", &sort_method, &sort_order, &color_scheme, &default_color_scheme)) }
+ th { (build_link("date", "Last modification", &sort_method, &sort_order, &color_scheme, &default_color_scheme)) }
}
tbody {
@if !is_root {
@@ -65,7 +66,7 @@ pub fn page(
tr {
td colspan="3" {
span.root-chevron { (chevron_left()) }
- a.root href=(parametrized_link(&parent, &sort_method, &sort_order, &color_scheme)) {
+ a.root href=(parametrized_link(&parent, &sort_method, &sort_order, &color_scheme, &default_color_scheme)) {
"Parent directory"
}
}
@@ -73,7 +74,7 @@ pub fn page(
}
}
@for entry in entries {
- (entry_row(entry, &sort_method, &sort_order, &color_scheme))
+ (entry_row(entry, &sort_method, &sort_order, &color_scheme, &default_color_scheme))
}
}
}
@@ -87,9 +88,10 @@ pub fn page(
/// Partial: color scheme selector
fn color_scheme_selector(
- sort_method: &Option<listing::SortingMethod>,
- sort_order: &Option<listing::SortingOrder>,
- active_color_scheme: &themes::ColorScheme,
+ sort_method: &Option<SortingMethod>,
+ sort_order: &Option<SortingOrder>,
+ active_color_scheme: &ColorScheme,
+ default_color_scheme: &ColorScheme,
) -> Markup {
html! {
nav {
@@ -99,14 +101,14 @@ fn color_scheme_selector(
"Change theme..."
}
ul {
- @for color_scheme in themes::ColorScheme::iter() {
+ @for color_scheme in ColorScheme::iter() {
@if active_color_scheme == &color_scheme {
li.active {
- (color_scheme_link(&sort_method, &sort_order, &color_scheme))
+ (color_scheme_link(&sort_method, &sort_order, &color_scheme, &default_color_scheme))
}
} @else {
li {
- (color_scheme_link(&sort_method, &sort_order, &color_scheme))
+ (color_scheme_link(&sort_method, &sort_order, &color_scheme, &default_color_scheme))
}
}
}
@@ -119,11 +121,18 @@ fn color_scheme_selector(
/// Partial: color scheme link
fn color_scheme_link(
- sort_method: &Option<listing::SortingMethod>,
- sort_order: &Option<listing::SortingOrder>,
- color_scheme: &themes::ColorScheme,
+ sort_method: &Option<SortingMethod>,
+ sort_order: &Option<SortingOrder>,
+ color_scheme: &ColorScheme,
+ default_color_scheme: &ColorScheme,
) -> Markup {
- let link = parametrized_link("", &sort_method, &sort_order, &color_scheme);
+ let link = parametrized_link(
+ "",
+ &sort_method,
+ &sort_order,
+ &color_scheme,
+ &default_color_scheme,
+ );
let title = format!("Switch to {} theme", color_scheme);
html! {
@@ -140,7 +149,7 @@ fn color_scheme_link(
}
/// Partial: archive button
-fn archive_button(compress_method: archive::CompressionMethod) -> Markup {
+fn archive_button(compress_method: CompressionMethod) -> Markup {
let link = format!("?download={}", compress_method);
let text = format!("Download .{}", compress_method.extension());
@@ -154,32 +163,38 @@ fn archive_button(compress_method: archive::CompressionMethod) -> Markup {
/// If they are set, adds query parameters to links to keep them across pages
fn parametrized_link(
link: &str,
- sort_method: &Option<listing::SortingMethod>,
- sort_order: &Option<listing::SortingOrder>,
- color_scheme: &themes::ColorScheme,
+ sort_method: &Option<SortingMethod>,
+ sort_order: &Option<SortingOrder>,
+ color_scheme: &ColorScheme,
+ default_color_scheme: &ColorScheme,
) -> String {
if let Some(method) = sort_method {
if let Some(order) = sort_order {
- return format!(
- "{}?sort={}&order={}&theme={}",
- link,
- method,
- order,
- color_scheme.to_slug()
- );
+ let parametrized_link = format!("{}?sort={}&order={}", link, method, order);
+
+ if color_scheme != default_color_scheme {
+ return format!("{}&theme={}", parametrized_link, color_scheme.to_slug());
+ }
+
+ return parametrized_link;
}
}
- format!("{}?theme={}", link.to_string(), color_scheme.to_slug())
+ if color_scheme != default_color_scheme {
+ return format!("{}?theme={}", link.to_string(), color_scheme.to_slug());
+ }
+
+ link.to_string()
}
/// Partial: table header link
fn build_link(
name: &str,
title: &str,
- sort_method: &Option<listing::SortingMethod>,
- sort_order: &Option<listing::SortingOrder>,
- color_scheme: &themes::ColorScheme,
+ sort_method: &Option<SortingMethod>,
+ sort_order: &Option<SortingOrder>,
+ color_scheme: &ColorScheme,
+ default_color_scheme: &ColorScheme,
) -> Markup {
let mut link = format!("?sort={}&order=asc", name);
let mut help = format!("Sort by {} in ascending order", name);
@@ -199,27 +214,32 @@ fn build_link(
}
};
+ if color_scheme != default_color_scheme {
+ link = format!("{}&theme={}", &link, color_scheme.to_slug());
+ }
+
html! {
span class=(class) {
span.chevron { (chevron) }
- a href=(format!("{}&theme={}", &link, color_scheme.to_slug())) title=(help) { (title) }
+ a href=(link) title=(help) { (title) }
}
}
}
/// Partial: row for an entry
fn entry_row(
- entry: listing::Entry,
- sort_method: &Option<listing::SortingMethod>,
- sort_order: &Option<listing::SortingOrder>,
- color_scheme: &themes::ColorScheme,
+ entry: Entry,
+ sort_method: &Option<SortingMethod>,
+ sort_order: &Option<SortingOrder>,
+ color_scheme: &ColorScheme,
+ default_color_scheme: &ColorScheme,
) -> Markup {
html! {
tr {
td {
p {
@if entry.is_dir() {
- a.directory href=(parametrized_link(&entry.link, &sort_method, &sort_order, &color_scheme)) {
+ a.directory href=(parametrized_link(&entry.link, &sort_method, &sort_order, &color_scheme, &default_color_scheme)) {
(entry.name) "/"
}
} @else if entry.is_file() {
@@ -234,7 +254,7 @@ fn entry_row(
}
}
} @else if entry.is_symlink() {
- a.symlink href=(parametrized_link(&entry.link, &sort_method, &sort_order, &color_scheme)) {
+ a.symlink href=(parametrized_link(&entry.link, &sort_method, &sort_order, &color_scheme, &default_color_scheme)) {
(entry.name) span.symlink-symbol { "⇢" }
}
}
@@ -264,7 +284,7 @@ fn entry_row(
}
/// Partial: CSS
-fn css(color_scheme: &themes::ColorScheme) -> Markup {
+fn css(color_scheme: &ColorScheme) -> Markup {
let theme = color_scheme.clone().get_theme();
let css = format!("
@@ -658,7 +678,7 @@ fn chevron_down() -> Markup {
}
/// Partial: page header
-fn page_header(page_title: &str, color_scheme: &themes::ColorScheme, file_upload: bool) -> Markup {
+fn page_header(page_title: &str, color_scheme: &ColorScheme, file_upload: bool) -> Markup {
html! {
(DOCTYPE)
html {