Hobix And HaloScan

Regular readers of this blog (yes, all three of you) will probably want to tune out this post, as it is entirely geek-oriented. Dieter Zinke asked recently how I got Hobix to use HaloScan for comments. Thanks for asking, Dieter—the answer is that it’s actually quite straightforward, assuming that you’ve become comfortable adding stuff to your blog’s hobix.yaml configuration file.

I should say that I decided to go with HaloScan because while Hobix does have a built-in comments feature, it requires some server-side Ruby CGI or Apache+Ruby setup that it wasn’t worth trying to get my host to do. It was also not entirely bug-free at the time I started using Hobix. HaloScan is a JavaScript-oriented comments engine that (I assume) was created just for blogs that don’t have their own comments built in. HS hosts the comments in their database, which you can access via the web, and their servers do the heavy lifting. It’s a pretty cool solution.

So here’s the deal:

  • As most people seem to do, I use “quick” templates for my blog; I’ve never tried any of the other setups, although I imagine the steps would be similar for them as well. Accordingly, the additions listed here will be made in the hobix/out/quick section of requires in hobix.yaml.
  • When you sign up with HaloScan, you will establish a unique user name. HS uses this name to create a script on their server that needs to be included in any page of your site where you want comments to be enabled. The URL to the script will be something like http://www.haloscan.com/load/yourUserName.
  • Your hobix.yaml may or may not already include a head_tags element in the hobix/out/quick section. If it doesn’t, add it, remembering to pay attention to indentation and follow it with a colon. You then add an HTML script tag under the head_tags section that references your HS script. This will look something like:
     head_tags: >-
      <script type="text/javascript" src="http://www.haloscan.com/load/yourUserName">
      </script>
  • Hobix will then add this tag to the HEAD section of each document created using “quick” templating. In my case, this means that it is loaded by every page of my blog; the overhead involved in fetching the script is generally quite small.
  • To insert a link that will allow visitors to post comments, add the following to the entry_footer element in the hobix/out/quick section:
     entry_footer: "<% comment_name = entry.id.gsub(\"/\", \"-\") %>
      <a href=\"javascript:HaloScan('<%= comment_name %>');\" target=\"_self\">
      <script type=\"text/javascript\">postCount('<%= comment_name %>');
      </script></a>" 
  • This code calls two functions in the HaloScan script, “HaloScan”, which is what allows a comment to be created, and “PostCount”, which returns the number of comments entered for a particular post. Both functions require a unique identifier for the post as an argument. I am simply using the name of the Hobix entry, with ”-” substituted for ”/”—this is what the “comment_name” variable is (so for this post, its value is daily-HobixAndHaloScan). Now that I am looking at this code again, I realize that “comment_name” really isn’t the best name for it. It also may not be necessary to do the substitution at all.
  • That’s pretty much it. Let me know whether or not this works for you.

What floats this goat? _why, Hobix, of course!