Extract Theme Logic

I started to extract theme generation logic in a separate file to be able to do a gulp/grunt/react/...whatever theme generator. As I explained #980 

I just refactored the code to extract logic... I wiil now extract angular deps, and do the right tests.

I PR at this stage, then if you want to merge that in wip-theme, it will be easier to merge if someone else work on themes...

Regards and thank you for your work.