Blog

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.