diff options
author | FLAMINGO <flamingodev@outlook.com> | 2022-05-23 04:05:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 04:05:41 +0000 |
commit | 0db44057a8f49f34aaf0c229942efc1060d6f319 (patch) | |
tree | a4e75346b87d661930d1f37ea80a30c7be74c063 | |
parent | Bump deps (diff) | |
download | miniserve-0db44057a8f49f34aaf0c229942efc1060d6f319.tar.gz miniserve-0db44057a8f49f34aaf0c229942efc1060d6f319.zip |
Add configuration `change-theme` (#805)
Add configuration `change-theme`Add configuration `change-theme`
Diffstat (limited to '')
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/config.rs | 4 | ||||
-rw-r--r-- | src/renderer.rs | 22 |
3 files changed, 20 insertions, 10 deletions
diff --git a/src/args.rs b/src/args.rs index 757fd22..3ddfe8b 100644 --- a/src/args.rs +++ b/src/args.rs @@ -83,6 +83,10 @@ pub struct CliArgs { #[clap(short = 'H', long = "hidden")] pub hidden: bool, + /// Show theme selector in frontend + #[clap(long = "change-theme")] + pub change_theme: bool, + /// Default color scheme #[clap( short = 'c', diff --git a/src/config.rs b/src/config.rs index 29e4c5c..d81d47e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -81,6 +81,9 @@ pub struct MiniserveConfig { /// Enable QR code display pub show_qrcode: bool, + /// Show theme selector in frontend + pub show_change_theme: bool, + /// Enable file upload pub file_upload: bool, @@ -225,6 +228,7 @@ impl MiniserveConfig { spa: args.spa, overwrite_files: args.overwrite_files, show_qrcode: args.qrcode, + show_change_theme: args.change_theme, file_upload: args.file_upload, uploadable_media_type, tar_enabled: args.enable_tar, diff --git a/src/renderer.rs b/src/renderer.rs index c64d459..e2e2efb 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -76,7 +76,7 @@ pub fn page( } } } - (color_scheme_selector(conf.show_qrcode)) + (color_scheme_selector(conf.show_qrcode, conf.show_change_theme)) div.container { span #top { } h1.title dir="ltr" { @@ -254,7 +254,7 @@ const THEME_PICKER_CHOICES: &[(&str, &str)] = &[ pub const THEME_SLUGS: &[&str] = &["squirrel", "archlinux", "zenburn", "monokai"]; /// Partial: color scheme selector -fn color_scheme_selector(show_qrcode: bool) -> Markup { +fn color_scheme_selector(show_qrcode: bool, show_change_theme: bool) -> Markup { html! { nav { @if show_qrcode { @@ -267,14 +267,16 @@ fn color_scheme_selector(show_qrcode: bool) -> Markup { } } } - div { - p { - "Change theme..." - } - ul.theme { - @for color_scheme in THEME_PICKER_CHOICES { - li.(format!("theme_{}", color_scheme.1)) { - (color_scheme_link(color_scheme)) + @if show_change_theme { + div { + p { + "Change theme..." + } + ul.theme { + @for color_scheme in THEME_PICKER_CHOICES { + li.(format!("theme_{}", color_scheme.1)) { + (color_scheme_link(color_scheme)) + } } } } |