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.
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::static_components::{css::css, fontawesome::fontawesome, htmx::htmx, meta::meta};
24use crate::utils::types::{HTMLResult, RUMString, SharedAppState, URLParams, URLPath};
25use crate::{rumtk_web_render_component, rumtk_web_render_html};
26use askama::Template;
27
28#[derive(Template)]
29#[template(
30 source = "
31 <head>
32 {{meta|safe}}
33 {{css|safe}}
34 {{fontawesome|safe}}
35 {{htmx|safe}}
36 </head>
37 ",
38 ext = "html"
39)]
40pub struct AppShellHead {
41 meta: RUMString,
42 css: RUMString,
43 fontawesome: RUMString,
44 htmx: RUMString,
45}
46
47///
48/// !!!!!!!!!!!!!!!!!!!!!!!WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49///
50/// The snippet below will add key static imports relying on CDN free bandwidth where possible.
51/// Keep in mind this can be dangerous security wise if the CDN or DNS services are manipulated
52/// because we will fallback on a local file version that may be of an older version.
53///
54/// It is not ideal but it will allow continuance of service for websites during CDN outages
55/// which do happen.
56///
57pub fn app_head(
58 _path_components: URLPath,
59 _params: URLParams,
60 state: SharedAppState,
61) -> HTMLResult {
62 //Let's render the head component
63 let html_meta = rumtk_web_render_component!(meta, state);
64
65 //Let's render the head component
66 let html_css = rumtk_web_render_component!(css);
67
68 //Let's render the head component
69 let html_fontawesome = rumtk_web_render_component!(fontawesome);
70
71 //Let's render the head component
72 let html_htmx = rumtk_web_render_component!(htmx);
73
74 rumtk_web_render_html!(AppShellHead {
75 meta: html_meta,
76 css: html_css,
77 fontawesome: html_fontawesome,
78 htmx: html_htmx
79 })
80}