HOWTO: Adding Technorati Cosmos Links to a Roller Blog
By toddfast on Jan 24, 2005
After seeing the convenient Technorati Cosmos links on Tim Bray's blog, I wanted to add them to my Roller-based blog. Unfortunately, it was a bit of trouble, so I'm blogging my findings here for my fellow Roller bloggers.
The Technorati Cosmos URL takes the following form:
To use this URL, we merely need to supply the [blog permalink] in the template above and put the result in an anchor tag. In Roller, you can get the relative permalink (relative to the base domain and roller context path) with the following variable:
However, if we want to avoid hard-coding the domain and Roller context path, you can prepend the following variable:
Now, putting this together in an anchor tag and remembering to escape the embedded URL, we have the following (note, this should all be one line when used in HTML):
This almost works, but there is one subtlety with Roller's permalink syntax that caused a bit of trouble for me.
Specifically, Roller includes a document fragment in its permalink URL, and document fragments must be preceded by a hash mark (#). When tacked onto the end of the search URL above, the browser interprets the hash mark and fragment as belonging to the actual link instead of being part of the value of the
url query parameter. Thus, when sending the search request to Technorati, the browser omits the fragment identifier and the search ends up returning the wrong result set. In order for the full permalink including the fragment identifier to be sent as part of the request, the hash mark preceeding the fragment identifier must be escaped so that it will be interpreted as part of the value of the
url query parameter. Unfortunately, Roller doesn't include any macros (that I could find) to escape the hash mark.
Now, modify your _day template and add the following anchor so that it appears once per entry:
<a href='http://www.technorati.com/cosmos/search.html?rank=& url=$absBaseURL$entry.permaLink' onclick='escapeHref(this,"#","%23")'> ... </a>
Remember that although I've split lines above, you should put all of this on a single line in your template.
That's all there is to it. When the link is clicked, all hash mark occurrences in the
href attribute will be replaced by the escaped form, "%23", before the URL is sent to Technorati.