rumtk_web/components/app_body.rs
1/*
2 * rumtk attempts to implement HL7 and medical protocols for interoperability in medicine.
3 * This toolkit aims to be reliable, simple, performant, and standards compliant.
4 * Copyright (C) 2025 Luis M. Santos, M.D.
5 * Copyright (C) 2025 Nick Stephenson
6 * Copyright (C) 2025 Ethan Dixon
7 * Copyright (C) 2025 MedicalMasses L.L.C.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23use crate::utils::defaults::DEFAULT_TEXT_ITEM;
24use crate::utils::types::{HTMLResult, RUMString, SharedAppState, URLParams, URLPath};
25use crate::{
26 rumtk_web_get_param, rumtk_web_get_text_item, rumtk_web_render_component, rumtk_web_render_html,
27};
28use askama::Template;
29
30#[derive(Template)]
31#[template(
32 source = "
33 <body class='f12 theme-{{theme}}'>
34 <a href='#main-content'>Skip to main content</a>
35 {{header|safe}}
36 {{main|safe}}
37 {{footer|safe}}
38 </body>
39 ",
40 ext = "html"
41)]
42pub struct AppBody {
43 theme: RUMString,
44 header: RUMString,
45 main: RUMString,
46 footer: RUMString,
47}
48
49pub fn app_body(path_components: URLPath, params: URLParams, state: SharedAppState) -> HTMLResult {
50 let page: RUMString =
51 rumtk_web_get_param!(path_components, 0, RUMString::from(DEFAULT_TEXT_ITEM));
52 let theme = rumtk_web_get_text_item!(params, "theme", DEFAULT_TEXT_ITEM);
53
54 //Let's render the header and footer
55 //<div class="" hx-get="/component/navbar" hx-target="#navbar" hx-trigger="load" id="navbar"></div>
56 let header = rumtk_web_render_component!("header", [("", "")], state);
57 let main = rumtk_web_render_component!("main", [("", "")], state);
58 //<div class="" hx-get="/component/footer?social_list=linkedin,github" hx-target="#footer" hx-trigger="load" id="footer"></div>
59 let footer = rumtk_web_render_component!(
60 "footer",
61 [(
62 "social_list",
63 state
64 .read()
65 .expect("Lock failure")
66 .config
67 .footer_conf
68 .socials_list
69 .clone()
70 )],
71 state
72 );
73
74 rumtk_web_render_html!(AppBody {
75 theme: RUMString::from(theme),
76 header,
77 main,
78 footer
79 })
80}