In LÖVE v12 you no longer need to run it through the unfurl.lua shim,
and you can now open new threads by pasting their links into the app
using ctrl+v
.
TQUVV6ZZAXGVEFRBUHRXFUIZYVBT5VFGUKSM25MYWS3QF6OB4VEQC
QVTMKCHF42UO2Y5EI2I22YWUNWYE5LJM6KQS3VBH5NTNQNIVF6NAC
3RLPFCICVQARJBY26A4SX3JZCQWMGPOZC5TDIKHJ75M4EPKJVAWQC
QQNT7EE4ZKTX2N6WNMCWCNYTBYSP3GD23TOODN6NOFCOF32QWO4QC
HMH2GYB6BLH4HE7N6J6ZK57RKFICWXSU3KJL7EGYTXJ5DC5XHBIQC
36Z442IVPXHZ7D2QI26YLN3TDDEMDRQ2GKBYQAD6NUHQZVCCY4VAC
TVCPXAAU4P3K5MFYINH2MWDK3KGTQ2GE74TUNERYOONG2G5EYKMQC
OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC
HUDGLWXFMJ2KIMJTTDLYCCTNEFFIE4HQXVF6VU362XQTEEZTRWBAC
DFXPZNH6FTVKXXFSTTE6UO7UK7A5H3JMYUDQPQSTPWP4SXAVEMLAC
FS2ITYYHBLFT66YUC3ENPFYI2HOYHOVEPQIN7NQR6KF5MEK4NKZAC
PNBKVYZ4ANUAZNQN6KEWYNDF7552ROZPNAPRJE7Q6O7ZZJMJ3S3QC
H2KZUAWHQXTRUFDPDH4AUG6EP3OR5U3GGFPVGTCY2XJB3WOEO7TQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
QDXO357AHOOUH3RHQFIF6XHLWOEGZFCSGUHPIL6QIQNY53CPNXFAC
BF7TW3EKRIDYC6J2Q2J4YOBAVQF55Y3H6KGZIHNXMH4N72MR6GXQC
X7HYGAL2QVKG7M5EMZ2VSH37UYWGE3EPUXYQBJOVL6IGJFZ2I5AAC
## Getting started (LÖVE v12 pre-release)
Install LÖVE from a nightly build.
* Go to https://github.com/love2d/love/actions
* Click on the most recent successful build (with a green check mark before it)
* Scroll down to the "Artifacts" section
* Download the artifact for your OS
* If you don't have a Github account, these won't be clickable.
Copy the URL for the build and paste it into https://nightly.link to get
clickable links to artifacts.
Run LÖVE from the commandline and pass in this directory. Optionally also pass
in a link to a Mastodon toot.
Copy a link to any mastodon toot and paste it into the app window using
`ctrl+v` to view it in the context of its thread.
url_from_ml = function(ml)
return ('%s/api/v1/statuses/%s'):format(ml.host, ml.id)
end
ml_from_url = function(url)
local host, user, id = url:match('^([^/]*://[^/]*)/@([^/]*)/(%d*)$')
if host then return {host=host, user=user, id=id} end
local host, user, id = url:match('^([^/]*://[^/]*)/users/([^/]*)/statuses/(%d*)$')
if host then return {host=host, user=user, id=id} end
end
Url = nil
try_load_nodes_from_url = function(initial_ml)
local result = get_toot(initial_ml)
if result.ancestors and #result.ancestors > 0 then
-- redo with oldest ancestor
result = get_toot(ml_from_url(result.ancestors[1].url))
end
return result
end
get_toot = function(ml)
local url = url_from_ml(ml)
local code, response, response_headers = https.request(url)
local result = json.decode(response)
code, response, response_headers = https.request(url..'/context')
local rels = json.decode(response)
result.host = ml.host
result.user = ml.user
result.id = ml.id
result.ancestors = rels.ancestors
result.descendants = rels.descendants
return result
end
if Input_filename then
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
local f = io.open(Input_filename)
assert(f)
local thread_data = json.decode(f:read('*a'))
f:close()
render_thread_to_surface(thread_data)
if Major_version >= 12 then
-- reload Url from network
if Url then
local initial_ml = ml_from_url(Url)
local thread_data = try_load_nodes_from_url(initial_ml)
render_thread_to_surface(thread_data)
Cursor_node = Root
if Nodes[initial_ml.id] then
Cursor_node = Nodes[initial_ml.id]
end
ensure_cursor_node_within_viewport()
end
B()
else
-- LÖVE pre-v12 has no https
-- reload same thread from file
if Input_filename then
love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font
local f = io.open(Input_filename)
assert(f)
local thread_data = json.decode(f:read('*a'))
f:close()
render_thread_to_surface(thread_data)
end
B()
elseif chord == 'C-v' then
-- load new URL
if Major_version >= 12 then -- requires LÖVE with https
-- ignore stuff in the clipboard that doesn't look like a url
local cb = App.get_clipboard()
if #cb > 300 then
print('clipboard: '..cb:sub(1,300)..'...')
else
print('clipboard: '..cb)
end
if cb:match('^%s*https://[^%s]*%s*$') then
print('clipboard contains a URL')
Url = trim(cb)
A()
end
end
if #arg == 0 then
error('Please pass in a file containing a Mastodon thread, and optionally an id within it to start out focused on.\n\nThis app currently needs to be invoked from a terminal.')
end
Input_filename = arg[1]
A()
Cursor_node = Root
if #arg >= 2 then
local initial_id = arg[2]
if Nodes[initial_id] then
Cursor_node = Nodes[initial_id]
if Major_version >= 12 then
-- LÖVE has https
-- commandline arg is a url
if #arg > 0 then
Url = arg[1]
A()
end
else
-- LÖVE pre-v12 doesn't have https
-- we depend on an external shim to download
-- commandline arg is a filename
if #arg == 0 then
-- no ability to load new URL
error('When running with LÖVE v11, please pass in a file containing a Mastodon thread, and optionally an id within it to start out focused on.\n\nThis app currently needs to be invoked from a terminal.')
end
Input_filename = arg[1]
A()
Cursor_node = Root
if #arg >= 2 then
local initial_id = arg[2]
if Nodes[initial_id] then
Cursor_node = Nodes[initial_id]
end