mirror of
https://notabug.org/scuti/pleroma-comments
synced 2025-05-31 11:21:40 +05:30
added support for avatars
This commit is contained in:
@@ -49,7 +49,38 @@ function get_short_date(timestamp)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function write_comments(pleroma_posts, instance)
|
function write_comments(pleroma_posts, instance, show_avatars)
|
||||||
|
show_avatars = show_avatars or false
|
||||||
|
|
||||||
|
function get_user(acct_data, instance, include_img)
|
||||||
|
-- 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"],
|
||||||
|
handle = acct_data["acct"],
|
||||||
|
}
|
||||||
|
if include_img then
|
||||||
|
user_info = [[
|
||||||
|
<figure>
|
||||||
|
<img src="$avatar$" loading="lazy" alt="avatar"/>
|
||||||
|
<figcaption>$alias$ <a href="$host$/users/$uid$">@$handle$</a> </figcaption>
|
||||||
|
</figure>
|
||||||
|
]]
|
||||||
|
vars.avatar = acct_data["avatar_static"]
|
||||||
|
result = user_info:gsub("%$(%w+)%$", vars)
|
||||||
|
else
|
||||||
|
user_info = "<p>$alias$ <a href=\"$host$/users/$uid$\">@$handle$</a></p>"
|
||||||
|
result = user_info:gsub("%$(%w+)%$", vars)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
if #pleroma_posts == 0 then
|
if #pleroma_posts == 0 then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
@@ -58,7 +89,7 @@ function write_comments(pleroma_posts, instance)
|
|||||||
<h3>
|
<h3>
|
||||||
#$i$ <a href="$host$/notice/$pid$">$datetime$</a>
|
#$i$ <a href="$host$/notice/$pid$">$datetime$</a>
|
||||||
</h3>
|
</h3>
|
||||||
<p>$alias$ <a href="$host$/users/$uid$">@$handle$</a></p>
|
$user$
|
||||||
<blockquote>
|
<blockquote>
|
||||||
$text$
|
$text$
|
||||||
</blockquote>
|
</blockquote>
|
||||||
@@ -69,18 +100,14 @@ function write_comments(pleroma_posts, instance)
|
|||||||
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 uid = post["account"]["id"]
|
|
||||||
local alias = post["account"]["display_name"]
|
|
||||||
local handle = post["account"]["acct"]
|
|
||||||
local text = post["content"]
|
local text = post["content"]
|
||||||
local interpolated = template:gsub("%$(%w+)%$", {
|
local interpolated = template:gsub("%$(%w+)%$", {
|
||||||
i= #replies - i + 1,
|
i= #replies - i + 1,
|
||||||
host=instance,
|
host=instance,
|
||||||
pid=pid,
|
pid=pid,
|
||||||
datetime=datetime,
|
datetime=datetime,
|
||||||
uid = uid,
|
user=get_user(post["account"], instance, true),
|
||||||
handle = handle,
|
|
||||||
alias=alias,
|
|
||||||
text = text
|
text = text
|
||||||
})
|
})
|
||||||
-- print(interpolated)
|
-- print(interpolated)
|
||||||
@@ -138,7 +165,8 @@ function Meta(meta)
|
|||||||
local host = ""
|
local host = ""
|
||||||
-- for each listed url in "pleroma-urls"
|
-- for each listed url in "pleroma-urls"
|
||||||
for _, v in pairs(pleroma_urls) do
|
for _, v in pairs(pleroma_urls) do
|
||||||
local link, host, id = get_url_from_pandoc_str(v)
|
local link, domain, id = get_url_from_pandoc_str(v)
|
||||||
|
host = domain
|
||||||
table.insert(hrefs,
|
table.insert(hrefs,
|
||||||
{link = link, id = id}
|
{link = link, id = id}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user