diff options
author | Vika <vika@fireburn.ru> | 2022-11-06 17:39:21 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-11-06 17:39:21 +0300 |
commit | 2ffa3c0d155baa0e5292647eea47d6aa002ad7c1 (patch) | |
tree | a2ff09f9442fbbacd1d8005a6d06151495670e6a /kittybox-rs | |
parent | 8c523414f007d54e0145ad9335a8932043a19f16 (diff) | |
download | kittybox-2ffa3c0d155baa0e5292647eea47d6aa002ad7c1.tar.zst |
templates: hotfix rich reply contexts
When did I implement that?!!!
Diffstat (limited to 'kittybox-rs')
-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() + } + } + } } } } |