diff options
author | Lukas Stabe <lukas@stabe.de> | 2020-09-26 02:45:31 +0000 |
---|---|---|
committer | Lukas Stabe <lukas@stabe.de> | 2020-09-26 02:45:31 +0000 |
commit | dab13c9bb3336aac4e44171f3074c4ce973b9782 (patch) | |
tree | 1e4592b6c38e9d230b76d9e0d485cb4be7c4f6f2 /src/renderer.rs | |
parent | [wip] client-side color-scheme handling (diff) | |
download | miniserve-dab13c9bb3336aac4e44171f3074c4ce973b9782.tar.gz miniserve-dab13c9bb3336aac4e44171f3074c4ce973b9782.zip |
move css out of html into its own route
Diffstat (limited to 'src/renderer.rs')
-rw-r--r-- | src/renderer.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index dedd028..0f11c25 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -20,6 +20,7 @@ pub fn page( file_upload: bool, upload_route: &str, favicon_route: &str, + css_route: &str, encoded_dir: &str, breadcrumbs: Vec<Breadcrumb>, tar_enabled: bool, @@ -36,7 +37,7 @@ pub fn page( html! { (DOCTYPE) html { - (page_header(&title_path, file_upload, favicon_route)) + (page_header(&title_path, file_upload, favicon_route, css_route)) body#drop-container { (PreEscaped(r#" <script> @@ -340,14 +341,6 @@ fn entry_row( } } -lazy_static::lazy_static! { - static ref CSS_TEXT: String = grass::from_string(include_str!("../data/style.scss").to_string(), &grass::Options::default()).unwrap(); -} -/// Partial: CSS -fn css() -> Markup { - PreEscaped(CSS_TEXT.clone()) -} - /// Partial: up arrow fn arrow_up() -> Markup { PreEscaped("⇪".to_string()) @@ -369,16 +362,17 @@ fn chevron_down() -> Markup { } /// Partial: page header -fn page_header(title: &str, file_upload: bool, favicon_route: &str) -> Markup { +fn page_header(title: &str, file_upload: bool, favicon_route: &str, css_route: &str) -> Markup { html! { head { meta charset="utf-8"; meta http-equiv="X-UA-Compatible" content="IE=edge"; meta name="viewport" content="width=device-width, initial-scale=1"; + link rel="icon" type="image/svg+xml" href={ "/" (favicon_route) }; - title { (title) } + link rel="stylesheet" href={ "/" (css_route) }; - style { (css()) } + title { (title) } @if file_upload { (PreEscaped(r#" @@ -452,6 +446,7 @@ pub fn render_error( has_referer: bool, display_back_link: bool, favicon_route: &str, + css_route: &str, ) -> Markup { let link = if has_referer { return_address.to_string() @@ -462,7 +457,7 @@ pub fn render_error( html! { (DOCTYPE) html { - (page_header(&error_code.to_string(), false, favicon_route)) + (page_header(&error_code.to_string(), false, favicon_route, css_route)) body { div.error { p { (error_code.to_string()) } |