Add about page
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
pub mod data;
|
||||
pub mod jobs;
|
||||
pub mod skills;
|
||||
pub mod website;
|
||||
|
12
src/services/website.rs
Normal file
12
src/services/website.rs
Normal 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
|
||||
}
|
@@ -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}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user