fixed saidebar links
improve gen_gallery.py

- add captions, contents and section titles
- closes #167