April 12, 2008, at 04:32 PM

Disqus

I have been using HaloScan for nearly a year now to power the commenting system of my bliki (the Logbook section only). Disqus popped on my radar a few months ago. I like the cross blogging platform commenting facility they are offering ... time to swicth!

The first thing to do is to create an account on Disqus and go to the General Integration section (not platform specific). In april 2008 it looked like this:

config.php

In your config.php (or a file you include in your config.php) add the following lines which create a (:disqus:) markup you will be able to use across your whole PmWiki installation, replacing YOUR-ID by your username on Disqus (or replace the code in the Keep call by the first snippet given by Disqus (see screenshot above).

Markup(
        'disqus',
        'inline',
        '/\\(:disqus:\\)/',
        Keep('<div id="disqus_thread"></div><script type="text/javascript" src="http://disqus.com/forums/YOUR-ID/embed.js"></script><noscript><a href="http://YOUR-ID.disqus.com/?url=ref">View the forum thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>')
    );

3kwa.tmpl

In your template file located in pub/skins/<your-skin> put the above code above the closing body tag (</body>) and replace YOUR-ID with ... obvious isn't it? (or copy the code in the second snippet given by Disqus).

<script type="text/javascript">
//<[CDATA[
(function() {
                links = document.getElementsByTagName('a');
                query = '?';
                for(var i = 0; i < links.length; i++) {
                        if(links[i].href.indexOf('#disqus_thread') >= 0) {
                                query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
                        }
                }
                document.write('<script type="text/javascript" src="http://disqus.com/forums/YOUR-ID/get_num_replies.js' + query + '"></' + 'script>');
        })();
//]]>
</script>

You are done ... wherever you want to allow comment on PmWiki document type (:disqus:)!