Remove dependence on request object.

I've removed the dependence on the request object by using protocol agnostic URL's in the views. This also makes it easier to test.