Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/onyxfish/boiler

A jQuery plugin for creating near real-time updating widgets without push infrastructure.
https://github.com/onyxfish/boiler

Last synced: about 1 month ago
JSON representation

A jQuery plugin for creating near real-time updating widgets without push infrastructure.

Awesome Lists containing this project

README

        

h1. Boiler: An experiment in client-side everything.

h2. What the hell?

Boiler is a jQuery plugin that takes URLs to a mustache.js template and a data file (JSON or CSV) mashes them up and inserts their content into the page. Optionally, it will repeat the process of loading the data and regenerating the mashup and a configurable interval.

h2. Why!?

For near-real-time updates without complicated push/comet infrastructure. Clients can poll for a small datafile hosted on very cheap infrastructure (S3, etc.) and render it using a template that was fetched on load. The data file can be updated by a server process with no knowledge of its users and the client can repeat its fetch-and-render cycle very frequently.

The code as written is currently targeted at embeddable widgets, but the principle would be straightforward to apply to full-pages.

h2. Usage

You will need a way to serve the files. I suggest executing the following Python one-liner:


% python -m SimpleHTTPServer

Because this plugin supports cross-site hosting of the template and data files, your files will need to be wrapped in a JSONP callback. Boiler includes a script that will automatically do this for files put into the 'data' and 'templates' directories. You must run this before running the example:


% python jsonpify.py

Then visit:


http://localhost:8000/test.html

h2. Boiler + Stovetop

Boiler can be combined with "Stovetop":http://github.com/bouvard/stovetop to
fetch data from Google Spreadsheets.

h2. Is it tested?

Not at all. Only in the latest non-dev Chrome and only on OSX.

h2. Notes/TODO

* Hashing may be used to avoid re-rendering identical content.
* Its entirely unclear how fast this is or how frequent polling could be on "average" computers.
* In the future boiler will take a param specifying how often to poll for new content and automatically show/hide a loading icon ("throbber") in the rendered template (likely using a magic div id).
* User needs to handle "no-cache" headers on the data file or the browser will cache the result of the AJAX call.
* It would make sense for the JSONP requirement to be conditional depending on whether or no the AJAX requests are cross-site.

h2. Credits

All code by Christopher Groskopf--courtesy of a Saturday evening, good whiskey, and Chevelle.

h2. License

MIT.