about summary refs log tree commit diff
path: root/templates
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-09-07 16:42:00 +0300
committerVika <vika@fireburn.ru>2024-09-07 16:42:00 +0300
commitc603ece30c6d2df17e0fe42c7b62f29e12df17ac (patch)
tree7596a99562fdc8dad120aac21f78aa86cb8dfb94 /templates
parent4f1fe5404c954c85f3bc2379c7ae130b57ea5e73 (diff)
downloadkittybox-c603ece30c6d2df17e0fe42c7b62f29e12df17ac.tar.zst
kittybox-frontend-renderer: use p-summary if available
Diffstat (limited to 'templates')
-rw-r--r--templates/src/mf2.rs20
1 files changed, 15 insertions, 5 deletions
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)