Skip to main content

rumtk_web/components/
app_head.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. <lsantos@medicalmasses.com>
5 * Copyright (C) 2025  Ethan Dixon
6 * Copyright (C) 2025  MedicalMasses L.L.C. <contact@medicalmasses.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 */
21use crate::static_components::{css::css, fontawesome::fontawesome, htmx::htmx, meta::meta};
22use crate::utils::types::{HTMLResult, RUMString, SharedAppState, URLParams, URLPath};
23use crate::{rumtk_web_render_component, rumtk_web_render_html, RUMWebTemplate};
24
25#[derive(RUMWebTemplate)]
26#[template(
27    source = "
28        <head>
29            {{meta|safe}}
30            {{css|safe}}
31            {{fontawesome|safe}}
32            {{htmx|safe}}
33        </head>
34    ",
35    ext = "html"
36)]
37pub struct AppShellHead {
38    meta: RUMString,
39    css: RUMString,
40    fontawesome: RUMString,
41    htmx: RUMString,
42}
43
44///
45///     !!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46///
47///      The snippet below will add key static imports relying on CDN free bandwidth where possible.
48///      Keep in mind this can be dangerous security wise if the CDN or DNS services are manipulated
49///      because we will fallback on a local file version that may be of an older version.
50///
51///      It is not ideal but it will allow continuance of service for websites during CDN outages
52///      which do happen.
53///
54pub fn app_head(
55    _path_components: URLPath,
56    _params: URLParams,
57    state: SharedAppState,
58) -> HTMLResult {
59    //Let's render the head component
60    let html_meta = rumtk_web_render_component!(meta, state);
61
62    //Let's render the head component
63    let html_css = rumtk_web_render_component!(css);
64
65    //Let's render the head component
66    let html_fontawesome = rumtk_web_render_component!(fontawesome);
67
68    //Let's render the head component
69    let html_htmx = rumtk_web_render_component!(htmx);
70
71    rumtk_web_render_html!(AppShellHead {
72        meta: html_meta,
73        css: html_css,
74        fontawesome: html_fontawesome,
75        htmx: html_htmx
76    })
77}