Octopress, Planet.rb and the Nilenso Blog

We use Octopress with planet.rb for this blog. It aggregates our personal blogs and also lets us post on the company’s behalf. It works pretty well.

We started off with planetplanet, tried planetvenus and then settled on planet.rb. The plusses are:

  • We can now use the blog as both: a company blog and an aggregator at the same time.
  • Octopress is great for us Ruby devs. We needed partials, sass, themeability, extensibility and a static site.
  • planet.rb generates markdown files for all the feeds it parses. This keeps it consistent with the rest of the blog, and we love writing markdown.

The tweaks we needed

Planet.rb is still in development, and there were a couple of things that needed to change before we could release. We sent pull requests for these which are now merged in to planet.rb v0.5.0.

A whitelist

One such feature was the ability to filter posts that are not suitable for the company blog. We implemented this as a whitelist of tags. Only posts that have any tags in the whitelist will be imported.

planet.yml
1
2
3
4
planet:
    posts_directory: source/_posts/
    templates_directory: source/_layouts/
    whitelisted_tags: ["nilenso", "open source", "software", "gsoc", "gnome", "lifehacks", "dev"]

Fault tolerance

Another issue with planet.rb was that it quit abruptly when it failed to parse a blog because the blog was unreacheable. We fixed that and then it was good to go. Here’s how it looks now when we run planet generate:

$planet generate
1
2
3
4
5
6
7
8
9
10
11
12
planet-nilenso|master ⇒ planet generate
=> Parsing http://blog.kitallis.in/feeds/posts/default
=> Found post titled GSoC - 1 & 2 - by Akshay Gupta
        => Ignored post titled: Computers with categories: [personal]
=> Found post titled GSoC 2011 - 0 - by Akshay Gupta
=> Found post titled "Open Containing Folder" for EoG and gedit - by Akshay Gupta
        => Ignored post titled: Init with categories: [personal]
=> Parsing http://blog.deobald.ca/feeds/posts/default
        => Failed to fetch http://blog.deobald.ca/feeds/posts/default with response_code: 0
=> Parsing http://blog.timothyandrew.net/atom.xml
=> Found post titled Encrypt Your Emails on OS X - by Timothy Andrew
=> Found post titled Pow Over HTTPS - by Timothy Andrew

The deploy hook and cronjob

We use Capistrano to deploy our blog. Here’s the post deploy hook that we use on it:

config/deploy.rb
1
2
3
4
5
task :octopress_planet_generate do
  run "cd #{deploy_to}/current && bundle exec planet generate && bundle exec rake generate"
end

after "deploy", :octopress_planet_generate

Taking the final step in automating this, we set up a simple cronjob to aggregate posts everyday:

$crontab -l
1
@daily cd /path/to/blog && planet generate && rake generate