18F/18f.gsa.gov — pull request #379 by gboone (2014-11-21 18:27:15+00:00)
Title: Adds functionality for sending tweets on publish

Another one I'm very open to feedback on. This plugin requires the "twitter" gem be installed on production environments only—which is nice. It does assume we want these tweets to be structured the same way. I'm thinking that's too rigid and that we'd want to create a front-matter entry for "twitter" and use that instead. These are easy to do if that's what we want.

- By default, will use the 'description' field from a post's front-matter along with the title and url to send a tweet
- Requires setting environment variables `TW_API_KEY`, `TW_API_SECRET`, `TW_TOKEN`, and `TW_SECRET` for twitter authentication.
- Requires environment variable to be set designating the production environment (export PRODUCTION=true should be set on the production server)

One flaw of this plugin is that it only supports publishing one blog post at a time. I don't really know if that's a bug or a feature. It's a little hard for me to imagine _us_ publishing more than one post at a time and wanting each of them to tweet immediately. But that doesn't mean it shouldn't be possible.

That said, it would be a difficult feature to build out if it becomes a need.

I'm also _pretty sure_ it will cannot happen, but builds will fail if the production environment attempts to send a duplicate tweet. This is because the Twitter gem throws an exception if it gets a 403 back from the API. I think it's impossible for the plugin to actually attempt it because if the post already exists in the built site, the post should get skipped.