Rewrite linking code

This now uses the links on the page itself to link to chat, main, and meta.  There's logic to determine whether we're linking to a main or meta site.