My recent interest in social software hasn’t been limited to hanging around on Orkut—in fact, it’s spilled over into my personal coding projects as well. Recent diversions from more pressing matters have included a number of experiments, some of which may or may not see the light of day. I did manage to finish one up today, however, and therefore I’m announcing the release of my first Blosxom plugin: a little something I call Autoxfn 1.0:
- autoxfn (Perl Source, 3k)
So what does it do, then? Well, first you need to know about XFN, a metadata profile devised by Tantek Çelik (and a few other people I’m not as familar with). It allows webloggers to represent relationships, Friendster-style, through hyperlinks (using simple “rel” attributes in anchor tags). For example, to identify someone as a friend I’ve met in person, I can use something like this:
<a href="http://www.soandso.com/blog" rel="friend met">Link</a>
XFN appeals to me because:
- It fits well with my belief that weblogs are a more effective, less evil, form of social software than friend-of-a-friend sites.
- It meets one of my favorite criteria for great technology: it’s simple.
My only problem with XFN is that it offends my software engineering sensibilities by essentially mixing the model (the relationship data) with the view (the front-end web page). Imagine, for example, that I decide so-and-so is no longer my friend. I now have to go through all of my links and remove the “rel” attributes on so-and-so’s links.
Autoxfn solves this problem by storing the relationship data centrally (in a tab delimited text file) and automatically adding the appropriate “rel” attributes to all links matching given criteria. For example, if the XFN file contains a line like this…
So-and-So soandso.com/blog friend met
…Autoxfn will look for all all links with “soandso.com/blog” in the href and automatically add “rel=’friend met’” to them. Voila: separation of data and presentation acheived!
A few additional notes:
- The URL match string can optionally be treated literally, or as a regular expression (there is a configuration variable to switch).
- Pattern matching peformance is kept reasonable by precompiling all of the regular expressions at startup. The plugin is running right now on my weblog and doesn’t seem to be causing any noticable drag. Still, people with ridiculous numbers of friends (Marc Canter, I’m looking at you!) may experience some slowness (finally, what Friendster has needed all along: a penalty for friend-whoring!)
- The anchor matching regular expression is one of the most obscure (and therefore, in the world of Perl, coolest) I have ever written (try maintaining that future generations of coders!). It should also be liberal enough to warm Mark Pilgrim’s heart. Pretty much any malformed markup that Safari will let you get away with will also be tolerated by Autoxfn.
- Right now, Autoxfn is Blosxom specific, but I’m sure it could be adapted to work with Moveable Type as well (sort of like John Gruber’s SmartyPants). I might look into it, but I don’t have a working MT installation (and I don’t really feel like setting one up—that’s why I use Blosxom in the first place), so if anyone wants to help, let me know…
(Update: In addition to making an interesting link between XFN and Jon Udell’s experiments with “class” attributes, Bill Humphries has done a much better job than me of explaining what the heck Autoxfn actually does!)