Refactored gallery viewer into a directive.