, 2 min read

HashOver Comment System with Hiawatha

When you have a blog you might want to engage with your readers by allowing them to comment on your posts. WordPress allows this out of the box. But when using a static site generator then having a commenting system is a bit more difficult. Many have resorted to Disqus. But Disqus has a number of drawbacks:

  1. It requires quite some bandwidth as its JavaScript libraries are large.
  2. Your data is now under control of a separate company.

There are a number of Disqus alternatives, see Top 7: Best Open Source Self-Hosted Comment System Alternatives to Disqus. The system HashOver is one of them. It is written in PHP and JavaScript.

Installing HashOver in Hiawatha unfortunately is not without its problems. Out of the box it does not work with Hiawatha. Once I knew it worked with

php -S 0:8000 -t /srv/http

then I concluded it has something to do with the handling of index.php.

HashOver should start as below:

Once logged in, settings-dialog looks like this:

Comments on your website look like this:

Back to the index.php problem: From PHP: Built-in web server:

If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. If neither file exists, the lookup for index.php and index.html will be continued in the parent directory and so on until one is found or the document root has been reached.

There are two possibilities to solve it in Hiawatha:

  1. Using StartFile=index.php
  2. Using a special UrlToolkit rule
UrlToolkit {
    ToolkitID = HashOver
    RequestURI isfile Return
    Match ^/hashover/(.+)/+$ Rewrite /hashover/$1/index.php

I also needed to change 3 files and add index.php before the question mark (?):

62:        redirect ('./index.php?status=success');
67:  redirect ('./index.php?status=failure');

733:        redirect ('./index.php?status=success');
738:  redirect ('./index.php?status=failure');

50:        redirect ('./index.php?status=success');
55:  redirect ('./index.php?status=failure');

The first option is not possible for my blog, as I need StartFile=index.html so that end-users can drop the index.html on their URL. Therefore I must use the 2nd option.

Ideally Hiawatha should allow a list of filenames for StartFile, e.g.,

StartFile = index.html, index.php

Unfortunately, Hiawatha does not allow this.

I am still hesitating whether I should include HashOver or not. Looking at the required bandwidth:

One sees that HashOver needs ca. 75kB: first 54kB for comments.php (which generates JavaScript on the fly), and second 20kB for comments-ajax.php. Compare this to the actual content of index.html which is only 1.7kB.