Making Microformats More Visible - Announcing The XFN Highlighter Script

UPDATE: The script now uses regular expressions. This fixes the problem where it translated met to me.

You’ve heard BillG say that we need Microformats. Do you catch yourself asking But Why?

Good question. Right now the Microformats movement is dealing with a bit of a chicken-egg problem due to a lack of tool support. Without tools to make microformat creation simple for content publishers and to make microformats more usable and visible to content consumers, it is difficult to see the point of the effort. The effort / reward scale is currently tipped heavily towards the effort side.

That may soon change as Microformats start taking over the web. In preparation for an article I am writing on the topic, I have been doing some thinking and reading up on Microformats. I won’t spoil the article by discussing Microformats in much detail here, but instead will highlight one microformat and my effort to make it more visible.

Do not reinvent the wheel!

Remember, Microformats are not about trying to reinvent the wheel. In fact, it is a key principle of the Microformat philosophy to build on what already exists. For example, even before microformats there was an initiative called XFN (or XHTML Friends Network). The idea is to add semantic information to web links in the form of the rel attribute to signify relationships.

This existing format has been adopted as a microformat. When linking to a friend’s blog or website, for example, you might add the following rel attribute.

<a href="http://haacked.com/" rel="friend met">...

This incidentally creates a network that is indexed by XFN crawler. But how does the average visitor to your site even notice this? Unless they view source, they won’t. This sort of goes against the Microformat principle of focusing on humans first and machines second. Better tools are needed to highlight interesting microformats to end users.

So let’s expose our friends

Well that is where my XFN Highlighter script comes in to help in a very small way. This is yet another Markup Based Javascript Effect Libraries in the style of my table mouse over script, and Lightbox JS. As more web publishers start adding microformatted content to their sites, I think we’ll see a proliferation of these type of scripts targetting this content.

Note that this script is a bit rough around the edges (for example, I need to replace indexOf with regular expressions). I slapped it together quickly one evening and there are many improvements that could be made. But the current version works well enough and I figure it is time to share it so I can generate some feedback (hopefully!).

What the script does is look through your html for links using the XFN microformat. It then places a little icon next to links that express a relationship as well as a special tooltip that lists the relationships info. But rather than talking about it, I should give a demo. Again, I will have to ask you to try this out in a browser since most aggregators will not display my javascript and CSS. Here are a list of a few people I know. Go ahead and move your mouse over them. Go on now.

A few friends and acquaintances

How to Use

Setup

1. Add the following Javascript declaration to the header.

<script type="text/javascript" 
    src="scripts/XFNHighlighter.js"></script>

2. Include the XFNHighlighter CSS file (or cut and paste these styles into your own stylesheet).

<link rel="stylesheet" href="css/XFNHighlighter.css" 
    type="text/css" media="screen" />

3. The CSS references an image friends.png in the images directory. Make sure that image exists or change the CSS to point to an appropriate image. This image is placed next to the link.

Activate

1. Add an appropriate rel="value" when linking to a friend or acquaintance. Check out the list of relationships from the XFN quickstart page.

Download

Grab the files (neatly organized) from here.

What others have said

Requesting Gravatar... Scott Hanselman Apr 05, 2006 11:17 AM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
Acquaintance? I thought we had something man....

<dick>Phil</dick>

;)
Requesting Gravatar... Haacked Apr 05, 2006 11:28 AM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
We do, but I didn't want to make Atwood jealous (did you see his relationship set?). Plus, I needed to demo other relationships.

I updated it to show some more love.
Requesting Gravatar... Jon Galloway Apr 05, 2006 11:31 AM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
Yeah, I was wondering about that crush thing. Couldn't decide if that meant you had a crush on the Wumpus, or you're threatening to crush him.
Requesting Gravatar... Ryan Rinaldi Apr 05, 2006 12:26 PM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
Seems to be rendering funky in IE 6? The div with the relationship info is appearing under the links making it almost impossible to read.
Requesting Gravatar... Jeff Atwood Apr 05, 2006 12:42 PM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
I viewed your source and now I need to take a shower!
Requesting Gravatar... Haacked Apr 05, 2006 1:55 PM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
Ryan: Thanks for the report. As I said, there's room for improvement and that's an obvious one.

Jeff: Well it's about time.
Requesting Gravatar... Haacked Apr 05, 2006 3:02 PM
# re: Making Microformats More Visible - Announcing The XFN Highlighter Script
Ryan, try it now. I fixed the problem.
Requesting Gravatar... Community Blogs Sep 15, 2006 3:01 AM
# Proposed Extensions To The XFN Microformat
If you’ve read my blog you know I have a bit of a thing for Microformats. I once wrote a little special
Requesting Gravatar... you've been HAACKED Feb 08, 2007 10:22 PM
# XFN Link Tool For Windows Live Writer
XFN Link Tool For Windows Live Writer
Requesting Gravatar... Community Blogs Feb 09, 2007 5:58 AM
# XFN Link Tool For Windows Live Writer
UPDATE: How could I have overlooked the Plugin Keyvan Nayyeri wrote two months ago. Sorry buddy! You

What do you have to say?

(will show your gravatar)
Please add 7 and 7 and type the answer here: