From c603ece30c6d2df17e0fe42c7b62f29e12df17ac Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 7 Sep 2024 16:42:00 +0300 Subject: kittybox-frontend-renderer: use p-summary if available --- templates/src/mf2.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/templates/src/mf2.rs b/templates/src/mf2.rs index 4a683d6..076989c 100644 --- a/templates/src/mf2.rs +++ b/templates/src/mf2.rs @@ -283,12 +283,22 @@ markup::define! { } } @PhotoGallery { photos: post["properties"]["photo"].as_array() } - @if post["properties"]["content"][0]["html"].is_string() { + @if *from_feed { + @if let Some(summary) = post["properties"]["summary"][0].as_str() { + p."p-summary" { @summary } + a[href=post["properties"]["uid"][0].as_str().unwrap()] { "Read more.." } + } else if let Some(content) = post["properties"]["content"][0]["html"].as_str() { + // TODO: ellipsize content by showing only the first paragraph + main."e-content" { + @markup::raw(content.trim()) + } + } + } else if let Some(content) = post["properties"]["content"][0]["html"].as_str() { main."e-content" { - @markup::raw(post["properties"]["content"][0]["html"].as_str().unwrap().trim()) + @markup::raw(content.trim()) } } - @WebInteractions { post } + @WebInteractions { post, from_feed: *from_feed } } } VCard<'a>(card: &'a serde_json::Value) { @@ -424,7 +434,7 @@ markup::define! { } } } - WebInteractions<'a>(post: &'a serde_json::Value) { + WebInteractions<'a>(post: &'a serde_json::Value, from_feed: bool) { footer.webinteractions { p[style="display: none", "aria-hidden"="false"] { "Webmention counters:" @@ -451,7 +461,7 @@ markup::define! { span.counter { @post["properties"]["bookmark"].as_array().map(|a| a.len()).unwrap_or(0) } } } - /*@if ( + /*@if *from_feed && ( post["properties"]["like"].as_array().map(|a| a.len()).unwrap_or(0) + post["properties"]["bookmark"].as_array().map(|a| a.len()).unwrap_or(0) + post["properties"]["repost"].as_array().map(|a| a.len()).unwrap_or(0) -- cgit 1.4.1