This commit is contained in:
parent
3b9d6acb72
commit
fabc0103be
2 changed files with 42 additions and 6 deletions
|
@ -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<Config>) -> impl Responder {
|
||||
HttpResponse::NotFound().body(build_page(config.get_ref().to_owned()))
|
||||
pub async fn page(req: HttpRequest, config: web::Data<Config>) -> 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<String>,
|
||||
}
|
||||
|
||||
#[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(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,32 @@
|
|||
<body>
|
||||
<header>{{>navbar.html}}</header>
|
||||
<main>
|
||||
<p style="color: aliceblue">404 :/</p>
|
||||
{{#data}}
|
||||
|
||||
<h1>Perdu ?</h1>
|
||||
|
||||
<p>Vous pouvez revenir sur le site via :</p>
|
||||
<ul>
|
||||
<li><p>La barre de navigation</p></li>
|
||||
|
||||
<li>
|
||||
<p>
|
||||
Le <a href="{{www}} ">site internet</a> (disponible grâce au projet
|
||||
<a href="http://info.cern.ch/hypertext/WWW/TheProject.html">W3</a>).
|
||||
</p>
|
||||
</li>
|
||||
|
||||
{{#onion}}
|
||||
<li>
|
||||
<p>
|
||||
Le <a href="{{onion}} ">site onion</a> (disponible grâce au réseau
|
||||
<a href="https://www.torproject.org/">Tor</a>).
|
||||
</p>
|
||||
</li>
|
||||
{{/onion}}
|
||||
</ul>
|
||||
|
||||
{{/data}}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue