Add functionality to save and display queries

* Queries support versioning by default
* Hitting 'Run Query' now creates a new revision
* Sharing the URL displays a read-only copy of query
* Added jsvars support to the base template

Change-Id: Id6c1d3734e1579c0368bc5ed086ba4cf04491051