Serious overhaul of the api.

* The api is now defined in api1.py
* The database is now defined in its own file
* The detail view now use viewstate
* TimeUtils now defines a default time span map.