mutewinter/Showbot — pull request #47 by gouwens (2013-03-20 04:18:04+00:00)
Title: Word Clouds

I ported my title suggestion [word cloud project](http://gouwens.net/blog/2013/2/25/through-the-eyes-of-the-jackals) into Showbot so that clouds can be created off the live data. This version uses the [d3-cloud](https://github.com/jasondavies/d3-cloud) Javascript layout engine by Jason Davies (with slight modifications) to create the clouds themselves.

There are a few new interfaces that generate the clouds. Going to `/clouds_between/[days_ago_1]/[days_ago_2]` will create clouds for all the episodes in the time range specified. So, for example, if you wanted to see the clouds for the past week, you could go to `/clouds_between/0/7`. **Warning:** The first time any cloud generation happens, it will take a very long time because it has to count terms across all episodes in the database. After that, it will update those counts by going through new episodes that occurred since the generator last ran.

Another interface is `/cloud_svg/[year]/[month]/[day]/[index]`, which will generate a single cloud by itself. The index tells it which episode you want on that day (i.e. if there were three episodes you can choose 0, 1, or 2). The idea behind this view is that it could be more easily saved as a PNG or SVG by something like [phantomjs](http://phantomjs.org). To find out how many episodes happened on a given day, you can access `/num_clouds_on_date/[year]/[month]/[day]`, which will return a JSON structure that looks like:
`{ "num_clouds": }`

Again, I'm not sure what exactly would need to happen on the server to automatically generate and save the images, but I tried to create the components that would allow it to happen. I'm certainly happy to work on it more to better adapt it for a particular situation.

In any case, here's an example created for Hypercritical #57 (using all the Hypercritical titles as the database):
![cloud_test](https://f.cloud.github.com/assets/2352483/279221/0a1158a8-9114-11e2-929e-b1b966d2ff42.png)