refactor preview function to clean things up
add current site to flask 'g' global context