# Visualize a Mastodon thread tree
An experiment inspired by Colin Wright's [Chartodon](https://mathstodon.xyz/@Chartodon).
[demo](assets/demo.webm) (video; 20 seconds)
Cons:
* Doesn't run in a browser. You need to install several small, reputable Lua
tools.
* Not as pretty as Chartodon.
* Might not work on Windows. Please report your experience if you try it.
Pros:
* Use keyboard shortcuts to browse the graph.
* `ctrl+up` to parent
* `ctrl+down` to first child
* `ctrl+left` to previous sibling
* `ctrl+right` to next sibling
* Much easier to modify to your needs than a web browser. You can
modify it while it's running (see below).
This repo is an example of a [Freewheeling App](http://akkartik.name/freewheeling),
designed above all to be easy to run, easy to modify and easy to share.
## Getting started (LÖVE v11)
Install the [Lua](https://www.lua.org) programming language. Just a 200KB
download, open source and with a stellar reputation. I'll assume below that
you can invoke it using the `lua` command, but that might vary depending on
your OS.
Install the [luasec](https://github.com/brunoos/luasec) library for https
access. One way to accomplish this is to install the [LuaRocks](https://luarocks.org)
package manager and then:
```
$ luarocks install luasec
```
(I haven't been able yet to install luarocks+luasec on Windows 11.)
Install the [LÖVE](https://love2d.org) game engine. It's just a 5MB download,
open-source and extremely well-behaved. I'll assume below that you can invoke
it using the `love` command, but that might vary depending on your OS.
Run `unfurl.lua` from this directory, passing in a link to some toot. For
example:
```
lua unfurl.lua https://merveilles.town/@akkartik/108773157588384635
```
unfurl.lua will make some Mastodon API requests before passing the results to
LÖVE.
Click on any toot to copy its URL to the clipboard.
## 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.
Click on any toot to copy its URL to the clipboard.
## Hacking
To modify the code for the app without restarting the app each time, download
[the driver app](https://git.sr.ht/~akkartik/driver.love). Here's an example
session using a different app:
![making changes without restarting the app](assets/2.gif)
[Some reference documentation on how to create your own apps.](reference.md)
If the app being modified by the driver lives in a .love file, your changes
will go into the [save directory](https://love2d.org/wiki/love.filesystem.getSaveDirectory).
If it lives in a directory (like this repo), your changes will go straight
into the same directory.
## Keyboard shortcuts
* `ctrl` + arrow keys to move around
* `ctrl+=` to zoom in, `ctrl+-` to zoom out, `ctrl+0` to reset zoom
Exclusively tested so far with a US keyboard layout. If
you use a different layout, please let me know if things worked, or if you
found anything amiss: http://akkartik.name/contact
## Known issues
* No support yet for Unicode graphemes spanning multiple codepoints.
* No support yet for right-to-left languages.
* No scrollbars yet. That stuff is hard.
## Mirrors and Forks
This repo is a fork of [lines.love](http://akkartik.name/lines.html), an
editor for plain text where you can also seamlessly insert line drawings.
Its immediate upstream is [a simple Lua-based markup language](https://git.sr.ht/~akkartik/luaML.love).
Updates to it can be downloaded from:
* https://git.sr.ht/~akkartik/mastodon-unfurl.love
* https://tildegit.org/akkartik/mastodon-unfurl.love
* https://git.merveilles.town/akkartik/mastodon-unfurl.love
* https://nest.pijul.com/akkartik/mastodon-unfurl.love (using the Pijul version control system)
Further forks are encouraged. If you show me your fork, I'll link to it here.
## Feedback
[Most appreciated.](http://akkartik.name/contact) Messages, PRs, patches,
forks, it's all good.