encryptio.com

This sentence is very meta.

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:

You can see the scripts output in action here.

A developers preview of the code is avaliable here. The code is a mess and is undocumented. Ill 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, youll need to record something.

shell$ ttyrec -e vim outfile.tty
...do vim stuff...

Then youll need to preprocess it into that JSON format. (You have to give the preprocess script the size of your terminal - its not stored in the ttyrec file.)

shell$ perl preprocess.pl --size NNxNN outfile.tty outfile.json

Copy that somewhere on your server, however you like. (I use scp here)

shell$ scp outfile.json eighty:www/files/outfile.json

And then set up your page with the information needed to tell the player where your file is:

<div id="tty">Enable JavaScript to see the animation.</div>
<
script src="showtty.js"></script>
<
script>
showTTYURLdocument.getElementById("tty"), "/files/outfile.json" );
</script>

If youre using this script or have any comments, please tell me!