pothi.love/0118-load_subtree

24 lines
782 B
Plaintext

load_subtree = function(filename, out, depth)
-- load a file and recursively all replies to it
-- print('load_subtree', filename)
local item = initialize_item(filename, depth)
-- every item is a row consisting of two columns:
-- one column of padding and another of text
local row = cols(Inter_comment_spacing)
table.insert(row.data,
{type='rectangle', w=depth*Indent, h=0})
local item_stuff = rows()
table.insert(item_stuff.data, item)
table.insert(item_stuff.data, {
type='text', data={{data='reply'}},
margin=20,
bg=Reply_button_color,
border=Reply_button_border_color,
})
table.insert(row.data, item_stuff)
table.insert(out, row)
for i,reply_id in ipairs(item.metadata.replies) do
local reply = load_subtree(reply_id, out, depth+1)
end
return item
end