Mild-Mannered Canadian Fury

Doug Stephen is Politely Peeved

More Octopress Syndication Tricks: Publishing to Tumblr with a short description

Sat, 01 Sep 2012 Ā«permalinkĀ»

Inspired by Jonathan Poritsky’s Yahoo! Pipes wizardry yesterday, I have decided to undertake another syndication task that I’ve been wanting to do for a while: Auto-posting to Tumblr using Pipes + IFTTT.

While it would be trivial enough to simply mirror to Tumblr or just post random links to Tumblr, I don’t think that this is a very “nice” way of presenting this information. I’m most inspired by what Marco Arment does to syndicate his posts to his old Tumblr blog, wherein he often accompanies his links with a short blurb describing the article. I had been doing this manually, but not with any frequency, mostly because of the tedium. Like Marco, I originally started this site off on Tumblr, and I still have a rather small group of people that read what I do over there. But I don’t want to mirror the content, because I want MMCF to be the canonical location for all of my writing.

Using Pipes and a little Octopress jiggery-pokery, this was incredibly easy. The first step is to tweak your Octopress content just a tad:

Octopress Tweaking

The only real “tweak” to Octopress itself is a slight modification to your atom.xml, giving your posts explicit descriptions rather than letting them be auto-generated by your post content. This is easier than you might thing; the Jekyll yaml front matter actually has a “description” property built-in, and Octopress uses it to generate <meta> tags for descriptions/SEO purposes. Just not many people use it. As such:

Step 1: Start adding a description: property to the front matter on your posts

You’d have to come up with the short blurb for the syndication anyway, so you’re not really doing any extra writing.

Step 2: Extract this description and place it in every entry post

Next, we need to make sure that Yahoo! Pipes sees this tag as extractable content from the XML. I did this by adding a <description type="html"></description> tag pair to every <entry> in my atom feed, right before the content. It only contains the description from the yaml front matter:

atom.xml edits

Now that we’re taken care of on the Octopress end, we need to do some Yahoo! Pipes magic. I started off with Jonathan’s basic template, and this is currently what I’m using to syndicate to Twitter. I’m going to use the same feed to syndicate to Tumblr, since it this description and content thingy won’t interfere with the way the IFTTT recipe interacts with Twitter.

Setting up the Yahoo! Pipe

The IFTTT “RSS -> Tumblr” Recipe creates a Link Post, with the Title and Link easy enough to create by pulling the EntryTitle and EntryURL out of the feed much in the same way the Twitter recipe does. It’s filling in the text body that requires some tricks since IFTTT doesn’t offer a “EntryDescription” ingredient. So we’re going to use Yahoo! Pipes to replace the Entry Content with whatever is in the Description. This doesn’t do anything to your original feed; your readers will still be able to see the full content. Remember that Pipes simply uses your original feed as a source and performs wizardry to then output a new, independent feed of a different nature.

First, the Pipe, then the description of how it works. It looks like this:

Syndication Pipe

The structure of your pipe will vary, of course, depending on how your source atom is set up. For example, where Jonathan uses “guid” in his atom, I simply use “id”. Use the Debugger on the bottom to poke around your feed, and remember that depending on which block of the Pipe you have selected will modify what you see in the debugger.

I use the Loop module (an Operator) to perform this transformation on every “item.content” node in the feed. I then use the String Replace module (under String) to replace item.content.content with item.description.content, and assign the result of this function to item.content.content.

The item content is now the description we defined, and so when we syndicate to Tumblr we can simply extract the “EntryContent” ingredient from IFTTT and, like magic, we can syndicate to Tumblr with short descriptions for all of our posts!

Bonus Tip: Automatically ping the Feedburner Manual Refresh URL

Jonathan mentions the manual refresh URL from Feedburner, and how he saves it as a bookmarklet. With a simple one line addition to your Rakefile, you can automate this every time you run a deploy or gen_deploy.

Using the command-line http client of your choice (I prefer cURL over wget), simply have Ruby call out to the shell and have it run your command on the ping URL. I also redirect the output to /dev/null so it doesn’t pollute the output from the Rake task.

Add this one-liner to the very end of the deploy task. Mine looks something like this:

auto-ping Feedburner

I use exec instead of system because we aren’t worried about capturing the return status of the call. If it fails, it’s not a big deal.