Creating Microsummaries (How to & Evo)

May 16th, 2006

I’ve been playing around more with microsummaries in Firefox 2.0 Alpha and I’m totally addicted. This’ll probably turn out to be my favourite feature in Firefox and it’ll be even better when there is a central location where microformats could be uploaded (a bit like Userscripts.org). If Firefox integrated this into it’s interface, it’d be amazing.

Microsummaries are really, really easy to create. I’ve created two microsummaries - one for my blog and an example microformat for Evolution. To create a microformat, all you need to do is to write one line of XSLT. W3Schools has a one page syntax guide which is more or less all the documentation you need for creating a microformat.

This is the microformat for my blog: 

<?xml version="1.0" encoding="UTF-8"?><generator xmlns="http://www.mozilla.org/microsummaries/0.1" name="Latest Blog Entry">  <template>    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">      <xsl:output method="text"/>      <xsl:template match="/">        <xsl:text>Cow: </xsl:text>        <xsl:value-of select="//h3[@class='headline blogentrytitle'][1]/a[1]"/>      </xsl:template>
    </xsl:transform>  </template></generator>

It might look complex at a first glance, but it’s really just a XPath expression wrapped in other XSLT. The magic line is this:

//h3[@class='headline blogentrytitle'][1]/a[1]
  • // selects every single node in the document.
  • h3 selects every level 3 heading in the document (I use these for blog titles)
  • [@class='headline blogentrytitle'] filters the nodes again so I’m left only with the ones with a class attribute of "headline blogentrytitle". All my blog entry titles have this.
  • [1] selects the first blog entry title.
  • /a[1] will then select the first hyperlink in that heading. This is required as I nest a hyperlink in my headings.   

Try it out! If your using Firefox 2.0 Alpha 2, bookmark the homepage of my blog. Select the summary in the dropdown.

Evolution Microsummary

Just for fun, I also tried to create a microsummary for Evolution. It was even easier to create than the microsummary for my blog. This time I decided to create it as an installable microsummary. This is the way to create "unauthorized" microsummaries. 

The Evolution microsummary looks like this: 

<?xml version="1.0" encoding="UTF-8"?><generator xmlns="http://www.mozilla.org/microsummaries/0.1" name="Evolution 5 Ranking">  <pages>    <include>http://ev5\.neondragon\.net/</include>  </pages>  <template>    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">      <xsl:output method="text"/>      <xsl:template match="/">
        <xsl:text>Evolution 5 (Rank: </xsl:text>        <xsl:value-of select="//meta[@name='Evolution-Rank']/@content"/>        <xsl:text>)</xsl:text>      </xsl:template>    </xsl:transform>  </template></generator>

The first major difference is the inclusion of the <pages> section. This tells the browser which pages the microsummary is intended for. This is only required because the microsummary is not embedded in the actual page.

This is the actual code which generates the microsummary:

        <xsl:text>Evolution 5 (Rank: </xsl:text>        <xsl:value-of select="//meta[@name='Evolution-Rank']/@content"/>        <xsl:text>)</xsl:text>

The microsummary comes in three parts - a static string, dynamic content, and a second static string. The <xsl:text> elements give the static bits. <xsl:value-of> is used to get the value of the dynamic sections of the microsummary text.

The syntax is similar to before. However this time I needed to grab the value of the content attribute so I used /@content at the end. 

 

Related Posts

  1. Microsummaries
  2. XPath Checker (Microsummaries)
  3. Microsummaries
  4. Evolution 5 Toolbar
  5. First Collaborative Blog

Trackback URI | Comments RSS

Leave a Reply