separate basic gallery functionality

to be more flexible with creating galleries we can separate gallery
functionality so it can be reused if developer wants to create a
gallery but not necessarily a gallery page