Whitespace rework to produce consistent layout using 4-space indentation. Copy of #132

This is a duplicate of pull-request #132, except being against the dev branch.


Note: The real changes are +109 -68 if you ignore whitespace (and compare against my [other](https://github.com/emoncms/emoncms/pull/130) pull request. (and that's mostly minor format tweaking, a few additional comments (TODO, etc...) and a few cases where github's diff isn't working properly), or +841  −167 if you don't include my other pull request.

Apparently you can add `?w=1` to the end of a github pull request or comparison to get only the non-whitespace changes. [link for this pull request](https://github.com/emoncms/emoncms/pull/132?w=1)