Roller’s Ugly Permalinks

I'm using Roller 1.2 for this blog at the moment. Roller 2.0 is out, but I'm in the middle of a beta-testing a new product so I'm not going to risk upgrading for a few weeks yet, in case I end up yak shaving.

I'm pretty happy with Roller. It's a great piece of code and it's been really easy to customise. I run it because I was already running tomcat, and it's just easier to keep everything Java focused if you can. (more on that later – there's a big deficiency in the webmail area with Java).

So anyway, the one thing that was really annoying me was the permalinks. The standard form is:

http://www.richardrodger.com/roller/page/richard?entry=foobar

Yuck. Not only does it look ugly, but the entry is only identified in the query parameters and is thus not analysed properly in most web stats packages (including google analytics, which I was lucky enough to get an account on). This makes it hard to tell which entries are getting the most hits etc. Also, the permalink is not search-engine friendly.

So time to put the hacking hat on. After scanning through the Velocity templates in the Roller distribution I was none the wiser. But then I decided to bite the bullet and hack the code. In the end it was pretty easy to change the permalink code. First, links of the form

http://www.richardrodger.com/roller/page/richard/Weblog/foobar

are supported (why are they not standard? dunno.), so this was my target. After a bit of global searching, I discovered the getPermaLink method in org.roller.pojos.WeblogEntryData. Replace the line:

String plink = "/page/" + website.getUser().getUserName() + "?entry=" + lAnchor;

with

String plink = "/page/" + website.getUser().getUserName() + "/Weblog/" + lAnchor;

And now the permalinks are just right. By the way, the easiest way to make this kind of quick change is to download the source and tools distributions, unpack them, and run build.sh all. It all “just works”. Great stuff.

Of course, as you may have noticed, mucking with your feeds is not a good idea. If you change the permalink then all the old entries get replicated, because the aggregators think they are all new. So make this change before you go live.




This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *