jsttyplay
jsttyplay is a set of scripts written in Perl and JavaScript to allow ttyrec logs to be played back in a web browser.
When I first posted the source to my twitter irssi script, the usage seemed awfully complicated to explain in text. Luckily, I stumbled upon TTYShare, a site that lets you upload ttyrec logs and have them play in a Flash player. I thought it was a great idea, but the site itself was horribly broken. I then started working on a replacement for it, using JavaScript as the playback engine with a Perl preprocessor. It took about 2 days of work to get it working, then another 4 days making it work with screen properly.
I plan to eventually implement these features:
- Controls and scrubber for playback engine
- Object-oriented JavaScript interface
- Emulation of odd terminal charsets (for elinks and naim)
- Unicode support
- Full test suite, based on the VT102 and VT320 manuals.
You can see the script’s output in action here.
A developer’s preview of the code is avaliable here. The code is a mess and is undocumented. I’ll be cleaning up the code and documenting the pieces as time goes by.
Structure and Usage
The script is seperated into two major pieces: the preprocessor and the player. The preprocessor takes a ttyrec log and turns it into a JSON file with all the information the player needs to play back the file successfully.
First, you’ll need to record something.
...do vim stuff...
Then you’ll need to preprocess it into that JSON format. (You have to give the preprocess script the size of your terminal - it’s not stored in the ttyrec file.)
Copy that somewhere on your server, however you like. (I use scp here)
And then set up your page with the information needed to tell the player where your file is:
<script src="showtty.js"></script>
<script>
showTTYURL( document.getElementById("tty"), "/files/outfile.json" );
</script>
If you’re using this script or have any comments, please tell me!