add: allow lisp templates (bberry)

This commit is contained in:
trisua 2025-05-30 21:22:53 -04:00
parent 8de5c0ea76
commit 78d0766345
10 changed files with 296 additions and 263 deletions

View file

@ -1,3 +1,4 @@
use bberry::core::element::Render;
use pathbufd::PathBufD;
use regex::Regex;
use std::{
@ -39,9 +40,9 @@ pub const ROOT: &str = include_str!("./public/html/root.html");
pub const MACROS: &str = include_str!("./public/html/macros.html");
pub const COMPONENTS: &str = include_str!("./public/html/components.html");
pub const MISC_ERROR: &str = include_str!("./public/html/misc/error.html");
pub const MISC_ERROR: &str = include_str!("./public/html/misc/error.lisp");
pub const MISC_NOTIFICATIONS: &str = include_str!("./public/html/misc/notifications.html");
pub const MISC_MARKDOWN: &str = include_str!("./public/html/misc/markdown.html");
pub const MISC_MARKDOWN: &str = include_str!("./public/html/misc/markdown.lisp");
pub const MISC_REQUESTS: &str = include_str!("./public/html/misc/requests.html");
pub const AUTH_BASE: &str = include_str!("./public/html/auth/base.html");
@ -161,7 +162,7 @@ macro_rules! vendor_icon {
/// * icons
/// * icons (with class specifier)
/// * l10n text
pub(crate) async fn replace_in_html(input: &str, config: &Config) -> String {
pub(crate) async fn replace_in_html(input: &str, config: &Config, lisp: bool) -> String {
let reader = HTML_FOOTER.read().await;
if reader.is_empty() {
@ -180,7 +181,12 @@ pub(crate) async fn replace_in_html(input: &str, config: &Config) -> String {
let reader = HTML_FOOTER.read().await;
// ...
let mut input = input.to_string();
let mut input = if !lisp {
input.to_string()
} else {
bberry::parse(input).0.render()
};
input = input.replace("<!-- prettier-ignore -->", "");
// l10n text
@ -243,9 +249,9 @@ pub(crate) async fn write_assets(config: &Config) -> PathBufD {
write_template!(html_path->"macros.html"(crate::assets::MACROS) --config=config);
write_template!(html_path->"components.html"(crate::assets::COMPONENTS) --config=config);
write_template!(html_path->"misc/error.html"(crate::assets::MISC_ERROR) -d "misc" --config=config);
write_template!(html_path->"misc/error.html"(crate::assets::MISC_ERROR) -d "misc" --config=config --lisp);
write_template!(html_path->"misc/notifications.html"(crate::assets::MISC_NOTIFICATIONS) --config=config);
write_template!(html_path->"misc/markdown.html"(crate::assets::MISC_MARKDOWN) --config=config);
write_template!(html_path->"misc/markdown.html"(crate::assets::MISC_MARKDOWN) --config=config --lisp);
write_template!(html_path->"misc/requests.html"(crate::assets::MISC_REQUESTS) --config=config);
write_template!(html_path->"auth/base.html"(crate::assets::AUTH_BASE) -d "auth" --config=config);