about summary refs log tree commit diff
path: root/templates
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-05-23 20:52:24 +0300
committerVika <vika@fireburn.ru>2022-05-23 20:52:24 +0300
commitc655404eaf34ca72faffc148c195d83aeefc727d (patch)
treef7c298bf050c23b10b4edbf3464b0a5569e751f5 /templates
parent20867384e36fba1d33113dbdbb0bdd94aabf6760 (diff)
downloadkittybox-c655404eaf34ca72faffc148c195d83aeefc727d.tar.zst
templates: prepare for facepiles a bit better
This bit of code is still disabled for now though. I need to actually
gather and render facepiles.

Additionally, now details won't even show if there were no reactions
to the post, which saves space.
Diffstat (limited to 'templates')
-rw-r--r--templates/src/templates.rs45
1 files changed, 29 insertions, 16 deletions
diff --git a/templates/src/templates.rs b/templates/src/templates.rs
index 66edc9a..0054c91 100644
--- a/templates/src/templates.rs
+++ b/templates/src/templates.rs
@@ -329,22 +329,35 @@ markup::define! {
                     span.counter { @post["properties"]["bookmark"].as_array().map(|a| a.len()).unwrap_or(0) }
                 }
             }
-            // Needs rich webmention support which may or may not depend on an MF2 parser
-            // Might circumvent with an external parser with CORS support
-            // why write this stuff in rust then tho
-            /*details {
-                summary { "Show comments and reactions" }
-                @if post["properties"]["like"].as_array().map(|a| a.len()).unwrap_or(0) > 0 {
-                    // Show a facepile of likes for a post
-                }
-                @if post["properties"]["bookmark"].as_array().map(|a| a.len()).unwrap_or(0) > 0 {
-                    // Show a facepile of bookmarks for a post
-                }
-                @if post["properties"]["repost"].as_array().map(|a| a.len()).unwrap_or(0) > 0 {
-                    // Show a facepile of reposts for a post
-                }
-                @if post["properties"]["comment"].as_array().map(|a| a.len()).unwrap_or(0) > 0 {
-                    // Show all the comments recursively (so we could do Salmention with them)
+            /*@if (
+                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)
+                    + post["properties"]["comment"].as_array().map(|a| a.len()).unwrap_or(0)
+            ) > 0 {
+                details {
+                    summary { "Show comments and reactions" }
+                    // TODO actually render facepiles and comments
+                    @if let Some(likes) = post["properties"]["like"].as_array() {
+                        @if !likes.is_empty() {
+                            // Show a facepile of likes for a post
+                        }
+                    }
+                    @if let Some(bookmarks) = post["properties"]["bookmark"].as_array() {
+                        @if !bookmarks.is_empty() {
+                            // Show a facepile of bookmarks for a post
+                        }
+                    }
+                    @if let Some(reposts) = post["properties"]["repost"].as_array() {
+                        @if !reposts.is_empty() {
+                            // Show a facepile of reposts for a post
+                        }
+                    }
+                    @if let Some(comments) = post["properties"]["comment"].as_array() {
+                        @for comment in comments.iter() {
+                            // Show all the comments recursively (so we could do Salmention with them)
+                        }
+                    }
                 }
             }*/
         }