36 lines
816 B
Rust
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()
|
|
},
|
|
)
|
|
}
|