tsquillario/Jamstash — pull request #181 by Hyzual (2014-11-09 19:14:50+00:00)
Title: Major refactoring, Random starred songs

Hello there !

This might be a long post, hope you read it. Just in case :
**TL;DR** : I love Jamstash, I use it everyday. I want to help make it better. I've changed many things with this goal in mind.

See the result on my server : http://jamstash.furinax.com

This giant PR has 3 goals :

## 1. Change the "Starred" Auto Playlist so it selects random starred songs.

I've always wanted that to happen but never did write an issue for it :P. As my library grows, so do the number of starred songs, to the point where I now have ~1600. It's unmanageable for me AND for Jamstash which hangs when I hit play.
Even though Subsonic does not provide an API for that, I simply query all the starred things and let Angular cache it. Then I select randomly from the songs. This way, only the first query hangs for a short time.

## 2. Split everything in manageable files, in an easy to navigate structure

While working on the first goal, I found it very difficult to get any work done in giant, thousand lines long files. So I split them according to the view they belong to. Subsonic has now its own folder, which contains the template, the controller, the service and their respective tests. Archive has its own folder too, etc.
While doing this I've been able to solve all of the circular dependencies problems.

See the [Google best practice recommendation](https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub) for the motivation behind such a structure.

Besides files, I've also tried to split up things in their own Angular modules. This helps also in seeing and thus managing dependencies.

## 3. Use javascript tools to speed up development

In order to achieve the second goal and at the same time avoid having users make 500 http requests, one wants to concatenate and minify everything as much as possible. Grunt helps us do that, so we can create as many files as we need to.
Bower helps with managing dependencies and will enable us to upgrade them much more easily. The next time something breaks with jplayer, simply use `bower install jplayer latest`, test that everything works, and voilà !
Karma helps with unit testing and TDD. As this is the way I work, I wanted to be able to write unit tests for the features I touched. Together with Grunt, I could spin up a webserver, have it reload every time I change anything and run unit tests to see if everything is still working.

Finally, let me say again that I love Jamstash. I even used it during all the time I worked on it !
I think it can be even better and I want to be a part of it. Even though there is every possibility that this PR conflicts, I hope you'll accept it, and if not that you'll help me understand how to make it acceptable.
I've spent most of the day merging what you've pushed yesterday so I can certainly understand the pain related with breaking changes. Do let me know if something does break.

I've done my best to test everything and fix any errors I came across. I must admit that since I never really used it, I'm not sure if I saw every feature of the Archive.org tab, so if anything is broken it might be there.

I've taken the liberty of bumping the version to 4.1.0.
I've tried to fill in the metadata of the package.json and bower.json files to the best of my abilities. There might be some missing contributors, I added everyone displayed by github but I think not everyone who commited is on github.
I've added how to install everything with npm and bower in the readme. If you need more info please message me.

Best regards, Hyzual