Tuesday, June 10, 2008

Announcing the web-screen-saver project

I finally got around to posting a little tidbit of source code I had lying around on my computer as the new open-source project web-screen-saver (really lame name, I know). Not only that, but the premise seems a bit lame, too. Who would want a screen-saver that runs in their web browser?

It turns out I do! I have been learning about aviation weather and the best way to stay fresh is to practice every day, so I took a really old Toshiba laptop (Pentium MMX @ 166 MHz, 16 MB RAM and a 2.1 GB HD), got it running again (which involved soldering frankensteining an equally-as-old power supply from a Futjitsu laptop, not to mention putting the disassembled laptop back together from memory) and set it on top of my refrigerator. This way, whenever I'm preparing meals, washing dishes, feeding the cat, etc. in the kitchen, I can take a minute or so to browse the latest weather.

Next up was figuring out how to get various semi-frequently-updated images to show up on the screen on a cycle. Various options popped up, such as:


  1. a cron job that would trigger wget on a few URLs with one of:

    1. a companion program that would convert the HTML pages to images and rescale pure images appropriately and a corresponding client (any of many file-system-based screen-savers)

    2. a static page that would cycle the pre-downloaded pages or images using a bit of JavaScript

    3. a number of static pages that serve up one pre-downloaded page or image for a little bit of time before redirecting to the next



  2. a static page that would cycle the live pages or images using a bit of JavaScript

  3. a number of static pages that serve up one live page or image for a little bit of time before redirecting to the next



Some of the above options don't make that much sense until you consider that aviation weather is the kind of information that's sensitive to updates (or the lack thereof) and so it is of the utmost importance to always have the latest version of, say, a TAF or a GFA cloud & weather map. With some web browsers reportedly overzealously caching pages or images coupled with sometimes unreliable internet connections, I was trying to explore the space of options so that I could potentially detect the worse case and do something about it.

I ended up deciding to see whether the current browsers that I use/care about indeed [still] suffered from that problem, since it would eliminate an entire class of problems/solutions. Turns out that improper browser caching no longer appears to be a problem, although this could also be due to proper configuration programming at the server end. That, and the prospect of having to write client-server code that scanned files coming from remote computers sounded more stupid every second I continued to think about it since, you know, web browsers do that sort of thing already!

A few evenings of light programming (i.e. tweaking a few lines of code here and there during a few boring moments of TV watching) and I've got what I think is "version 1.0"-worthy. It's running right now on the trusty laptop in Internet Explorer 6[1] in full-screen mode (hide the status bar, hit F11, then right-click on the toolbars to select auto-hide), although with this much RAM it just swaps and thrashes like hell for a minute or two on every reload. I also need to reboot it every so often because the USB wireless adapter's driver is as stable as the U.S. economy. *cough*

Download


Download version 1.0: awesome-web-screen-saver-1.0.html.
View source of version 1.0: index.html
Live demo (latest version): Aviation Weather Electronic Summary Of Major Events

How to use


Once everything loads, all but the first page/image will be "hidden" (it's really a clever lame container resizing trick). After 2 minutes, the next page/image will be shown, etc. until about 33 minutes at which point the whole thing will reload. You can, of course, scroll up and down, but you may want to use the left and right arrow keys, since they are programmed to jump back and forward (respectively) at page/image boundaries.

Roadmap for future versions



  • JavaScript code to live in its own file

  • META-based refresh to be adjusted based on the number of "pages"

  • better handling of unavailable content (i.e. keep retrying - with suitable back-off - iframes or images that returned anything other than HTTP 200)

  • use Google App Engine for the following features:

    • configurable content profiles (i.e. pick your own frequently-changing content)

    • content caching (i.e. Google's servers can withstand more hits and will probably replicate content to various globally-distributed data centers for higher availability)

    • content download scheduling (i.e. while you have both of the previous two features, you might as well configure content with an expected lifetime or scheduled release, so that it is only pulled once, per publishing, from its source)

    • stats collection

    • general geekiness





Notes


[1] This will probably cost me a few geek points, but the laptop is still running the Windows 98 copy it came with - I couldn't get any GNU/Linux distro to boot/install and I have better things to do with my time!

No comments: