fix: adjust domain accessors and template adapter for Askama compatibility

This commit is contained in:
2026-05-04 19:03:48 +02:00
parent 965fc0eda8
commit 27be840faa
4 changed files with 26 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ edition = "2024"
askama = { version = "0.16.0" }
serde = { workspace = true }
chrono = { workspace = true }
domain = { workspace = true }
application = { workspace = true }

View File

@@ -61,7 +61,7 @@ struct UsersTemplate<'a> {
#[template(path = "profile.html")]
struct ProfileTemplate<'a> {
ctx: &'a HtmlPageContext,
profile_user_email: &'a str,
profile_display_name: String,
stats: &'a UserStats,
view: &'a str,
entries: Option<&'a Paginated<DiaryEntry>>,
@@ -79,6 +79,7 @@ struct HeatmapCell {
bg_style: String,
}
#[allow(dead_code)]
fn relative_time(dt: chrono::NaiveDateTime) -> String {
let now = chrono::Utc::now().naive_utc();
let diff = now.signed_duration_since(dt);
@@ -192,9 +193,11 @@ impl HtmlRenderer for AskamaHtmlRenderer {
let heatmap = data.history.as_deref()
.map(|h| build_heatmap(h))
.unwrap_or_default();
let profile_display_name = data.profile_user_email
.split('@').next().unwrap_or(&data.profile_user_email).to_string();
ProfileTemplate {
ctx: &data.ctx,
profile_user_email: &data.profile_user_email,
profile_display_name,
stats: &data.stats,
view: &data.view,
entries: data.entries.as_ref(),