Style rework #35

Merged
Anri merged 70 commits from rework into main 2023-10-15 20:58:23 +02:00
2 changed files with 42 additions and 6 deletions
Showing only changes of commit fabc0103be - Show all commits

View file

@ -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(),
)
}

View file

@ -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>