About Archive Tags RSS Feed

 

disqus on the cheap?

2 February 2014 21:50

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

icon Steve Kemp at 14:22 on 2 February 2014
http://www.steve.org.uk/

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.

icon Erik Johansson at 15:21 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.

icon Steve Kemp at 15:26 on 2 February 2014
http://www.steve.org.uk/

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.


icon Steve Kemp at 16:43 on 2 February 2014
http://www.steve.org.uk/

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

icon Florian at 17:58 on 2 February 2014
http://f5n.org

Whoo, awesome.

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

icon Serge van Ginderachter at 18:14 on 2 February 2014
http://serge.vanginderachter.be

Hi Steve,

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

Thanks!

Serge

icon Steve Kemp at 18:55 on 2 February 2014
http://www.steve.org.uk/

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.

icon Mourad De Clerck at 01:13 on 3 February 2014

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

icon Steve Kemp at 09:44 on 3 February 2014
http://www.steve.org.uk/

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/