mylloon.fr/src/routes/not_found.rs

37 lines
823 B
Rust
Raw Normal View History

use actix_web::{web, Responder};
2023-04-11 10:45:25 +02:00
use cached::proc_macro::once;
use ramhorns::Content;
2023-02-08 22:27:40 +01:00
use crate::{
config::Config,
utils::misc::{get_url, Html},
2024-05-28 20:26:58 +02:00
template::{InfosPage, NavBar},
};
2023-02-09 11:19:53 +01:00
2023-10-24 11:50:30 +02:00
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>,
2023-02-09 10:55:49 +01:00
}
2023-04-11 10:45:25 +02:00
#[once(time = 60)]
2023-10-24 11:50:30 +02:00
fn build_page(config: Config) -> String {
config.tmpl.render(
"404.html",
NotFoundTemplate {
navbar: NavBar::default(),
2023-10-24 11:50:30 +02:00
www: get_url(config.fc.clone()),
onion: config.fc.onion,
},
2024-05-28 20:26:58 +02:00
InfosPage {
desc: Some("Une page perdu du web".into()),
..InfosPage::default()
},
)
2023-02-08 22:27:40 +01:00
}