About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

XFN Microformat - with Icon Goodness

Tonight while working on some blog posts about CodeMash I decided to make use of a new Windows Live Writer plug-in, Insert XFN Link.

In my post about becoming a more productive programmer I tagged a link to Jon Galloway's site with the XFN markup. I quickly realized that I didn't like the icon that Subtext's XFN Highlighter uses. So naturally I set to the web to find some alternatives.

I came across some great icons for the XFN Microformat, and I just had to have them. Since they are licensed under the Creative Commons ShareAlike 1.0 license I pulled them down and added them to my Subtext install. One of the first thing I noticed about the icon set is that it has icons for some of the combination of valid XFN rel values.

For example, if you mark someone as a friend you see one icon [  ], but my marking them as both a friend and met you see a slightly different one [  ].

I thought "OK, so that's pretty cool, but how can I really make use of this on my real blog?" In Subtext we implemented the XFN Highlighter using some clever CSS and JavaScript, and the key is the CSS.

The XFN markup works by allowing you to specify multiple relationships (like friend and met) in the rel attribute of a hyperlink element. The hyperlink to Jon's site looks like this:

<a class="xfnRelationship newWindowStyle" 
  rel="external friend met co-worker" 
  href="http://weblogs.asp.net/jgalloway/" 
  title="Jon Galloway (new window)">Jon Galloway</a>

The original XFN Highlighter CSS Selector simply looked for the xfnRelationship class to figure out how to style the hyperlink. Simple enough. But I need to be able to have a CSS Selector that looks at an element's attributes, and the values of said attribute.

CSS 2.1 Attribute Selectors to the rescue! As long as your browser supports the CSS 2.1 standard you can make use of these powerful selectors when building your style sheets. That is to say - this doesn't work in IE 6.0, so I had build my new selectors so they would fail gracefully and revert to the original behavior of just looking at the hyperlink's class.

I'm not going to take a deep dive into exactly how I used the Attribute Selectors to add the new icons, you can take a look at my style sheet for that. Instead, I wanted to show you some examples* of Subtext's XFN Highlighter (with the new icons) in action.

You'll notice that I used the same icons for both co-worker and colleague. I did this because the icon set that I mentioned only had an icon for colleagues, but I feel that it also works as an icon for the co-worker relationship. The same could probably also be said for crush and sweetheart.

The icon next to Dave's link is my new default XFN icon... replacing the original one that I don't like. You're seeing that icon because the relationships for Dave don't match any of the ones defined in my style sheet. So naturally he is being assigned the default icon.

Also, if you look at the underlying markup for the link to Phil you'll see that I marked him as a friend, met, and co-worker. But the icon shown is for a friend-met, not co-worker-met. The order or importance is determined by the order in which you place the CSS selectors in the style sheet. I have the friend relationships below the co-worker/colleague relationships in the actual style sheet file. So by simply reordering the selectors you can set a weight to the relationships.

I hope that Bartelme will release some new icons for the other relationships - at which point I will update the XFN Highlighter to include the new icons.

I also plan to push out an new version of Subtext (soon) that will include these new icons as well as several bug fixes.

* = example links have been modified to showcase all of the available icons.

Technorati tags: , , ,

What others are saying.

# re: XFN Microformat - with Icon Goodness
Gravatar Keyvan Nayyeri
Jan 20, 2007
Nice done Steve :-)

For a long time I was using SubText icon but I'll deploy it to my site very soon ;-)
# re: XFN Microformat - with Icon Goodness
Gravatar Keyvan Nayyeri
Jan 21, 2007
Just deployed. Really nice :-)

+ We have to create new icons for some common relationships.
# re: XFN Microformat - with Icon Goodness
Gravatar Steve Harman
Jan 21, 2007
I just took a look at your site, and the new icons look great.

I agree about needing some more icons for the common relationships. Unfortunately I'm not very talented as far as graphics go, so I'm hoping that the guy who did this initial set will update the set with more icons. I found the icons here.
# re: XFN Microformat - with Icon Goodness
Gravatar Keyvan Nayyeri
Jan 21, 2007
I'm not a designer, too. And yes, I hope to see new icons from that guy ;-)
# Mr.
Gravatar Chris Messina
Jan 22, 2007
Great write up Steve -- that's just how I intended them to be used! ;)

Wolfgang did a great job on the icons -- and maybe we can convince him to do an expansion pack...

Thought you might find this post interesting.

Oh, and you might check your spelling -- it's XFN and not XNF after all.. ;)
# re: XFN Microformat - with Icon Goodness
Gravatar Steve Harman
Jan 22, 2007
@Chris: I'd love to see an expansion pack... so how we we persuade Wolfgang? :)

Thanks for pointing out my typo, I think I've fixed them all now.

Also, I took a look at the post you linked to and I think that real solution might be to use some JavaScript to set some XFN specific classes on the hyperlink elements... similar to what we already do in Subtext for the rel attribute. Perhaps I'll mention it to the author of that other post..
# re: XFN Microformat - with Icon Goodness
Gravatar Jon Galloway
Jan 23, 2007
If I help out with the icons, will you upgrade me to an XFN friend? ;-)

The XFN icon development kit has Photoshop and AI files: (http://www.factorycity.net/projects/microformats-icons/files/mf_icon_devkit.zip)

What other icons do you think are most necessary?
# re: XFN Microformat - with Icon Goodness
Gravatar Steve Harman
Jan 23, 2007
@Jon: If you read the little disclaimer at the bottom, it says that the relationships have been tweaked to showcase the various icons available. This is why you are only marked co-worker and met.

However, if you take a look at my previous post you'll see that I marked you friend, co-worker, and met. :)

Of the other relationships, I think that it would be nice to have icons for the family relationships (child, parent, sibling, spouse, kin... and possibly co-resident). Also, a fun one might be crush - so you could distinguish between that and sweetheart.

Some of the other ones might be hard to iconify (but maybe that's just my left brain talking), but I'd love to see anything that you can come up with.
# re: XFN Microformat - with Icon Goodness
Gravatar Dave
Jan 23, 2007
Wow, I'm listed as "muse". I feel privileged, although I'm not sure if that's good or bad ;-)
# re: XFN Microformat - with Icon Goodness
Gravatar Steve Harman
Jan 23, 2007
@Dave: Yeah, I know what a muse is (for those that don't know, read this) and to be honest I found it funny that it was one of the official XFN relationships. And since I was looking for a relationship that I didn't have an icon for - I went with it.

By the way, take it as a good thing that I marked you as a muse... as if I'm aspiring to be more like you or something. Hell, it's hard not to be inspired a guy that founds a project named EViL!
# Eating My Own Dog Food - Subtext v1.9.4.x
Gravatar StevenHarman.net
Jan 28, 2007
Eating My Own Dog Food - Subtext v1.9.4.x
# re: XFN Microformat - with Icon Goodness
Gravatar helo
Feb 02, 2007
Just for testing
# re: XFN Microformat - with Icon Goodness
Gravatar Steve Harman
Feb 02, 2007
What are you testing... exactly?
# Subtext v1.9.4
Gravatar StevenHarman.net
Feb 11, 2007
Subtext v1.9.4
# Day Dreamin' - a New Skin for Subtext
Gravatar StevenHarman.net
Feb 22, 2007
Day Dreamin' - a New Skin for Subtext
Comments have been closed on this topic.