Blog

Adding XFN

I recently readded XFN tags back into my links (read: blogroll), which are another Microformat open standard. As with most microformats it’s very simple, and some blogs will do it for you by default. What it basically means is you add rel=”relationship” to the link of the person to give the link some additional meaning.

For example, if I wanted to link to my friend Lana, I can write:

<a href=”http://lanadenise.wordpress.com” rel=”met friend”>Lana’s blog</a>

This indicates that Lana is a friend who I have met. If you leave out the “met” it can be a friend you haven’t yet met (i.e. online). There’s a handful of predefined relationships that should be used but there’s just enough. You can indicate family members, co-workers and vague connections.

Why would you bother, I hear you ask? Well, it gives some extra meaning to my markup for one. You know how I love semantics. But after badgering my Dad onto WordPress so I’d have a legitimate reason to use a family XFN tag, we discussed some of the awesome things about it (which had also been mentioned on #microformats). For example, my Dad has a website because he’s interested in finding, and being found by, distant relatives. Imagine a few years down the line when everyone has a blog (don’t they already?) and use XFN tags on the links to their other family members with blogs. You could easily pull up a diagram based on these interconnected links and see who is related to who. An instant family tree!

Alternatively, you could look up people who work together, or instantly pull up a group’s social network based on reciprocated links. Also, it means I can tie other websites that I use to this page, providing they all show the rel=”me” which will ultimately end here. (See Identity consolidation with the XFN rel=”me” value.)

So, I added that, and after spotting that I had accidentally misspelt his surname and telling me that I should blog this, Tantek suggested I also hCard the links. Not a bad idea! So now you can grab my friends names, websites and what they mean to me all in one go.

Apart from my inability to spell some names correctly, XFN is a very simple to add but fully loaded tag for links, so I had no issues with implementing them.

I think it’s something that will be relied upon more and more in the future for a range of uses and services, so it’s really worth adding now and getting a grip on. Mixing XFN with VoteLinks (which I have yet to use anywhere) and no-follow seem like an interesting prospect and perhaps could be useful for better determining page ranking or just aiding web searches. I’m no innovator, but I’m sure someone will come up with a good way to utilise these features together.

The question is, what should I format next? hResume?

Microformats London social

Drew Mclellan (developer of the awesome hKit) and I have discussed a Microformats Social here in the UK for a while but never got anywhere with it, but now we’ve named a date and want to see levels of interest.

We’ve gone for a Saturday – 30th September. So, it’s a little breather after the upcoming events. If you think you can make it, please register your interest either on the wiki page, or the upcoming.org events page. Drop a comment to say if you’d like to do something in particular on one of those pages or on here. This is mostly designed to be a social, but it’ll be an opportunity to discuss any projects you’ve got on the go, get more involved, or clarify any problems you might be having.

We were thinking a trip to a microbrewery would be appropriate – so if you know of one in London which is easily accessible (i.e. near a tube) and wouldn’t mind a hoard of microformateers visiting, let us know about that too.

If you’re at BarCampLondon or d.Construct then you can always talk to us about it there too (or we may draft you into coming along!).

Implementing hAtom: The entries code

This article is rather old now, but has been linked to a few times recently. Just wanted to say that I don’t actually use the example below anymore, as I have since upgraded WordPress and used the sandbox theme as the basis for my own, which comes with it’s own microformat goodness. The example below is still valid though and should be useful to you if you want to understand how it works or still want to do it yourself.

As promised, here is my PHP hAtom WordPress loop. Feel free to do as you like with it.

To start: The first thing with implementing something like this is it’s a really good excuse to do a code review. I had a look at the way I was using my headings and abbrs etc. and moved them about a bit. It becomes clear pretty soon that if you’re not using your HTML tags in a semantic way, it’s harder to think about adding additional levels of meaning (the microformat classes).

When I first added hAtom I didn’t also add it for my comments. This meant I could use hFeed around the entries. You can’t nest hFeed though, and since this loop will sit around the comments loop on a permalink entry, it had to be sacrificed and instead the page is taken as hFeed (which is the fallback) and the hFeed wraps around the comments loop (which I can also post if you’re interested). If you don’t hAtom your comments, put hFeed back in around the main entries, as this is a field that *should* exist if possible.

Entries loop with hAtom:


<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div class="post hentry" id="post-<?php
the_ID(); ?>">

<h2 class="entry-title"><a href="<?php
the_permalink() ?>" rel="bookmark"
title="<?php the_title(); ?>"><?php the_title();
?></a></h2>

<h3>by <span class="author
vcard"><span class="fn"><?php the_author()
?></span></span>

on <abbr class="published" title="<?php
the_time(’Y-m-d’) ?>"><?php the_time(’F jS Y’)
?></abbr> </h3>

<?php the_bunny_tags(); ?>

<div class="entry-content">

<?php the_content(’Read the rest of this entry »’); ?>

</div>

</div> <!– end hentry –>

<p class="righted">Posted in <?php the_category(’, ‘) ?>
<strong>|</strong>

<?php teb_word_count(); ?> | <?php
edit_post_link(’Edit’,'’,'<strong>|</strong>’); ?>
<?php comments_popup_link(’No Comments »’, ‘1 Comment »’,
‘%Comments »’); ?></p>

<?php comments_template(); ?>

<?php endwhile; ?>

<p><?php next_posts_link(’« Previous Entries’) ?>
<?php previous_posts_link(’Next Entries »’) ?></p>

<?php else : ?>

<h2>Not Found</h2>

<p>Sorry, but you are looking for something that isn’t here.</p>

<?php endif; ?>

I’ve added some linebreaks and such to make it a bit more practical for a fixed width blog, so don’t take too much heed of the actual layout.

The bold parts are the hAtom sections (although the bunny tags also produce the “rel=tag”). The parts in italics are plugin calls. Note also how you incorporate hCard as the author. The publish date uses the datetime design pattern on the abbreviation. I chose not to include a timestamp as I don’t publish more than once a day (as a rule, anyway).

Do not fret those of you who aren’t into working up your own code, or perhaps are using wordpress.com – The Sandbox theme (available to .com users also) now has hAtom!

As you can see, it’s pretty simple. It’s just a case of going through and basically labeling the correct parts with the correct classes (making sure you have instances of all the *must have* classes). If you follow the link above to the hAtom wiki page on the microformat site, you’ll find some tools for testing your implementation.

Hypnagogia

Sleep is another of my armchair interests. I saw an interesting documentary last night about night terrors, and with Rich discussing dreams on his blog, it reminded me about my own odd sleep condition; sleep paralysis.

I did some research on it a couple years ago but never turned up that much information (imagine that, a time when the internet didn’t know everything). I had a look about today, and there is a lot more about it available. I suffer, a term I use loosely, from sleep paralysis, or more precisely Hypnagogia with sleep paralysis, and have done for about 5 years now and with a frequency of about once every week to a fortnight. Apparently it’s common (around 25% of people experience sleep paralysis either in this form, or the more common hypnopompic state which instead occurs when waking). It’s almost the opposite of sleep walking, in that rather than the brain switching off and the body carrying on it’s activities, sleep paralysis feels like the body has switched off and the brain is still awake.

It’s pretty weird at first, because if you don’t realise you’re asleep (like I didn’t the first few times) you’re convinced you’re paralysed and therefore not doing too well. Because I’m aware of the experience, I’m able to lucid dream once I’ve grabbed back a bit of control and moved past the anxiety. I’ve experienced a lot of the recorded strange sensations though, from thinking I’ve got up and done things as normal, being convinced I’m going to die (”the fear”, which is unavoidable but fightable), feeling like I’m moving (sliding, spinning or falling) and imagining people (including “the intruder”). Napping in the afternoon sun on my back, which I don’t get to do much anymore, is the most reliable trigger for it, for me.

Sleep is a funny thing.

hAtom implementation

It’s late, and I have had a long journey today down to Cornwall to visit my family for the week (so if you email me this week please use my gmail not my work address), but I thought I’d stop by and mention that a couple nights ago I finally got around to implementing hAtom on this blog.

Implementation was a doddle. Checking it was accurate was not so much. The available Firefox extensions that check for hAtom are not all that… working. If you show certain elements in a slightly different order it seems microformat-find, for example, can totally miss it. This is fair enough though for a couple reasons. A. hAtom is very, very new. Version 0.1 still. and B. Writing parsers isn’t exactly straight forward, and I have every sympathy for that. Consequently, I spent a long time wondering why it “wasn’t working”, when infact it was fine… I just didn’t have access to tools to show me that (but the boys helped me out – cheers Chris, Drew and Luke for checking my stuff over).

Also, I found that some of the documentation for hAtom seemed a little odd. I will probably bring this up with the group later, but I’ll throw it on here first. The main thing I found odd is that “updated” is a required field, and if not found you should use “published“. This seems odd to me since surely you can’t update something unless it was published in the first place? Perhaps I am misunderstanding the usage of the term updated (Drew suggests it’s a mapping to the Atom spec)? Anyway, looks like that part of the spec could use a little ironing, and I think that’ll be happening. I’ll keep you posted on that one.

Anyway, I was going to post my final wordpress loop code snippet, but I’m not sure how useful that is for everyone. If you want to see it, and where I’ve added the extra information, say so, and I’ll run through it on here. Having lots of implementations means that people can get writing extractors and having some varied testing beds to try them out on will help, so I encourage people to take a look at it.