show creator and timestamp for each toot

This commit is contained in:
Kartik K. Agaram 2023-02-18 23:51:26 -08:00
parent 207fbffd89
commit 799afaf881
17 changed files with 1322 additions and 1077 deletions

1
0645-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.mouse_release":586,"on.update":368,"scale":7,"add_node":590,"render_node_and_descendants":645,"vx":5,"compute_layout":619,"ntracks":600,"vy":8,"Nodes":593,"add_thick_line":400,"ensure_cursor_node_within_viewport":643,"Input_filename":436,"on.initialize":446,"to_text":180,"A":582,"line_height":365,"box_height":345,"on.keychord_press":644,"B":379,"fw_parent":644,"to_node":611,"fw_app":"mastodon-unfurl","initialize_editor":338,"add_edge":575}

View File

@ -0,0 +1,33 @@
render_node_and_descendants = function(id, y, xlo, xhi, grandparent_surface_node)
-- draw a parent 'id' and its children
-- also draw an edge from grandparent to parent if provided
-- position the root between xlo and xhi to be closer to children with fewer tracks
local parent = Nodes[id]
if parent.children == nil then
parent.surface_node = add_node(xlo, y, parent, grandparent_surface_node)
return
end
local parent_xlo
if #parent.children <= 1 then
parent_xlo = xlo
else
local total_boundaries = 0
local curr_boundary = xlo
for child_idx = 1,#parent.children-1 do
local child_id = parent.children[child_idx]
local child = Nodes[child_id]
curr_boundary = curr_boundary + 620 * child.ntracks
total_boundaries = total_boundaries + curr_boundary
end
local parent_x = total_boundaries / (#parent.children-1)
parent_xlo = parent_x - 620/2
end
parent.surface_node = add_node(parent_xlo, y, parent.content, parent.id, grandparent_surface_node)
local parent_height = box_height(parent.surface_node)
local curr_boundary = xlo
for _,child_id in ipairs(parent.children) do
local child = Nodes[child_id]
render_node_and_descendants(child_id, y + parent_height + 50, curr_boundary, curr_boundary + 620*child.ntracks, parent.surface_node)
curr_boundary = curr_boundary + 620*child.ntracks
end
end

1
0646-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.mouse_release":586,"on.update":368,"scale":7,"add_node":590,"render_node_and_descendants":646,"vx":5,"compute_layout":619,"ntracks":600,"vy":8,"Nodes":593,"add_thick_line":400,"ensure_cursor_node_within_viewport":643,"Input_filename":436,"on.initialize":446,"to_text":180,"A":582,"line_height":365,"box_height":345,"on.keychord_press":644,"B":379,"fw_parent":645,"to_node":611,"fw_app":"mastodon-unfurl","initialize_editor":338,"add_edge":575}

View File

@ -0,0 +1,33 @@
render_node_and_descendants = function(id, y, xlo, xhi, grandparent_surface_node)
-- draw a parent 'id' and its children
-- also draw an edge from grandparent to parent if provided
-- position the root between xlo and xhi to be closer to children with fewer tracks
local parent = Nodes[id]
if parent.children == nil then
parent.surface_node = add_node(xlo, y, parent, grandparent_surface_node)
return
end
local parent_xlo
if #parent.children <= 1 then
parent_xlo = xlo
else
local total_boundaries = 0
local curr_boundary = xlo
for child_idx = 1,#parent.children-1 do
local child_id = parent.children[child_idx]
local child = Nodes[child_id]
curr_boundary = curr_boundary + 620 * child.ntracks
total_boundaries = total_boundaries + curr_boundary
end
local parent_x = total_boundaries / (#parent.children-1)
parent_xlo = parent_x - 620/2
end
parent.surface_node = add_node(parent_xlo, y, parent, grandparent_surface_node)
local parent_height = box_height(parent.surface_node)
local curr_boundary = xlo
for _,child_id in ipairs(parent.children) do
local child = Nodes[child_id]
render_node_and_descendants(child_id, y + parent_height + 50, curr_boundary, curr_boundary + 620*child.ntracks, parent.surface_node)
curr_boundary = curr_boundary + 620*child.ntracks
end
end

15
0647-add_node Normal file
View File

@ -0,0 +1,15 @@
add_node = function(x, y, node, parent_surface_node)
local surface_node = {
x=x, y=y,
width=600,
type='text',
data=split_lines(dehtml(node.content)),
bg={r=0.7,g=0.7, b=1.0},
toot_id=node.id,
}
compute_layout(surface_node, surface_node.x, surface_node.y, Surface)
if parent_surface_node then
add_edge(surface_node, parent_surface_node)
end
return surface_node
end

1
0647-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.mouse_release":586,"on.update":368,"scale":7,"add_node":647,"render_node_and_descendants":646,"vx":5,"compute_layout":619,"ntracks":600,"vy":8,"Nodes":593,"add_thick_line":400,"ensure_cursor_node_within_viewport":643,"Input_filename":436,"on.initialize":446,"to_text":180,"A":582,"line_height":365,"box_height":345,"on.keychord_press":644,"B":379,"fw_parent":646,"to_node":611,"fw_app":"mastodon-unfurl","initialize_editor":338,"add_edge":575}

1
0648-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"header":648,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.mouse_release":586,"on.update":368,"scale":7,"add_node":647,"render_node_and_descendants":646,"vx":5,"compute_layout":619,"ntracks":600,"vy":8,"Nodes":593,"add_thick_line":400,"ensure_cursor_node_within_viewport":643,"Input_filename":436,"on.initialize":446,"to_text":180,"A":582,"line_height":365,"box_height":345,"on.keychord_press":644,"B":379,"fw_parent":647,"to_node":611,"fw_app":"mastodon-unfurl","initialize_editor":338,"add_edge":575}

12
0648-header Normal file
View File

@ -0,0 +1,12 @@
header = function(node)
local result = {}
assert(node.account)
if node.account.display_name then
table.insert(result, node.account.display_name)
else
table.insert(result, node.account.username)
end
table.insert(result, node.created_at
table.insert(result, '---')
return table.concat(result, '\n')
end

1
0649-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"header":649,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.initialize":446,"on.update":368,"scale":7,"add_node":647,"render_node_and_descendants":646,"vx":5,"add_edge":575,"initialize_editor":338,"vy":8,"Nodes":593,"add_thick_line":400,"ntracks":600,"Input_filename":436,"compute_layout":619,"to_text":180,"A":582,"on.keychord_press":644,"box_height":345,"line_height":365,"B":379,"fw_parent":647,"to_node":611,"fw_app":"mastodon-unfurl","ensure_cursor_node_within_viewport":643,"on.mouse_release":586}

12
0649-header Normal file
View File

@ -0,0 +1,12 @@
header = function(node)
local result = {}
assert(node.account)
if node.account.display_name then
table.insert(result, node.account.display_name)
else
table.insert(result, node.account.username)
end
table.insert(result, node.created_at)
table.insert(result, '---')
return table.concat(result, '\n')
end

15
0650-add_node Normal file
View File

@ -0,0 +1,15 @@
add_node = function(x, y, node, parent_surface_node)
local surface_node = {
x=x, y=y,
width=600,
type='text',
data=split_lines(header(node)..'\n'..dehtml(node.content)),
bg={r=0.7,g=0.7, b=1.0},
toot_id=node.id,
}
compute_layout(surface_node, surface_node.x, surface_node.y, Surface)
if parent_surface_node then
add_edge(surface_node, parent_surface_node)
end
return surface_node
end

1
0650-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"header":649,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.initialize":446,"on.update":368,"scale":7,"add_node":650,"render_node_and_descendants":646,"vx":5,"add_edge":575,"initialize_editor":338,"vy":8,"Nodes":593,"add_thick_line":400,"ntracks":600,"Input_filename":436,"compute_layout":619,"to_text":180,"A":582,"on.keychord_press":644,"box_height":345,"line_height":365,"B":379,"fw_parent":649,"to_node":611,"fw_app":"mastodon-unfurl","ensure_cursor_node_within_viewport":643,"on.mouse_release":586}

1
0651-fwmanifest Normal file
View File

@ -0,0 +1 @@
{"render_thread_to_surface":626,"dehtml":456,"Cursor_node":172,"on.code_change":578,"copy_shape":396,"on.text_input":587,"header":651,"Surface":588,"update_editor_box":430,"load_from_iterator":463,"on.draw":632,"compute_ntracks":598,"on":1,"Viewport":303,"font":353,"split_lines":469,"schema1_of_y":366,"on.mouse_press":618,"y_of_schema1":364,"on.initialize":446,"on.update":368,"scale":7,"add_node":650,"render_node_and_descendants":646,"vx":5,"add_edge":575,"initialize_editor":338,"vy":8,"Nodes":593,"add_thick_line":400,"ntracks":600,"Input_filename":436,"compute_layout":619,"to_text":180,"A":582,"on.keychord_press":644,"box_height":345,"line_height":365,"B":379,"fw_parent":650,"to_node":611,"fw_app":"mastodon-unfurl","ensure_cursor_node_within_viewport":643,"on.mouse_release":586}

13
0651-header Normal file
View File

@ -0,0 +1,13 @@
header = function(node)
local result = {}
if node.account == nil then
table.insert(result, node.user)
elseif node.account.display_name then
table.insert(result, node.account.display_name)
else
table.insert(result, node.account.username)
end
table.insert(result, node.created_at)
table.insert(result, '---')
return table.concat(result, '\n')
end

2
head
View File

@ -1 +1 @@
644
651

2248
input

File diff suppressed because it is too large Load Diff

View File

@ -23,10 +23,15 @@ end
function get(ml)
local url = url_from_ml(ml)
local response, code, response_headers, status = https.request(url)
local basic_info = json.decode(response)
local result = json.decode(response)
local response, code, response_headers, status = https.request(url..'/context')
local rels = json.decode(response)
return {host=ml.host, user=ml.user, id=ml.id, url=basic_info.url, content=basic_info.content, replies_count=basic_info.replies_count, ancestors=rels.ancestors, descendants=rels.descendants}
result.host = ml.host
result.user = ml.user
result.id = ml.id
result.ancestors = rels.ancestors
result.descendants = rels.descendants
return result
end
posts = {}