From c655404eaf34ca72faffc148c195d83aeefc727d Mon Sep 17 00:00:00 2001 From: Vika Date: Mon, 23 May 2022 20:52:24 +0300 Subject: 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. --- templates/src/templates.rs | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'templates/src') 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) + } + } } }*/ } -- cgit 1.4.1