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