diff --git a/src/routes/not_found.rs b/src/routes/not_found.rs index 014c0cf..51c7f69 100644 --- a/src/routes/not_found.rs +++ b/src/routes/not_found.rs @@ -1,28 +1,39 @@ -use actix_web::{web, HttpResponse, Responder}; +use actix_web::{web, HttpRequest, HttpResponse, Responder}; use cached::proc_macro::once; use ramhorns::Content; use crate::{ config::Config, + misc::utils::get_url, template::{Infos, NavBar}, }; -pub async fn page(config: web::Data) -> impl Responder { - HttpResponse::NotFound().body(build_page(config.get_ref().to_owned())) +pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder { + HttpResponse::NotFound().body(build_page( + config.get_ref().to_owned(), + get_url(req.connection_info()), + )) } #[derive(Content, Debug)] struct NotFoundTemplate { navbar: NavBar, + www: String, + onion: Option, } #[once(time = 60)] -fn build_page(config: Config) -> String { +fn build_page(config: Config, url: String) -> String { config.tmpl.render( "404.html", NotFoundTemplate { navbar: NavBar::default(), + www: url, + onion: config.fc.onion, + }, + Infos { + page_desc: Some("Une page perdu du web".into()), + ..Infos::default() }, - Infos::default(), ) } diff --git a/templates/404.html b/templates/404.html index 75060b5..afdba64 100644 --- a/templates/404.html +++ b/templates/404.html @@ -6,7 +6,32 @@
{{>navbar.html}}
-

404 :/

+ {{#data}} + +

Perdu ?

+ +

Vous pouvez revenir sur le site via :

+
    +
  • La barre de navigation

  • + +
  • +

    + Le site internet (disponible grâce au projet + W3). +

    +
  • + + {{#onion}} +
  • +

    + Le site onion (disponible grâce au réseau + Tor). +

    +
  • + {{/onion}} +
+ + {{/data}}