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.
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::types::HTMLResult;
24use crate::{rumtk_web_render_html, RUMWebTemplate};
25use askama::Template;
26
27#[derive(Debug)]
28pub struct FontAwesomeCSSElement {
29    file: &'static str,
30    version: &'static str,
31    sha: &'static str,
32}
33
34#[derive(RUMWebTemplate, Debug)]
35#[template(
36    source = "
37        {% for e in elements %}
38            <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}}\';' />
39        {% endfor %}
40    ",
41    ext = "html"
42)]
43pub struct FontAwesome {
44    elements: Vec<FontAwesomeCSSElement>,
45}
46
47pub fn fontawesome() -> HTMLResult {
48    let elements = vec![
49        FontAwesomeCSSElement {
50            file: "fontawesome.min.css",
51            version: "7.0.1",
52            sha: "sha512-M5Kq4YVQrjg5c2wsZSn27Dkfm/2ALfxmun0vUE3mPiJyK53hQBHYCVAtvMYEC7ZXmYLg8DVG4tF8gD27WmDbsg==",
53        },
54        FontAwesomeCSSElement {
55            file: "regular.min.css",
56            version: "7.0.1",
57            sha: "sha512-x3gns+l9p4mIK7vYLOCUoFS2P1gavFvnO9Its8sr0AkUk46bgf9R51D8xeRUwCSk+W93YbXWi19BYzXDNBH5SA==",
58        },
59        FontAwesomeCSSElement {
60            file: "brands.min.css",
61            version: "7.0.1",
62            sha: "sha512-WxpJXPm/Is1a/dzEdhdaoajpgizHQimaLGL/QqUIAjIihlQqlPQb1V9vkGs9+VzXD7rgI6O+UsSKl4u5K36Ydw==",
63        },
64    ];
65
66    rumtk_web_render_html!(FontAwesome { elements })
67}