
The Cloud have finally worked out what the hell is going on. ![]()
David Galbraith told a preacher on the train to shut up. Good on ya! ![]()
Last night I discussed with Kosso my frustration at the way that comments get rendered up in the RSS of the OPML Editor blogs.
Today I farted around for hours trying to fix it. Here are the results. Now when you are subscribed to my feed, you will see a link in the RSS to the comments and trackbacks over on HaloScan but these don't tell you how many comments or TBs have been posted, but are accurate links.
How is this? Well, it's magic really.
And like all magic, it's a simple trick.
I've added four lines to dotOpmlSuite.blog.buildRss. These remove the JavaScript from the RSS version of the feed, but not from the OPML version. The JavaScript is used simply to find out how many comments and TBs there are for that particular entry.
I had considered another solution which would be rendering the number of comments in a GIF file rather than in JavaScript, but this solution is much easier.
Want to see how I did it? Open up OPML, choose File > Open URL... and copy this link in to it.
If you simply wish to install this code, hit Control + J or Cmd + J, type in dotOpmlSuite.blog.buildRSS, then delete what's there and replace it with what's in my outline.
For the geeky among you, this is the code which actually does the magic:
| local (patternTB = "<script type="text/javascript">postCountTB([^<]*)</script>") |
| regex.subst (patternTB, "Trackback", @s) |
| local (patternComm = "<script type="text/javascript">postCount([^<]*)</script>") |
| regex.subst (patternComm, "Comments", @s) |
What is this code doing?
The first two replace the Trackback javascript with a simple link, and the second two do the same for the comments. Why in this order? Because if you switch lines 1 and 2 with lines 3 and 4, you're screwed - and you get some very funny looking links. Try if you like - you won't like it!
The code should work for most Haloscan OPML implementations - Kosso's, Tibor's and mine, since it's not doing anything clever with the outline, only with the RSS.
Enjoy!