43 lines
1,008 B
Rust
43 lines
1,008 B
Rust
use actix_web::{get, web, Responder};
|
|
use cached::proc_macro::once;
|
|
use ramhorns::Content;
|
|
|
|
use crate::{
|
|
config::Config,
|
|
misc::utils::{make_kw, Html},
|
|
template::{Infos, NavBar},
|
|
};
|
|
|
|
#[get("/")]
|
|
async fn page(config: web::Data<Config>) -> impl Responder {
|
|
Html(build_page(config.get_ref().to_owned()))
|
|
}
|
|
|
|
#[derive(Content, Debug)]
|
|
struct IndexTemplate {
|
|
navbar: NavBar,
|
|
fullname: String,
|
|
}
|
|
|
|
#[once(time = 60)]
|
|
fn build_page(config: Config) -> String {
|
|
config.tmpl.render(
|
|
"index.html",
|
|
IndexTemplate {
|
|
navbar: NavBar {
|
|
index: true,
|
|
..NavBar::default()
|
|
},
|
|
fullname: config
|
|
.fc
|
|
.fullname
|
|
.to_owned()
|
|
.unwrap_or("Fullname".to_owned()),
|
|
},
|
|
Infos {
|
|
page_title: config.fc.fullname,
|
|
page_desc: Some("Page principale".into()),
|
|
page_kw: make_kw(&["index", "étudiant"]),
|
|
},
|
|
)
|
|
}
|