Add about page

This commit is contained in:
2024-11-03 03:00:40 +01:00
parent 1bb774eb00
commit 32f9356a1a
8 changed files with 142 additions and 0 deletions

View File

@@ -27,9 +27,14 @@ pub async fn render_upload(
views::data::upload(v).await
}
pub async fn render_about(ViewEngine(v): ViewEngine<TeraView>) -> Result<impl IntoResponse> {
views::website::about(v).await
}
pub fn routes() -> Routes {
Routes::new()
.add("/", get(render_index))
.add("/upload", get(render_upload))
.add("/login", get(render_login))
.add("/about", get(render_about))
}

View File

@@ -1,3 +1,4 @@
pub mod data;
pub mod jobs;
pub mod skills;
pub mod website;

12
src/services/website.rs Normal file
View File

@@ -0,0 +1,12 @@
use chrono::Datelike;
pub fn get_current_age() -> u32 {
let now = chrono::Utc::now();
let birth_date = chrono::NaiveDate::from_ymd_opt(2002, 2, 27);
let age = match birth_date {
Some(birth_date) => now.year_ce().1 - birth_date.year_ce().1,
None => 0,
};
age
}

View File

@@ -12,3 +12,9 @@ pub async fn index(v: impl ViewRenderer, ctx: &AppContext) -> Result<impl IntoRe
data!({ "skills": skills, "jobs": jobs }),
)
}
pub async fn about(v: impl ViewRenderer) -> Result<impl IntoResponse> {
let age = services::website::get_current_age();
format::render().view(&v, "website/about.html", data!({"age": age}))
}