diff options
author | Lukas Stabe <lukas@stabe.de> | 2020-10-01 16:08:05 +0000 |
---|---|---|
committer | Lukas Stabe <lukas@stabe.de> | 2020-10-01 16:08:05 +0000 |
commit | 47895cad827180787a8f305ddac0372d2dbd266a (patch) | |
tree | b317c8e8f727ecee75a9e69c224b6f67acf1b4c2 /src/renderer.rs | |
parent | fix build.rs rerun-if-changed (diff) | |
download | miniserve-47895cad827180787a8f305ddac0372d2dbd266a.tar.gz miniserve-47895cad827180787a8f305ddac0372d2dbd266a.zip |
restore default theme cli option and add default theme dark option
Diffstat (limited to 'src/renderer.rs')
-rw-r--r-- | src/renderer.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 2ebe214..61e382e 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -20,6 +20,8 @@ pub fn page( upload_route: &str, favicon_route: &str, css_route: &str, + default_color_scheme: &str, + default_color_scheme_dark: &str, encoded_dir: &str, breadcrumbs: Vec<Breadcrumb>, tar_enabled: bool, @@ -37,7 +39,7 @@ pub fn page( (DOCTYPE) html { (page_header(&title_path, file_upload, favicon_route, css_route)) - body#drop-container { + body#drop-container.(format!("default_theme_{}", default_color_scheme)).(format!("default_theme_dark_{}", default_color_scheme_dark)) { (PreEscaped(r#" <script> const body = document.body; @@ -153,7 +155,7 @@ fn build_upload_action( upload_action } -const THEMES: &[(&str, &str)] = &[ +const THEME_PICKER_CHOICES: &[(&str, &str)] = &[ ("Default (light/dark)", "default"), ("Squirrel (light)", "squirrel"), ("Archlinux (dark)", "archlinux"), @@ -161,6 +163,8 @@ const THEMES: &[(&str, &str)] = &[ ("Monokai (dark)", "monokai"), ]; +pub const THEME_SLUGS: &[&str] = &["squirrel", "archlinux", "zenburn", "monokai"]; + /// Partial: color scheme selector fn color_scheme_selector(show_qrcode: bool) -> Markup { html! { @@ -180,7 +184,7 @@ fn color_scheme_selector(show_qrcode: bool) -> Markup { "Change theme..." } ul.theme { - @for color_scheme in THEMES { + @for color_scheme in THEME_PICKER_CHOICES { li.(format!("theme_{}", color_scheme.1)) { (color_scheme_link(color_scheme)) } @@ -452,6 +456,8 @@ pub fn render_error( display_back_link: bool, favicon_route: &str, css_route: &str, + default_color_scheme: &str, + default_color_scheme_dark: &str, ) -> Markup { let link = if has_referer { return_address.to_string() @@ -463,7 +469,7 @@ pub fn render_error( (DOCTYPE) html { (page_header(&error_code.to_string(), false, favicon_route, css_route)) - body { + body.(format!("default_theme_{}", default_color_scheme)).(format!("default_theme_dark_{}", default_color_scheme_dark)) { div.error { p { (error_code.to_string()) } @for error in error_description.lines() { |