update
This commit is contained in:
parent
3b9d6fbd89
commit
a87c3f3ad3
3 changed files with 11 additions and 25 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1788,7 +1788,7 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
|
|||
[[package]]
|
||||
name = "web-base"
|
||||
version = "0.2.0"
|
||||
source = "git+https://git.hydrar.de/jmarya/web-base#dc5c22175bb58e554ebfd19a493be3631c9be40c"
|
||||
source = "git+https://git.hydrar.de/jmarya/web-base#3331a088cb4afab6596dca120825d76ce5be6a62"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-web",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::config::Config;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::HttpResponse;
|
||||
use actix_web::{web::Data, HttpRequest};
|
||||
use maud::{html, PreEscaped};
|
||||
|
||||
pub(crate) async fn build_site(
|
||||
|
@ -9,13 +9,8 @@ pub(crate) async fn build_site(
|
|||
disable_color: bool,
|
||||
shadow: bool,
|
||||
config: &Data<Config>,
|
||||
r: &HttpRequest,
|
||||
) -> HttpResponse<String> {
|
||||
let bootstrap = html! {
|
||||
link href="/bootstrap.min.css" rel="stylesheet";
|
||||
link href="/bootstrap-icons.css" rel="stylesheet";
|
||||
link href="/bootstrap.bundle.min.js" rel="stylesheet";
|
||||
};
|
||||
|
||||
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();
|
||||
|
@ -33,23 +28,12 @@ pub(crate) async fn build_site(
|
|||
c_style.push_str("text-shadow: 1px 1px 3px black;");
|
||||
}
|
||||
|
||||
let r = html! {
|
||||
(maud::DOCTYPE)
|
||||
html {
|
||||
head {
|
||||
title {
|
||||
(title)
|
||||
};
|
||||
(bootstrap)
|
||||
};
|
||||
let body = html! {
|
||||
body style=(c_style) class=(c_class) {
|
||||
style { (g_style) };
|
||||
(PreEscaped(content))
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
HttpResponse::Ok()
|
||||
.message_body(r.into_string())
|
||||
.expect("could not build page")
|
||||
web_base::func::build_site_from_body(r, title, &body.into_string())
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ pub async fn message_page(r: HttpRequest) -> impl Responder {
|
|||
}
|
||||
};
|
||||
|
||||
pages::html_fn::build_site(resp.into_string(), "Message", false, true, config).await
|
||||
pages::html_fn::build_site(resp.into_string(), "Message", false, true, config, &r).await
|
||||
}
|
||||
|
||||
#[get("/mirrors.txt")]
|
||||
|
@ -63,6 +63,7 @@ pub async fn mirrors(r: HttpRequest) -> Result<impl Responder, Error> {
|
|||
false,
|
||||
true,
|
||||
config,
|
||||
&r,
|
||||
)
|
||||
.await);
|
||||
}
|
||||
|
@ -104,6 +105,7 @@ pub async fn public_key(r: HttpRequest) -> Result<impl Responder, Error> {
|
|||
true,
|
||||
false,
|
||||
config,
|
||||
&r,
|
||||
)
|
||||
.await);
|
||||
}
|
||||
|
@ -181,7 +183,7 @@ fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
|||
}
|
||||
|
||||
#[get("/")]
|
||||
pub(crate) async fn index(conf: web::Data<config::Config>) -> impl Responder {
|
||||
pub(crate) async fn index(conf: web::Data<config::Config>, r: HttpRequest) -> impl Responder {
|
||||
let information_block = build_information_block(&conf);
|
||||
let contact_block = build_contact_block(&conf);
|
||||
let donation_block = build_donation_block(&conf);
|
||||
|
@ -192,5 +194,5 @@ pub(crate) async fn index(conf: web::Data<config::Config>) -> impl Responder {
|
|||
{donation_block}
|
||||
"
|
||||
);
|
||||
crate::pages::html_fn::build_site(content, "About Me", false, true, &conf).await
|
||||
crate::pages::html_fn::build_site(content, "About Me", false, true, &conf, &r).await
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue