Change double quotes in search() to single quotes.
Refactor search() controller to make it more comprehensible and ferret out bugs.

I was tired of looking at that ugly mess. This still isn't great, but it's a start.

* Don't crash when limit and offset query string params aren't parseable ints.
* Don't crash when format=json and we're using the error.html template.
* Deal with negative limits and offsets. Hey, why not?
* Don't HTML-escape the query text manually anymore. Do urlencode it when using it in a URL.