moved some template stuff from javascript to jinja2; partial implementation of sections