add networks and portfolio endpoints

This commit is contained in:
Mylloon 2023-02-09 10:59:06 +01:00
parent 2a3045e5da
commit c4a80e15cd
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 49 additions and 7 deletions

View file

@ -10,14 +10,20 @@ use glob::glob;
use minify_html::{minify, Cfg};
mod config;
#[path = "routes/index.rs"]
mod index;
#[path = "routes/agreements.rs"]
mod agreements;
#[path = "routes/not_found.rs"]
mod not_found;
#[path = "routes/agreements.rs"]
mod agreements;
#[path = "routes/index.rs"]
mod index;
#[path = "routes/networks.rs"]
mod networks;
#[path = "routes/portfolio.rs"]
mod portfolio;
#[actix_web::main]
async fn main() -> io::Result<()> {
@ -76,11 +82,13 @@ async fn main() -> io::Result<()> {
App::new()
.app_data(web::Data::new(config.clone()))
.service(index::page)
.service(Files::new("/", &folder))
.service(agreements::security)
.service(agreements::humans)
.service(agreements::robots)
.service(agreements::sitemap)
.service(networks::page)
.service(portfolio::page)
.service(Files::new("/", &folder))
.default_service(web::to(not_found::page))
})
.bind(addr)?

17
src/routes/networks.rs Normal file
View file

@ -0,0 +1,17 @@
use actix_web::{get, HttpResponse, Responder};
use askama::Template;
#[get("/networks")]
pub async fn page() -> impl Responder {
HttpResponse::Ok().body(get_page())
}
#[derive(Template)]
#[template(path = "../templates/networks.html")]
struct NetworksTemplate {}
pub fn get_page() -> std::string::String {
let index = NetworksTemplate {};
index.render().unwrap()
}

17
src/routes/portfolio.rs Normal file
View file

@ -0,0 +1,17 @@
use actix_web::{get, HttpResponse, Responder};
use askama::Template;
#[get("/portfolio")]
pub async fn page() -> impl Responder {
HttpResponse::Ok().body(get_page())
}
#[derive(Template)]
#[template(path = "../templates/portfolio.html")]
struct PortfolioTemplate {}
pub fn get_page() -> std::string::String {
let index = PortfolioTemplate {};
index.render().unwrap()
}

View file

@ -60,7 +60,7 @@
<button
class="buttonIndex"
id="buttonIndexBL"
onclick="window.location.href='networks.html';"
onclick="window.location.href='/networks';"
>
<span class="buttonIndex">Réseaux</span>
</button>
@ -69,7 +69,7 @@
<button
class="buttonIndex"
id="buttonIndexBR"
onclick="window.location.href='portfolio.html';"
onclick="window.location.href='/portfolio';"
>
<span class="buttonIndex">Projets</span>
</button>