this is the same stuff that was in projects.rb, just factored out into base.rb since it's reused twice now.