From a99d8bdcadf4f822bb86a2710e5d73783ac7097a Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 26 Jul 2022 12:27:14 +0800 Subject: Move QR code page style to `style.scss` --- src/renderer.rs | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'src/renderer.rs') diff --git a/src/renderer.rs b/src/renderer.rs index 95aeb5f..0154ce0 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -18,7 +18,7 @@ pub fn page( readme: Option<(String, String)>, is_root: bool, query_params: QueryParameters, - breadcrumbs: Vec, + breadcrumbs: &[Breadcrumb], encoded_dir: &str, conf: &MiniserveConfig, current_user: Option<&CurrentUser>, @@ -34,11 +34,7 @@ pub fn page( let upload_action = build_upload_action(&upload_route, encoded_dir, sort_method, sort_order); let mkdir_action = build_mkdir_action(&upload_route, encoded_dir); - let title_path = breadcrumbs - .iter() - .map(|el| el.name.clone()) - .collect::>() - .join("/"); + let title_path = breadcrumbs_to_path_string(breadcrumbs); html! { (DOCTYPE) @@ -226,34 +222,16 @@ pub fn raw(entries: Vec, is_root: bool) -> Markup { } /// Renders the QR code page -pub fn qr_code_page(qr: &QrCode) -> Markup { +pub fn qr_code_page(breadcrumbs: &[Breadcrumb], qr: &QrCode, conf: &MiniserveConfig) -> Markup { use qrcode::render::svg; + let title = breadcrumbs_to_path_string(breadcrumbs); + html! { (DOCTYPE) - html { - body.qr_code_page { - // make QR code expand and fill page - style { - (PreEscaped("\ - html {\ - width: 100vw;\ - height: 100vh;\ - }\ - body {\ - width: 100%;\ - height: 100%;\ - margin: 0;\ - display: grid;\ - align-items: center;\ - justify-items: center;\ - }\ - svg {\ - width: 80%;\ - height: 80%;\ - }\ - ")) - } + html.qr_code_page { + (page_header(&title, false, &conf.favicon_route, &conf.css_route)) + body { (PreEscaped(qr.render() .quiet_zone(false) .dark_color(svg::Color("#000000")) @@ -264,6 +242,15 @@ pub fn qr_code_page(qr: &QrCode) -> Markup { } } +/// Build a path string from a list of breadcrumbs. +fn breadcrumbs_to_path_string(breadcrumbs: &[Breadcrumb]) -> String { + breadcrumbs + .iter() + .map(|el| el.name.clone()) + .collect::>() + .join("/") +} + // Partial: version footer fn version_footer() -> Markup { html! { -- cgit v1.2.3