Why I chose Disqus Comments

I recently moved my blog comments away the PyBlosxom comments plugin to a hosted system. The main driver was the ability for people to subscribe to comments for an article using email or RSS. It's a pain for people to have to check back to the site to see if someone has replied to their comments. I was also keen on user-experience-enhancing features such as integration with external systems like OpenID, Twitter and Yahoo.

My criteria were:

There are a number of hosted comment systems out there. The most popular options seem to be Disqus, JS-Kit Echo and IntenseDebate.

IntenseDebate was eliminated first because it doesn't seem to provide an import mechanism for custom websites. Import only seems to be supported for well known blog platforms such as Wordpress. There's no comment API either. The approach seems to be to leave your old comment system in place and just have new comments go into IntenseDebate. Not good enough, I wanted to completely replace the existing comments system.

After some deliberation I decided on JS-Kit Echo for one tiny reason: it supports the <pre> tag. The closest Disqus supported was the <code> tag which doesn't preserve white-space (useless for Python code samples).

So I paid my US$12 (it's the only service that doesn't have a free option) and started looking at how to import my existing comments using their API ... and quickly found that it sucks. Comments can be submitted but you can't specify a timestamp so they are dated with the import date. Far from ideal. Then there's the API for retrieving comments: it returns the data as JavaScript code (no not JSON)! It's pretty clear that the API is what they use with the JavaScript for Echo itself and geared for that use only. They've just thrown it out there and documented it, warts and all.

Back to the drawing board.

The only showstopper for Disqus was the lack of <pre>. Everything else about it was great: it met all my requirements and the API was clean and comprehensive. If only there was a way to have properly formatted source code in the comments.

Light bulb moment: use a CSS hack to make <code> in comments behave like <pre>. The trick is to turn code into a block element and change how white-space is handled. The CSS snippet looks like:

.dsq-comment-message code {
  display:block;
  white-space:pre;
}

Works great.

With the only blocker gone, I wrote a Python script with the help of Ian Lewis' excellent disqus-python-client package to pull in the existing comments from the old system. Within an hour or so it was ready to go.

Hopefully this article saves someone else some time if they decide to use one of these systems. Getting things running chewed up a lot more time then I had expected.

posted: Thu, 05 Nov 2009 19:49 | permalink | comments

Internet Explorer Ampersand Bug with prompt()

I just discovered an inconsistency in how Internet Explorer (6 and 7) handles ampersands with the prompt() built-in function.

Try the following in Firefox and then again in IE6 or IE7.

<html>
  <script>
    alert('-&-');
    alert('-\&-');
    alert('-&&-');
    prompt('-&-');
    prompt('-\&-');
    prompt('-&&-');
 </script>
</html>

FF and IE behave identically for alert() but for prompt() both IE6 and IE7 fail to show an ampersand unless "&&" is supplied. Very strange.

In case you're wondering, &amp; doesn't help either; it isn't translated for popups in any of the browsers.

Is this a known problem? I haven't been able to track down other reports of the issue.

Short of doing browser specific hacks, or just not using prompt(), I can't see a way of getting consistent behaviour across browsers. How craptastic. The joys of web development...

posted: Fri, 16 Nov 2007 16:09 | permalink | comments