bpartridge/angryponies — pull request #3 by matchu (2012-05-04 23:40:49+00:00)
Title: Offline mode

After playing around with it all day, I think this should do it! [Here's a super-cool screenshot, including the awesome "Playing in offline mode" message in the top right :D](http://i.imgur.com/NyQlJ.png)

Here's some important information from the last commit message:

> Because the Chrome extension is able to run as early as possible, it can prevent /fowl/\*.cache.js from being run. Therefore, we don't need the crazy iframe hack; instead, after ponify.js is injected, only then do we allow /fowl/*.cache.js to be injected, ensuring that all of our ponification hooks are already in place. (It was vital to avoid the iframe hack in order to get ourselves on the actual URL instead of "about:blank", because some assets weren't loading properly in offline mode without actually being on the correct page.)
>
> From there, it's just a matter of setting up the Angry Ponies assets in their own appcache, then dropping an iframe with the appcache manifest into the Angry Birds page to let the browser know that we're also interested in caching the pony assets.
>
> The big caveat right now: every time a pony asset is in any way modified, the developer must run "node appcache/manifest_gen.js" to generate the new appcache manifest file. This can be kind of a pain during development, especially development that involves significantly editing ponify.js. Perhaps a next step might be a developer mode that disables the appcache, and some nifty git hooks that generate the manifest on commit. Or, we could gitignore the manifest and have the server be responsible for
generating and caching the it each time the site starts up, and just let developers choose to have the file be absent in order to prevent caching in the dev copies. (If the cache file is absent, there's no error thrown; rather, Chrome will assume that the caching feature of the site is obsolete and will therefore delete all appcached files. So, it's all cool.)
>
>(Also, I'm not *entirely* sure that the installer.html iframe is inserted early enough; it seems to sometimes take two refreshes to see one's changes. That might be another important next step.)

Also should mention that the edits to ponify.coffee were very minor, only actually changing behavior if the `resumeFowl` function that the Chrome extension creates is present. I've confirmed that the Firefox version of the extension continues to work as expected, and I imagine the bookmarklet should be similarly unaffected :)

Hope this helps! Happy Friday!