blahed/frank — pull request #73 by stephan-buckmaster (2012-05-09 01:05:50+00:00)
Title: Two auto_refresh extensions

Hey, I use frank for some kind of advanced computation output, very fancy.

I put computation code in the lib directory, and place display in dynamic templates.

The auto_refresh feature makes it so that a file-save becomes like a "return" in a terminal: the results of the computation, from new code or display-changes, show up in my browser immediately.

This works all very nice. I ran into two issues, which these changes fix:

1. The watch_dir which is used for Frank::Middleware::Refresh did not allow any configuration (couldn't watch for changes in my lib directory)
2. When computations take a while (> 5 sec), the auto_refresh javascript would send multiple refresh requests.

For (1) I allowed configuration by reading an environment variable "FRANK_REFRESH_DIRS" which is appended to the "watch_dirs"

For (2) I added a javascript variable "loading" which is set when the page is reloaded, and prevents any further reloads. While the new page is loading, a more-or-less fancy loading indicator section is displayed on the page. Automatic refresh can be disabled through simple javascript "window.stop_refresh_check = true"

Cheers!