display extra attributes e.g images attached

This commit is contained in:
scuti 2024-11-27 21:56:32 -08:00
parent 174f25f12c
commit 38d67e0601

View File

@ -108,6 +108,29 @@ function write_comments(pleroma_posts, instance, show_avatars)
return card_template:gsub("%$(%w+)%$", vars)
end
function get_media(attachments)
if type(attachments) ~= "table" then
return ""
end
if #attachments < 1 then
return ""
end
local media_list = {"<p>images attached: </p><ol>"}
local item = "<li><a href=\"$link$\">$mime$</a></li>"
for _, v in pairs(attachments) do
local vars = {
link = v["preview_url"],
mime = v["pleroma"]["mime_type"]
}
local foo = item:gsub("%$(%w+)%$", vars)
print(foo)
table.insert(media_list, foo)
end
table.insert(media_list, "</ol>")
printTable(media_list)
return table.concat(media_list, "\n")
end
if #pleroma_posts == 0 then
return ""
end
@ -121,6 +144,7 @@ function write_comments(pleroma_posts, instance, show_avatars)
$text$
</blockquote>
$card$
$attributes$
</article>
]]
local comments = {}
@ -128,8 +152,16 @@ function write_comments(pleroma_posts, instance, show_avatars)
for i, post in ipairs(replies) do
local pid = post["id"]
local datetime = get_short_date(post["created_at"])
local text = post["content"]
local attrs = {}
table.insert(
attrs, get_media(post["media_attachments"])
)
if type(post["poll"]) == "table" then
table.insert(attrs, "<p>(poll attached)</p>")
end
local interpolated = template:gsub("%$(%w+)%$", {
i= #replies - i + 1,
host=instance,
@ -137,7 +169,8 @@ function write_comments(pleroma_posts, instance, show_avatars)
datetime=datetime,
user=get_user(post["account"], instance, true),
text = text,
card = get_card(post["card"], instance)
card = get_card(post["card"], instance),
attributes = table.concat(attrs)
})
-- print(interpolated)
table.insert(