Skip to main content

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_text_item, rumtk_web_render_component,
27    rumtk_web_render_html, RUMWebTemplate,
28};
29use askama::Template;
30
31#[derive(RUMWebTemplate)]
32#[template(
33    source = "
34        <body class='f12 theme-{{theme}}'>
35            <a href='#main-content'>Skip to main content</a>
36            {{header|safe}}
37            {{main|safe}}
38            {{footer|safe}}
39        </body>
40    ",
41    ext = "html"
42)]
43pub struct AppBody {
44    theme: RUMString,
45    header: RUMString,
46    main: RUMString,
47    footer: RUMString,
48}
49
50pub fn app_body(path_components: URLPath, params: URLParams, state: SharedAppState) -> HTMLResult {
51    let theme = rumtk_web_get_text_item!(params, "theme", DEFAULT_TEXT_ITEM);
52
53    //Let's render the header and footer
54    //<div class="" hx-get="/component/navbar" hx-target="#navbar" hx-trigger="load" id="navbar"></div>
55    let header = rumtk_web_render_component!("header", [("", "")], state);
56    let main = rumtk_web_render_component!("main", path_components, [("", "")], state);
57    //<div class="" hx-get="/component/footer?social_list=linkedin,github" hx-target="#footer" hx-trigger="load" id="footer"></div>
58    let footer = rumtk_web_render_component!(
59        "footer",
60        [(
61            "social_list",
62            state
63                .read()
64                .expect("Lock failure")
65                .get_config()
66                .footer_conf
67                .socials_list
68                .clone()
69        )],
70        state
71    );
72
73    rumtk_web_render_html!(AppBody {
74        theme: RUMString::from(theme),
75        header,
76        main,
77        footer
78    })
79}