diff options
Diffstat (limited to 'kittybox-rs/templates/src')
-rw-r--r-- | kittybox-rs/templates/src/mf2.rs | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/kittybox-rs/templates/src/mf2.rs b/kittybox-rs/templates/src/mf2.rs index d9fc5e7..607c983 100644 --- a/kittybox-rs/templates/src/mf2.rs +++ b/kittybox-rs/templates/src/mf2.rs @@ -59,11 +59,16 @@ markup::define! { .unwrap_or_else(|| bookmarkof["properties"]["url"][0].as_str().unwrap()) } } - @if let Some(published) = post["properties"]["published"][0].as_str() { - time."dt-published"[datetime=published] { - @chrono::DateTime::parse_from_rfc3339(published) - .map(|dt| dt.format("on %a %b %e %T %Y").to_string()) - .unwrap_or("sometime in the past".to_string()) + + a."u-url"."u-uid"[href=post["properties"]["uid"][0].as_str().unwrap()] { + @if let Some(published) = post["properties"]["published"][0].as_str() { + time."dt-published"[datetime=published] { + @chrono::DateTime::parse_from_rfc3339(published) + .map(|dt| dt.format("on %a %b %e %T %Y").to_string()) + .unwrap_or("sometime in the past".to_string()) + } + } else { + "sometime in the past" } } } @@ -113,14 +118,30 @@ markup::define! { } } @if post["properties"]["in-reply-to"].is_array() { - // TODO: Rich reply contexts - blocked on MF2 parser span { "In reply to: " ul.replyctx { @for ctx in post["properties"]["in-reply-to"].as_array().unwrap() { - li { a."u-in-reply-to"[href=ctx.as_str().unwrap()] { - @ctx.as_str().unwrap().truncate_ellipse(24).as_ref() - } } + @if let Some(ctx) = ctx.as_str() { + li { + a."u-in-reply-to"[href=ctx] { + @ctx.truncate_ellipse(24).as_ref() + } + } + } else if let Some(ctx) = ctx.as_object() { + li { + a."u-in-reply-to"[href=ctx["properties"]["uid"][0] + .as_str() + .unwrap_or_else(|| ctx["properties"]["url"][0].as_str().unwrap())] + { + @ctx["properties"]["uid"][0] + .as_str() + .unwrap_or_else(|| ctx["properties"]["url"][0].as_str().unwrap()) + .truncate_ellipse(24) + .as_ref() + } + } + } } } } |