Behind the Scenes

How Mother Jones built a Donald Trump insult generator

The media is on a tear sifting through presidential hopeful Donald Trump’s speeches to find his most noxious and memorable quotes. Some outlets, like Time  and Mother Jones, have built interactive applications that allow a user to input her name and be personally “insulted” by Trump.

We spoke with Ben Breedlove, a web developer at Mother Jones, about how his team built their insult generator. New to coding? Try our headline generator tutorial.


Who pitched the idea?

Tim Murphy did the pitching and writing and the research and the putting together of the data we used.

How did you build the insult generator?

It’s a branch off of a tool we use for creating mashups of strings for insults, headlines, whatever. You can find the code we used here. For the Trump piece, I added a form to take in the readers name, so we could put it in to our templates.

How do you input data into the generator?

The random sentence maker is one of a bunch of tools that we’ve made that rely on Google Spreadsheets to get structured data out of our journalists without making them learn JSON. [See the Google spreadsheet here.]



How do you connect the Google Spreadsheet to the Trump story?

We usually use Tabletop.js to pull from Google Spreadsheets. Right now, we’re running live off the Google Spreadsheet for the Trump piece.

How does it randomize the data from the spreadsheet and generate an insult?

We randomly select a value from each column, and use that as the context to fill out a dust template, and slap it on the page. The part I’m particularly pleased with, for our random sentence maker, is that we randomly select the template to use, as well.

DON’T MISS  The art of fear: How the YouTube channel 'Spikima Movies’ made film analysis its own cinematic experience

How did you put it all in the CMS?

We link to our dependancies and paste our code directly into the CMS. We end up just copying and pasting all the pieces separately.

Any interesting challenges?

We only had one Trump quote that followed the construction “I’ve been warning about {name} since the 80s”. In order to have that quote not show up 1/3rd of the time, instead of ~1/20th of the time, we added duplicates of the other templates to our array.


What should students and newsrooms keep in mind when building this kind of a news app, especially on deadline?

I think as an organization we’ve done a pretty good job keeping the possibility of reuse in mind when we’re creating tools, and we’ve done a good job keeping our tools organized on Github so we’re ready to roll them out quickly. If we hadn’t had the random sentence generator in our back pocket, there’s no way we could have put the Trump insult generator together nearly as quickly. As it was, all I had to do was put together a form for grabbing the readers name and we were ready to roll it out in about an hour.

Where can we go for more Mother Jones code?

We’ve got a list of our tools that follow the same basic pattern of turning Google Spreadsheets into cool stuff over here and we love it when people use them.

Aleszu Bajak
Latest posts by Aleszu Bajak (see all)
DON’T MISS  How The Washington Post offered readers an immersive look at Puerto Rico without power

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest from Storybench

Keep up with tutorials, behind-the-scenes interviews and more.