Skip to content

disqus on the cheap?

Last night I was up again, really hard to sleep when you have a bad cold.

I decided to do something fun, and allow my tweaking guide to accept comments.

Like many of my sites this is 100% static, and generated by templer, so comments are "hard".

I've seen a few people try to rewrite disqus as a general-purpose solution, and I like that idea, because I don't trust that particular service.

I wasn't so ambitious though, I just hacked up a quick sinatra server:

  • "GET /comments/ID"
    • Retrieves the comments on the specified identifier as a JSON array of comment-hashes.
  • "POST /comments/ID"
    • Append the submitted comment to a redis set.

My jquery/javascript is nasty, but the thing seems to work pretty well. The page loads and comments are populated, and new ones are persisted as expected.

I can see the appeal of putting all this magic in one javascript file. You include that and get both the existing comments and the form to add new ones - my approach is to hardwire the submission/display in my generated site.

Perhaps something for the future.

In conclusion if people wish they can now leave feedback on most of the pages :)

Comments On This Entry

  1. [author] Steve Kemp

    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.

  2. [gravitar] Erik Johansson

    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.

  3. [author] Steve Kemp

    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.


  4. [author] Steve Kemp

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

  5. [gravitar] Florian

    Whoo, awesome.

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

  6. [gravitar] Serge van Ginderachter

    Hi Steve,

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

    Thanks!

    Serge

  7. [author] Steve Kemp

    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.

  8. [gravitar] Mourad De Clerck

    you've probably seen this before, but just in case:
    https://github.com/phusion/juvia

  9. [author] Steve Kemp

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


    • https://github.com/talkatv/talkatv
    • https://github.com/phusion/juvia
    • https://github.com/posativ/isso/