From 174f25f12c4a69646374cd9198f10f296dde6467 Mon Sep 17 00:00:00 2001 From: scuti Date: Wed, 27 Nov 2024 20:25:13 -0800 Subject: [PATCH] included cards in comments if any --- pleroma-comments.lua | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/pleroma-comments.lua b/pleroma-comments.lua index 2b9d0d5..c7fa0ff 100644 --- a/pleroma-comments.lua +++ b/pleroma-comments.lua @@ -56,10 +56,6 @@ function write_comments(pleroma_posts, instance, show_avatars) -- user data local user_info = "" local result = "" - --- local uid = acct_data["id"] --- local alias = acct_data["display_name"] --- local handle = acct_data["acct"] local vars = { alias = acct_data["display_name"], uid = acct_data["id"], @@ -81,6 +77,37 @@ function write_comments(pleroma_posts, instance, show_avatars) return result end + function get_card(card, instance) + if card == nil or type(card) ~= "table" then + return "" + end + if card["provider_url"] == instance then + -- skip rendering a card + return "" + end +-- print(type(card)) + local card_template = [[ +
+
+

$title$

+

$description$

+
+ + +
+ ]] + local vars = { + title = card["title"], + description = card["description"], + image = card["image"], + image_description=card["image_description"], + link = card["url"] + } + return card_template:gsub("%$(%w+)%$", vars) + end + if #pleroma_posts == 0 then return "" end @@ -93,6 +120,7 @@ function write_comments(pleroma_posts, instance, show_avatars)
$text$
+ $card$ ]] local comments = {} @@ -108,7 +136,8 @@ function write_comments(pleroma_posts, instance, show_avatars) pid=pid, datetime=datetime, user=get_user(post["account"], instance, true), - text = text + text = text, + card = get_card(post["card"], instance) }) -- print(interpolated) table.insert(