mylloon.fr/src/routes/not_found.rs
Mylloon 49af05a565
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
add content type, allowing firefox to see source code of pages
2023-10-24 13:27:02 +02:00

36 lines
816 B
Rust

use actix_web::{web, Responder};
use cached::proc_macro::once;
use ramhorns::Content;
use crate::{
config::Config,
misc::utils::{get_url, Html},
template::{Infos, NavBar},
};
pub async fn page(config: web::Data<Config>) -> impl Responder {
Html(build_page(config.get_ref().to_owned()))
}
#[derive(Content, Debug)]
struct NotFoundTemplate {
navbar: NavBar,
www: String,
onion: Option<String>,
}
#[once(time = 60)]
fn build_page(config: Config) -> String {
config.tmpl.render(
"404.html",
NotFoundTemplate {
navbar: NavBar::default(),
www: get_url(config.fc.clone()),
onion: config.fc.onion,
},
Infos {
page_desc: Some("Une page perdu du web".into()),
..Infos::default()
},
)
}