P@ Sunglasses

« java-syndication... | Main | Sun opens 82678... »

20050125 e martë janar 25, 2005

Re: Todd Fast: HOWTO: Adding Technorati Cosmos Links to a Roller Blog

Todd Fast explains HOWTO: Adding Technorati Cosmos Links to a Roller Blog. A good entry, but since he is not aware of all the possibilities offered by velocity macros in Roller templates he has to use javascript to encode the url of the post, which makes including these links more complicated than it should be.

Roller macros are extremely well documented at http://www.rollerweblogger.org/velocidocs/index.html, but I could not find any documentation for the $utilities package (or whatever they name it in velocity). The best way to discover what you can do in velocity macros inside of the Roller context is to read the code from roller macro packages (in the documentation the code is included at the end, which is very convenient). The only problem with Roller velocity templates is that you cannot use many of the excellent velocity tools, since they are not installed in Roller. I tried installing one of these on my own Roller server and found out that you can't do it without modifying Roller code because Roller populates the velocity context in some java code in a different way than the standard velocity servlet.

In order to encode a url you can use the $utilities.encode function in your template. $utilities has a set of useful functions that are used by the Roller templates tehmselves. If you are curious for more, get the Roller code and find all .vm files: they are worth a read if you plan to do more than boilerplates templates. roller.vm is a good read.

So I would replace Todd's instructions by this code:

#set ($permalink = "$absBaseURL$entry.permaLink")
#set ($encodedpermalink = $utilities.encode($permalink))
<a href='http://www.technorati.com/cosmos/search.html?rank=&url=${encodedpermalink}'>
<img align='top' style='border:0px' alt='Technorati cosmos' src='${absBaseURL}/resources/${userName}/cosmos.gif'/></a>

For those interested in James Todd's MyJxta experimentations, I also have similar code in my template, coupled with a servlet on my server to autogenerate a jnlp file for MyJxta starting a chat room for each item in your blog.

#set ($jxtadescription = $utilities.encode("Chat room for ${entry.title}"))
#set ($jnlplink = "http://blogs.chanezon.com/roller.jnlp?name=${userName}&id=${encodedpermalink}&description=${jxtadescription}")
<a href="$jnlplink">Chat about this entry</a>

Feel free to experiment with it, but I will describe this further when it will work as advertised.

( Jan 25 2005, 06:44:20 PD PST ) Permalink Chat about it Technorati cosmos Tagsurf It

Comments:

Post a Comment:

Comments are closed for this entry.

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.