43 lines
1.4 KiB
Rust
43 lines
1.4 KiB
Rust
use crate::config::Config;
|
|
use actix_web::HttpResponse;
|
|
use actix_web::{web::Data, HttpRequest};
|
|
use maud::{html, PreEscaped};
|
|
|
|
pub(crate) async fn build_site(
|
|
content: String,
|
|
title: &str,
|
|
disable_color: bool,
|
|
shadow: bool,
|
|
config: &Data<Config>,
|
|
r: &HttpRequest,
|
|
) -> HttpResponse<String> {
|
|
let mut c_class = "bg-dark text-white justify-content-center text-center".to_string();
|
|
let mut c_style = String::new();
|
|
let mut g_style = "a {text-decoration: none; font-weight: bold; color: white}".to_string();
|
|
if !disable_color {
|
|
if let (Some(fg), Some(bg)) = (config.fg_color(), config.bg_color()) {
|
|
c_class = "justify-content-center text-center".to_string();
|
|
c_style = format!("background: {bg}; color: {fg};");
|
|
g_style = format!("a {{text-decoration: none; font-weight: bold; color: {fg}}}");
|
|
}
|
|
}
|
|
if std::path::Path::new("./config/wall.avif").exists() {
|
|
c_style.push_str("background-image: url('assets/wall');background-size:cover;");
|
|
}
|
|
if shadow {
|
|
c_style.push_str("text-shadow: 1px 1px 3px black;");
|
|
}
|
|
|
|
let body = html! {
|
|
body style=(c_style) class=(c_class) {
|
|
style { (g_style) };
|
|
(PreEscaped(content))
|
|
};
|
|
};
|
|
|
|
web_base::func::build_site_from_body(
|
|
&web_base::Site::from_request(&r),
|
|
title,
|
|
&body.into_string(),
|
|
)
|
|
}
|