mirror of
https://notabug.org/scuti/pleroma-comments
synced 2025-01-09 19:47:51 +05:30
included cards in comments if any
This commit is contained in:
parent
05ea67e03d
commit
174f25f12c
@ -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 = [[
|
||||
<article class="card">
|
||||
<header>
|
||||
<h1 class="card-title">$title$</h1>
|
||||
<p class="card-description">$description$</p>
|
||||
</header>
|
||||
<!-- <img src="$image$" alt="$image_description$" class="card-image" loading="lazy"/> -->
|
||||
<footer>
|
||||
<a href="$link$" class="card-link">Read More</a>
|
||||
</footer>
|
||||
</article>
|
||||
]]
|
||||
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)
|
||||
<blockquote>
|
||||
$text$
|
||||
</blockquote>
|
||||
$card$
|
||||
</article>
|
||||
]]
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user