So, a while ago, I moved my blog to github, using jekyll and markdown, with jekyll integration in Emacs.
That works great, and I like the fasct that posting a blog entry is just a regular git push.
My blog is aggregated in some places, but it doesn’t appear on blogs.perl.org, because it’s not an aggregator (and that’s cool, it’s not its purpose). But, blogs.perl.org audience is big, and I’m missing all these potential readers (in improbable case people would actually be interested in what I have to say :) )
Anyway, so I decided to bite the bullet and write a script that would cross post my entry to blogs.perl.org. I made the script generic enough to work with different type of blogs, but here I’m going to explain only the blogs.perl.org specific case.
blogs.perl.org is a Movable Type blog engine. A look on Metacpan indicates us there is a Net::MovableType module. That’s great, let’s use that.
There is a catch: to use this module, you need your login, and your API password, not your regular password. You can get it easily though, by following these instructions (thanks to davorg for directing me to it).
To avoid storing the user / password in the script, and to have to pass it on
the command line, let’s have a configuration file, that will lie at
~/.crosspost.ini
, and that we’ll load with
Config::Any::Merge.
The file name of the original post will have to be passed on the command line, using Getopt::Long and Path::Class to retrieve and slurp it.
Here is the configuration file.
# file ~/.corsspost.ini
[ main_blog ]
title = dams blog
url = http://damien.krotkine.com
[ blogs.perl.org ]
type = mt
username = foo
password = bar
url = http://blogs.perl.org/rsd.xml
And here’s the code:
Missing in this code is some mungling of the text to manage jekyll specific syntax. And while I was at it, I improved it so that it supports cross-posting to twitter, using Net::Twitter, and posting only a short description of the entry. Here is an example (I had to create a custom Twitter app called blog-cross-poster)
Now, I just need to add a git hook to be executed at push time, check if there is a new post or a modified one, and cross post it. Yay !