Reopen pull: First pass at pulling logic out of the template and simplify some of the logic too

See discussion in https://github.com/Automattic/msm-sitemap/pull/45, only change since reopening the pull is: https://github.com/pkevan/metro-google-sitemap/commit/cf254f9e1224743d21d4f859e5ef7489fcc3e597