aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwyhaya <wyhaya@gmail.com>2019-07-04 03:16:55 +0000
committerwyhaya <wyhaya@gmail.com>2019-07-04 03:16:55 +0000
commit1db42b84ab288921b74a19becbc83d1f8cddc365 (patch)
treed93f98f0f1cbf50eb142a31a6c659eb58b6db607
parentMerge pull request #157 from svenstaro/dependabot/cargo/libflate-0.1.25 (diff)
downloadminiserve-1db42b84ab288921b74a19becbc83d1f8cddc365.tar.gz
miniserve-1db42b84ab288921b74a19becbc83d1f8cddc365.zip
accomplish #142
-rw-r--r--src/renderer.rs46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index d1e16ea..f8436c2 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -218,6 +218,20 @@ fn archive_button(
}
}
+// Append to the string after the link
+fn get_dir_last(link: &str) -> &str {
+ match link.chars().last() {
+ Some(d) => {
+ if d == '/' {
+ ""
+ }else {
+ "/"
+ }
+ },
+ None => "/"
+ }
+}
+
/// If they are set, adds query parameters to links to keep them across pages
fn parametrized_link(
link: &str,
@@ -228,7 +242,13 @@ fn parametrized_link(
) -> String {
if let Some(method) = sort_method {
if let Some(order) = sort_order {
- let parametrized_link = format!("{}?sort={}&order={}", link, method, order);
+ let parametrized_link = format!(
+ "{}{}?sort={}&order={}",
+ link,
+ get_dir_last(&link),
+ method,
+ order
+ );
if color_scheme != default_color_scheme {
return format!("{}&theme={}", parametrized_link, color_scheme.to_slug());
@@ -239,10 +259,15 @@ fn parametrized_link(
}
if color_scheme != default_color_scheme {
- return format!("{}?theme={}", link.to_string(), color_scheme.to_slug());
+ return format!(
+ "{}{}?theme={}",
+ link,
+ get_dir_last(&link),
+ color_scheme.to_slug()
+ );
}
- link.to_string()
+ format!("{}/", link)
}
/// Partial: table header link
@@ -672,6 +697,21 @@ fn css(color_scheme: ColorScheme) -> Markup {
.mobile-info {{
display: block;
}}
+ table tbody tr td {{
+ padding-top: 10px;
+ padding-bottom: 0;
+ }}
+ a.directory {{
+ display: block;
+ padding: 0.5625rem 0;
+ }}
+ .file-entry {{
+ align-items: center;
+ }}
+ a.file {{
+ flex: 1;
+ padding: 0.5625rem 0;
+ }}
.back {{
display: flex;
}}