mirror of
https://notabug.org/scuti/pleroma-comments
synced 2025-05-31 11:21:40 +05:30
display extra attributes e.g images attached
This commit is contained in:
@@ -108,6 +108,29 @@ function write_comments(pleroma_posts, instance, show_avatars)
|
|||||||
return card_template:gsub("%$(%w+)%$", vars)
|
return card_template:gsub("%$(%w+)%$", vars)
|
||||||
end
|
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
|
if #pleroma_posts == 0 then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
@@ -121,6 +144,7 @@ function write_comments(pleroma_posts, instance, show_avatars)
|
|||||||
$text$
|
$text$
|
||||||
</blockquote>
|
</blockquote>
|
||||||
$card$
|
$card$
|
||||||
|
$attributes$
|
||||||
</article>
|
</article>
|
||||||
]]
|
]]
|
||||||
local comments = {}
|
local comments = {}
|
||||||
@@ -128,8 +152,16 @@ function write_comments(pleroma_posts, instance, show_avatars)
|
|||||||
for i, post in ipairs(replies) do
|
for i, post in ipairs(replies) do
|
||||||
local pid = post["id"]
|
local pid = post["id"]
|
||||||
local datetime = get_short_date(post["created_at"])
|
local datetime = get_short_date(post["created_at"])
|
||||||
|
|
||||||
local text = post["content"]
|
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+)%$", {
|
local interpolated = template:gsub("%$(%w+)%$", {
|
||||||
i= #replies - i + 1,
|
i= #replies - i + 1,
|
||||||
host=instance,
|
host=instance,
|
||||||
@@ -137,7 +169,8 @@ function write_comments(pleroma_posts, instance, show_avatars)
|
|||||||
datetime=datetime,
|
datetime=datetime,
|
||||||
user=get_user(post["account"], instance, true),
|
user=get_user(post["account"], instance, true),
|
||||||
text = text,
|
text = text,
|
||||||
card = get_card(post["card"], instance)
|
card = get_card(post["card"], instance),
|
||||||
|
attributes = table.concat(attrs)
|
||||||
})
|
})
|
||||||
-- print(interpolated)
|
-- print(interpolated)
|
||||||
table.insert(
|
table.insert(
|
||||||
|
Reference in New Issue
Block a user