Thorough fix of page-relative urls + some more refactoring + cleanup

* Moved some more code between the plugins and main server.js file.
* Some var declaration cleanup.
* More thorough handling of page-relative urls:
  - requires passing in the right page-relative url prefix
    through helpers based on the page url on which urls are
    being rendered.

  - FIXME: Revisit this. We used to have page-absolute urls but
    domain-relative urls till recently and because of the need to
    run duplicate services on the same server, and where those
    services can have "/foo" in the root url.

    Ex: http://parsoid-tests.wikimedia.org AND
        http://parsoid-tests.wikimedia.org/visualdiff

Change-Id: Iaf1c76a3530fc793a1627e860ad07736d0542a0d
Merge "Thorough fix of page-relative urls + some more refactoring + cleanup"