Adding comments

Posted on Jan 19, 2011

In my last post I hinted that the next feature to be implemented was a comments facility. Searching through the web I found two options Disqus and IntenseDebate. Browsing through their respective sites, I liked Disqus better. Judging by a few comparisons I found here and here, and the fact that gitready uses Disqus. Disqus scored best in my comparison. Their registration process also was a lot less labor intensive. Adding the code to the site was also trivial. Being a bit overly purist I decided to translate the code snippet provided by Disqus to Haml. Which results in the following:

{% assign post_id = '{{ post.id }}' %}
{% assign post_url = '{{ post.url}}' %}
%div#disqus_thread
:javascript
  /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  var disqus_shortname = 'basbossink'; // required: replace example with your forum shortname

  // The following are highly recommended additional parameters. Remove the slashes in front to use.
  var disqus_identifier = '{{ post_id }}';
  var disqus_url = 'http://basbossink.github.com{{ post_url }}';

  /* * * DON'T EDIT BELOW THIS LINE * * */
  (function() {
    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
    dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
%noscript 
  Please enable JavaScript to view the 
  %a{ :href => "http://disqus.com/?ref_noscript" } 
    comments powered by Disqus.
%a.dsq-brlink{ :href => "http://disqus.com" } 
  blog comments powered by
  %span.logo-disqus 
    Disqus

This snippet can also be found in the Git repository from which this blog is generated, here to be exact. Now that the basic infrastructure is in place. It is probably time for some real content. Until next time.