diff --git a/pleroma-comments.lua b/pleroma-comments.lua index 3687315..9581370 100644 --- a/pleroma-comments.lua +++ b/pleroma-comments.lua @@ -49,7 +49,38 @@ function get_short_date(timestamp) ) 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 = [[ +
+ avatar +
$alias$ @$handle$
+
+ ]] + vars.avatar = acct_data["avatar_static"] + result = user_info:gsub("%$(%w+)%$", vars) + else + user_info = "

$alias$ @$handle$

" + result = user_info:gsub("%$(%w+)%$", vars) + end + return result + end + if #pleroma_posts == 0 then return "" end @@ -58,7 +89,7 @@ function write_comments(pleroma_posts, instance)

#$i$ $datetime$

-

$alias$ @$handle$

+ $user$
$text$
@@ -69,18 +100,14 @@ function write_comments(pleroma_posts, instance) for i, post in ipairs(replies) do local pid = post["id"] 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 interpolated = template:gsub("%$(%w+)%$", { i= #replies - i + 1, host=instance, pid=pid, datetime=datetime, - uid = uid, - handle = handle, - alias=alias, + user=get_user(post["account"], instance, true), text = text }) -- print(interpolated) @@ -138,7 +165,8 @@ function Meta(meta) local host = "" -- for each listed url in "pleroma-urls" 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, {link = link, id = id} )