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

disqus on the cheap?

Sun, 2 Feb 2014 12:32:38 GMT

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 :)

| 9 comments.

 

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.

Thanks!

Serge

[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:
https://github.com/phusion/juvia

[gravitar] Steve Kemp

Submitted at 09:44:03 on 3 February 2014

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/

 

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

Spiral Logo

Search

Recent Posts

Recent Tags

Links

RSS Feed

  • Subscribe to feed