Greasemonkey and microformats (5)

Leaving so soon? I was hoping to interest you on yet another release of my famous series Greasemonkey and Microformats! No, wait! Please, oh please, just a little more…

Well, for the few of you still there, here I am again at it. Today, let’s talk about something I fancy calling microformat lifecycle. It’s easy enough: you and a dozen more geeks gather around a table to despise all committee-designed monstrosities of the world and come up with a shiny new microformat. After 34 meetings. All is well and parsers flourish, but for the newfangled microformat to gain any traction, there must be some content producers slapping it into their, well, whatever is that they might be producing. Or, as Web 2.0 3.0 advocates would rather say, ‘semantically enhancing their creations’.

The key to microformats adoption would be then, to bootstrap an healthy ecosystem of both producers and consumers. Live examples can be found for the best example in established microformats: hCard. A vehicle for contact details, hCard has seen quite an adoption for several reasons:

  • It’s a semantic HTML implementation of an already established standard: RFC 2426.
  • There are readily available consumers for it. The Operator Firefox extension, which makes hCard embedded data available as vCards readable by most contact management applications, among other interesting features.
  • There are several hCard producers, the simplest one being hCard Creator. A wide sampling of the hCard ecosystem can be found in the hCard implementations page.

A main concern of microformat supporters ought to be helping the non-HTML literate masses of the world to add semantic information to their markup. But there’s a catch-22 in there, as ‘non-HTML literate masses’, as per their definition, have at best a hazy understanding of markup, and well intended pages like this hCard authoring guide aren’t to be of much help but for the most dedicated of hobbyists (well, us geeks can do with just a formal hCard description, XMDP-way, can’t we?)

As a matter of example, I’m putting my money where my mouth is and release a Greasemonkey script that adds measurement unit microformat support to Blogger‘s new post (and edit post) pages. It’s creatively called InsertUnit, and after installation (just point your Greasemonkey enabled Firefox browser to the previous link, thank you) will add a button to the Edit Html editor tab just for your measurement unit microformatting pleasure. To illustrate its workflow here are some screenshots. Who doesn’t like screenshots?

  1. First of all, select some text to denote as a measurement unit. You may skip this step and just press the damn button, already.
  2. That’s it: press the uF button. I should have come up with a better glyph, but that one (as ‘microformat’ abbreviation) is way economical, byte-wise (and not an image, if I may add).
  3. Here you can see the microformat description dialog. Any text selected in step 1 will appear into the corresponding text box, saving you some keystrokes and thus helping you avoid those dreaded RSIs.
  4. After filling the rest of the text boxes (you’ll need a scalar value for the measurement, a name for the unit —to Google’s liking— and a name for a suggested target unit —same way) you may click on the Test conversion link to do just that. If an error shows up, adjust your unit names until you get the desired result. There is no documentation on expected unit names, but Google did much work to keep it a matter of common sense.
  5. And here is the result after tapping on the OK button, in all its semantic HTML glory. Nifty, isn’t it?

Before calling it quits for the day, two remarks: you are not forced to specify a target unit name (but you should state at least a value and a unit name; the OK button doesn’t enable itself until after you’ve done so). You might be interested in marking up your units, but not keen on any particular conversion. InsertUnit is a good match with UnitFormat (as described in the third part of this post series), but by no means is a required match. You might come up with a better parser, for instance (hint, hint) one that is able to suggest target units —out of the blue, or reading from some preferences file.

Last one: now you can get this script and its natural fit from userscripts.org, here: UnitFormat (userscripts.org) and here: InsertUnit (userscripts.org).

Publicado por

Iván Rivera

Another instance of Homo sapiens.