A “Web Excursions” system for static blogs

[Tweet : nvALT]

Web excursions brought to you by MightyDeals.com, featuring great deals on software, training, and design resources.

Bookmarks in book

One of the things I was missing when I switched from WordPress to Jekyll was my “Web Excursions” setup. It allows me to gather link collections for posts as I browse and generate a single post with multiple links rather than a ton of individual “link list” posts”1.

Previously, I had just sent sites I wanted to include to Pinboard with a “blogit” tag and a description that would become the post. A WordPress plugin (Postalicious) would poll my bookmarks hourly and generate a post automatically when I had reached five or more new bookmarks with the given tag.

As a replacement, I created a CLI script that I could run manually, via cron/launchd or during the rake generate task which builds my static site. It works like this:

  1. Read in an existing stash of previously retrieved bookmarks
  2. Retrieve the latest pinboard bookmarks for ‘blogit’ tag
  3. Compare the new bookmarks to previous stash
  4. Add new bookmarks to a “draft” stash
  5. Add the bookmarks in the draft stash into the main bookmarks stash and save it to a file
  6. If the draft stash has 5 or more bookmarks
    1. create a draft post
    2. clear the draft stash

I have a custom draft setup that I’ll detail in a future post, but this basically generates a Web Excursions post in my drafts folder with all the necessary title, tags, categories, etc., and formats the new bookmarks using a Markdown template. I can then use Rake to publish at any time, and it updates the title and publish date to the current time.

If you’re interested in the script, help yourself. I’ve posted it as a Gist. It will eventually end up in a repository of my Jekyll hacks, once I have them all ready to share2.

Edit the various $conf[] variables to suit your needs. It should be flexible enough to work with any static blogging system, or even with the Blogging Bundle for TextMate.

Note: the first time you run the script it will pull all entries with the configured tag within the latest 100 bookmarks. It will create a draft with all of them and you’ll need to edit or discard that manually. After that it will only bring in new posts since the last run.

  1. Link list posts are great for some people, and I’m not against them. They just don’t fit my style.

  2. Many of them are dependent on others, and they won’t make sense if I publish them one at a time.