gsamokovarov/web-console — pull request #15 by gsamokovarov (2013-08-19 17:06:25+00:00)
Title: VT100 Terminal Emulator

While the adapters concepts worked well to some degree, it didn't allow us to support everything we wanted to. For example, we couldn't support features like interruptions, infinite loops and streamed output. This made us try to steer the project away from them and experiment spawning `rails console` processes with attached psuedo-terminals.

This concept has the benefits that we don't have to care what kind of `rails console` the user is using, as long as we act like a real terminal. It also gives us opportunities to run stuff like `/bin/login` and really act as a poor-man solution to `SSH`.

The trickiest part here is the actual terminal emulation. I started out trying to implement a custom VT100 terminal emulator as there are a lot of resources about online and it's the common denominator that the good terminal applications follow. However this is a lot of work, as I came to realize.

Hopefully, I was able to find a great VT100 terminal emulator written in JavaScript for the http://shellinabox.com project. However, the development of the project doesn't seem to be active at the moment, so I created my own fork at https://github.com/gsamokovarov/shellinabox to apply patchers for some of the unresolved problems and tweak the implementation for our use cases.

The separate fork is good for another reason too. The shellinabox project is under GPL-2, so if we are to modify the code directly from our vendors directory, we might count as a derivative work and need to be licenced under the same terms. I would hate that as much as everyone else would. Keeping the changes in a fork will work around that as we would just use the derivative work as is, which is fine with the GPL.

I have put a video of the terminal in action. You can see it at http://youtu.be/zjuJRXCLkHk.