Taking the happyhour OpenSocial party offline with Gears




We ran across happyhour, an OpenSocial container that implemented the JavaScript API in JavaScript itself. The happyhour project uses Gears to keep the social content around across sessions, which is an issue with a pure in-memory solution. This allows you to more easily login as multiple users in different browser windows to see "friend" interaction.

The motivation for the project was speeding up the development cycle of OpenSocial components by allowing developers to bypass talking to a production server, or even a local one. Load up an HTML file and you are good to go. This also helped when getting designers into the mix as they could just style the HTML and they were done.

The container supports Caja, and adds useful minor features such as munging between a JavaScript date, and an ISO 8601 date that SQLite uses:
opensocial.HappyHourContainer.prototype.toISO8601String = function (date) {
var zeropad = function (num) { return ((num < 10) ? '0' : '') + num; }

var str = "";
str += date.getUTCFullYear();
str += "-" + zeropad(date.getUTCMonth() + 1);
str += "-" + zeropad(date.getUTCDate());
str += "T" + zeropad(date.getUTCHours()) +
":" + zeropad(date.getUTCMinutes())+
":" + zeropad(date.getUTCSeconds());
var ms = date.getUTCMilliseconds();
str += "."+(ms < 10 ? "00"+ms : (ms < 100 ? "0"+ms : ms));
return str;
};

In your application, you will probably want to pass in a bootstrap callback where you can insert dummy data to get going.

Brad Neuberg and I got to chat with Chandra Patni, the developer behind the project, and you can watch and listen to his thoughts below: