aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjikstra <jikstra@disroot.org>2021-09-10 14:23:26 +0000
committerjikstra <jikstra@disroot.org>2021-09-10 14:32:07 +0000
commit45650ea93b723db551fec8c77fbac5065c7659a6 (patch)
treefeeac7e6f4da2b7a99a6177f7ab52f0d44ac3253 /src
parentFix tests (diff)
downloadminiserve-45650ea93b723db551fec8c77fbac5065c7659a6.tar.gz
miniserve-45650ea93b723db551fec8c77fbac5065c7659a6.zip
Implement --show-wget-footer argument
Diffstat (limited to 'src')
-rw-r--r--src/args.rs4
-rw-r--r--src/config.rs4
-rw-r--r--src/renderer.rs6
3 files changed, 12 insertions, 2 deletions
diff --git a/src/args.rs b/src/args.rs
index ff8d92b..c610bbe 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -142,6 +142,10 @@ pub struct CliArgs {
#[clap(short = 'F', long = "hide-version-footer")]
pub hide_version_footer: bool,
+ /// If enabled, display a wget command to recursively download the current directory
+ #[clap(short = 'W', long = "show-wget-footer")]
+ pub show_wget_footer: bool,
+
/// Generate completion file for a shell
#[clap(long = "print-completions", value_name = "shell", possible_values = &Shell::variants())]
pub print_completions: Option<Shell>,
diff --git a/src/config.rs b/src/config.rs
index 86fe314..ce4e5d7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -101,6 +101,9 @@ pub struct MiniserveConfig {
/// If enabled, version footer is hidden
pub hide_version_footer: bool,
+ /// If enabled, display a wget command to recursively download the current directory
+ pub show_wget_footer: bool,
+
/// If set, use provided rustls config for TLS
#[cfg(feature = "tls")]
pub tls_rustls_config: Option<rustls::ServerConfig>,
@@ -192,6 +195,7 @@ impl MiniserveConfig {
header: args.header,
show_symlink_info: args.show_symlink_info,
hide_version_footer: args.hide_version_footer,
+ show_wget_footer: args.show_wget_footer,
tls_rustls_config: tls_rustls_server_config,
})
}
diff --git a/src/renderer.rs b/src/renderer.rs
index c0a243e..3c2d008 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -143,7 +143,9 @@ pub fn page(
(arrow_up())
}
div.footer {
- (wget_download(&title_path, current_user))
+ @if conf.show_wget_footer {
+ (wget_footer(&title_path, current_user))
+ }
@if !conf.hide_version_footer {
(version_footer())
}
@@ -195,7 +197,7 @@ fn version_footer() -> Markup {
}
}
-fn wget_download(title_path: &str, current_user: Option<&CurrentUser>) -> Markup {
+fn wget_footer(title_path: &str, current_user: Option<&CurrentUser>) -> Markup {
let count = {
let count_slashes = title_path.matches('/').count();
if count_slashes > 0 {