Steve Kemp's Blog Writings relating to Debian & Free Software

External Comments, updated

Thu, 6 Feb 2014 12:32:38 GMT

The simple external-comments code is now complete enough for me to stop poking it on a daily basis:

  • Although the comments are styled minimally you can override that with CSS.
  • Although the default "Add your reply" form is ugly you can replace it with your own.
    • The reply-form may go above or below the comments.
  • If you add an email field then your comments will include a gravitar link.
  • Comments are assumed to be in markdown now.
  • The commments may be retrieved in newest-first, or oldest-first order.
  • There's now a simple anti-spam plugin system present.

All in all I'm pretty happy with the way it works, and the server-code. The client-side Javascript is less good, but I'm probably done poking that too.

In an ideal world the client-side code should be a jQuery plugin, but I've not worked out how to make a static method (the JSONP callback) be a member of a jQuery plugin-object. So without that I have to re-pass the options around too many places, rather than making them a member of "this".

Meh, pull requests welcome for adding new storage back-ends (redis and sqlite are supported by default), and similarly for cleanups.




Comments On This Entry

[gravitar] Steve Kemp

Submitted at 14:22:56 on 2 February 2014

FWIW I've updated the comments to be 100% dynamic.

The pages with comments:

  • Load jQuery.
  • Load a single index.js file.
  • Have <div id="comments"></div>

Everything else is dynamic.

[gravitar] Erik Johansson

Submitted at 15:21:49 on 2 February 2014

If you do it like this I guess you could just include a "static html" of the comments as well, you know for javascript fallback.. But I guess iframes are as evil as javascript.

[gravitar] Steve Kemp

Submitted at 15:26:05 on 2 February 2014

I genuinely hadn't considered the use of static HTML rendering, but now you mention it I agree that iframes are pretty unpleasant.

(On the basis I know these are external and javascript is required. Everything degrades perfectly with javascript disabled.)

I suspect the next thing to do is offer decent styling of the comments, and get somebody more javascript-friendly to tweak my code since it is naive rather than pretty.

Still it almost feels like I should make it a distinct mini-project, and create a repository for comment-handling, with the server and client both inside it.. I'm just not sure how generally useful it would be; people can use disqus if they don't care about the drawbacks, and if they do it was so quick to knock up I suspect nobody would use mine.

[gravitar] Steve Kemp

Submitted at 16:43:39 on 2 February 2014

I've tidied up the code and presented a standalone version:

[gravitar] Florian

Submitted at 17:58:51 on 2 February 2014

Whoo, awesome.

I started something like this and never finished it, will definitely give it a try :)

[gravitar] Serge van Ginderachter

Submitted at 18:14:13 on 2 February 2014

Hi Steve,

Love your posts. Thanks for all your sharing.
I'd love to hear more on why you distrust Disqus.



[gravitar] Steve Kemp

Submitted at 18:55:54 on 2 February 2014

Florian, awesome. I've rushed out an update that uses either Redis or SQLite as the storage-backend. Since I figure that is something people will care about.

As for distrust of disqus, people I respect avoid it because of privacy concerns - as mentioned in the wikipedia article I linked to.

On that basis alone I'd rule it out, but that aside I'm loathe to rely on too many external services because they have a habit of failing, or becoming paid things.

[gravitar] Mourad De Clerck

Submitted at 01:13:52 on 3 February 2014

you've probably seen this before, but just in case:

[gravitar] Steve Kemp

Submitted at 09:44:03 on 3 February 2014

Mourad I came across a few different projects later:<?p>



Comments are closed on posts which are more than ten days old.

Spiral Logo


Recent Posts

Recent Tags


RSS Feed

  • Subscribe to feed