HOWTO: Adding Technorati Cosmos Links to a Roller Blog

As I mention in the article below, my technique was primarily a hack to get around what I assumed was either a missing macro or missing documentation. Patrick Chanezon is more familiar with Velocity and has explained the proper way to escape links in Roller. Cheers, P@.

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:

http://www.technorati.com/cosmos/search.html?rank=&url=[blog permalink]

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:

$entry.permaLink

However, if we want to avoid hard-coding the domain and Roller context path, you can prepend the following variable:

$absBaseURL$entry.permaLink

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):

<a href='http://www.technorati.com/cosmos/search.html?rank=&amp;
url=$absBaseURL$entry.permaLink'>...</a>

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.

My admittedly hack-esque solution was to use a little bit of JavaScript to escape the fragment identifier when the link is clicked. While this technique won't work if the user has turned off JavaScript, that condition is fairly uncommon these days; until someone addresses the missing macro in Roller, this technique should suffice for the majority of readers.

First, add the following JavaScript to your master Weblog page template's <head> tag:

<script language="JavaScript" type="text/JavaScript">
function replaceCharacters(conversionString, inChar, outChar)
{
    var convertedString = conversionString.split(inChar);
    convertedString = convertedString.join(outChar);
    return convertedString;
}

function escapeHref(object, inChar, outChar)
{
    object.href=replaceCharacters(object.href,inChar,outChar);
}
</script>

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=&amp;
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.

[Find more about at Technorati]
[Find more about at Technorati]
[Find more about at Technorati]

Comments:

[Trackback] Here are some instructions to leverage the benefits of Technorati from your Blog: Go to www.technorati.com and become a member. Update your profile with the correct information and a picture (optional) Once you become a member, claim ...

Posted by Whatever... [Deepak Alur's Blog] on June 02, 2005 at 10:35 AM PDT #

http://www.agnieszka-dupa.sex-69.pl @ http://www.agnieszka-dupeczka.sex-69.pl @ http://www.agnieszka-dupsko.sex-69.pl @ http://www.agnieszka-duze.sex-69.pl @ http://www.agnieszka-dziwka.sex-69.pl @ http://www.agnieszka-dziwki.sex-69.pl @ http://www.agnieszka-erotyka.sex-69.pl @ http://www.agnieszka-flash.sex-69.pl @ http://www.agnieszka-foki.sex-69.pl @ http://www.agnieszka-fotki.sex-69.pl @ http://www.agnieszka-fotomodelki.sex-69.pl @ http://www.agnieszka-free.sex-69.pl @ http://www.agnieszka-galerie.sex-69.pl @ http://www.agnieszka-gay.sex-69.pl @ http://www.agnieszka-gole.sex-69.pl @ http://www.agnieszka-gorace.sex-69.pl @ http://www.agnieszka-gry.sex-69.pl @ http://www.agnieszka-jebac.sex-69.pl @ http://www.agnieszka-kamery.sex-69.pl @ http://www.agnieszka-kotki.sex-69.pl @ http://www.agnieszka-krakow.sex-69.pl @ http://www.agnieszka-kurwa.sex-69.pl @ http://www.agnieszka-ladne.sex-69.pl @ http://www.agnieszka-laski.sex-69.pl @ http://www.agnieszka-lechtaczka.sex-69.pl @ http://www.agnieszka-licealistki.sex-69.pl @ http://www.agnieszka-lizanko.sex-69.pl @ http://www.agnieszka-lolitki.sex-69.pl @ http://www.agnieszka-lubiewo.sex-69.pl @ http://www.agnieszka-male.sex-69.pl

Posted by aa on June 05, 2005 at 09:33 PM PDT #

nice blog..keep it up!

Posted by david on July 03, 2005 at 12:27 AM PDT #

hello

Posted by sexo on October 06, 2005 at 11:57 PM PDT #

[Trackback] Cheap generic acomplia without prescription

Posted by fda approval of acomplia on November 02, 2007 at 09:35 AM PDT #

i need the woman

Posted by guest on April 19, 2008 at 11:29 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

toddfast

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today