diff --git a/crates/app/src/assets.rs b/crates/app/src/assets.rs index bf92db7..63502ca 100644 --- a/crates/app/src/assets.rs +++ b/crates/app/src/assets.rs @@ -105,6 +105,9 @@ pub const LANG_EN_US: &str = include_str!("./langs/en-US.toml"); pub const VENDOR_SPOTIFY_ICON: &str = include_str!("./public/images/vendor/spotify.svg"); pub const VENDOR_LAST_FM_ICON: &str = include_str!("./public/images/vendor/last-fm.svg"); +pub(crate) static HTML_FOOTER: LazyLock> = + LazyLock::new(|| RwLock::new(String::new())); + /// A container for all loaded icons. pub(crate) static ICONS: LazyLock>> = LazyLock::new(|| RwLock::new(HashMap::new())); @@ -148,6 +151,24 @@ macro_rules! vendor_icon { /// * icons (with class specifier) /// * l10n text pub(crate) async fn replace_in_html(input: &str, config: &Config) -> String { + let reader = HTML_FOOTER.read().await; + + if reader.is_empty() { + if !config.html_footer_path.is_empty() { + drop(reader); + + let mut writer = HTML_FOOTER.write().await; + *writer = read_to_string(PathBufD::current().join(&config.html_footer_path)).unwrap(); + } else { + drop(reader); + } + } else { + drop(reader); + } + + let reader = HTML_FOOTER.read().await; + + // ... let mut input = input.to_string(); input = input.replace("", ""); @@ -195,6 +216,7 @@ pub(crate) async fn replace_in_html(input: &str, config: &Config) -> String { } // return + input = input.replacen("", &format!("{reader}"), 1); input } diff --git a/crates/app/src/public/html/root.html b/crates/app/src/public/html/root.html index 2e4b46e..14272c8 100644 --- a/crates/app/src/public/html/root.html +++ b/crates/app/src/public/html/root.html @@ -90,6 +90,7 @@ macros -%} {% else %} {% block body %}{% endblock %} {% endif %} + +{% endif %} diff --git a/example/tetratto.toml b/example/tetratto.toml index 084e340..f446e39 100644 --- a/example/tetratto.toml +++ b/example/tetratto.toml @@ -18,6 +18,7 @@ banned_usernames = [ "anonymous", ] town_square = 166340372315581657 +html_footer_path = "public/footer.html" [security] registration_enabled = true