Skip to main content

rumtk_web/static_components/
fontawesome.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::utils::types::HTMLResult;
22use crate::{rumtk_web_render_html, RUMWebTemplate};
23
24#[derive(Debug)]
25pub struct FontAwesomeCSSElement {
26    file: &'static str,
27    version: &'static str,
28    sha: &'static str,
29}
30
31#[derive(RUMWebTemplate, Debug)]
32#[template(
33    source = "
34        {% for e in elements %}
35            <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{e.version}}/css/{{e.file}}' integrity='{{e.sha}}' crossorigin='anonymous' referrerpolicy='no-referrer' onerror='this.onerror=null;this.href=\'/static/fontawesome-free/css/{{e.file}}\';' />
36        {% endfor %}
37    ",
38    ext = "html"
39)]
40pub struct FontAwesome {
41    elements: Vec<FontAwesomeCSSElement>,
42}
43
44pub fn fontawesome() -> HTMLResult {
45    let elements = vec![
46        FontAwesomeCSSElement {
47            file: "fontawesome.min.css",
48            version: "7.0.1",
49            sha: "sha512-M5Kq4YVQrjg5c2wsZSn27Dkfm/2ALfxmun0vUE3mPiJyK53hQBHYCVAtvMYEC7ZXmYLg8DVG4tF8gD27WmDbsg==",
50        },
51        FontAwesomeCSSElement {
52            file: "regular.min.css",
53            version: "7.0.1",
54            sha: "sha512-x3gns+l9p4mIK7vYLOCUoFS2P1gavFvnO9Its8sr0AkUk46bgf9R51D8xeRUwCSk+W93YbXWi19BYzXDNBH5SA==",
55        },
56        FontAwesomeCSSElement {
57            file: "brands.min.css",
58            version: "7.0.1",
59            sha: "sha512-WxpJXPm/Is1a/dzEdhdaoajpgizHQimaLGL/QqUIAjIihlQqlPQb1V9vkGs9+VzXD7rgI6O+UsSKl4u5K36Ydw==",
60        },
61    ];
62
63    rumtk_web_render_html!(FontAwesome { elements })
64}