Hacking Disqus

No video for this post today. It's just pure geekery that just cannot be made any less geeky or any more interesting by staring at my talking head.

Have I mentioned before that I <3 Disqus? I think maybe I have.

And a big thanks to the disqus guys for adding in a quick feature request I had that allowed me to pull my own disqus comments from every blog into my lifestream here on my homepage.

There are some other features that I'd like to see, and to work that out on my own, I've been doing some hacking and tweaking to get Disqus to do exactly what I want in Wordpress. Here's what I've done so far and how you can implement it on your own.

If you do make these changes, keep a few things in mind:

  1. I did this in the beta version of the wordpress plugin.
  2. once they issue an update, these changes will be overwritten and if they haven't addressed them, will need to be redone. That's the life of a gangsta.
  3. proceed at your own risk.

Trackbacks

Disqus doesn't have any support at all for trackbacks. But since Wordpress will still grab and store them in your comment database, you can still display those. Add the following code somewhere in your wp-plugins/disqus/comments.php script. Be sure to edit the one in the plugin dir. I put mine way down at the bottom.

<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>

DoFollow/NoFollow

Disqus posts all links in comments as dofollow links. (sans the rel="nofollow"). That's not that bad since Disqus has measures to prevent spammers. But it doesn't stop the comment monkeys.

So I've been playing with a few different ways do put nofollow on some of the spammier comments while taking the opportunity to give dofollow back to the good guys.

Here's what I did, again to comments.php. The bold code is what I added, I've included a little context so you can put it in yourself:

<ul id="dsq-comments">
    <?php foreach ( $disqus_response['posts'] as $comment ) : ?>
    <?php
     //SCJ added check for rel=nofollow
        if ($comment['points'] < 1 || $comment['user']['is_anonymous']) {
            $follow = ' rel="nofollow" ';
        } else {
            $follow = "";
        } 
        //SCJ end change
        $profile_url = DISQUS_URL . '/people/' . $comment['user']['profile'] . '/';
    ?>

That sets the $follow var which I just slip into the website link here, down about 30 lines from the first change.

<?php if ( $comment['user']['url'] ) : ?>
    <li><a href="<?php echo $comment['user']['url']; ?>" 
    target="_blank" <?php echo $follow?>>Website</a></li>
<?php endif ; ?>

Feature Requests for Disqus

While I'm at it, here are some feature requests...

  1. Incorporate real trackback support. I don't think I care whether you just use Wordpresses trackback support like I did or try to incorporate it into your service. If you think you can do something about the spammers and scrapers, then by all means take it in. Maybe just allow an option to show trackbacks above or below the comments?
  2. Do something with the Dofollow/Nofollow. I'm pretty happy with the rules I set, which is to add in a nofollow for anonymous commenters and for comments that have been voted down. But something more sophisticated could surely be done and would be welcomed here.
  3. I want more notifications on blogs that I comment on. Right now, I think you send me an email if someone replies to one of my comments somewhere. But if there's a conversation going on in a blog post that I've commented on, I want to know about it. Can I opt to get notified of any reply in a blog post that I've contributed to?
  4. I want to do more with Disqus, namely allow people who read my blog to START conversations, not just respond to the ones I start. I sent you guys at Disqus an email about this with more details. But I really think you guys are just scratching the surface here.
  5. I'm sure your lunches with Loic have you thinking about video comments, so I won't waste a wish on that one. ;)

What do you say, does anybody have other wishes? They're hiring and surely need stuff for that Python hacker to do.

Posted on in Blogging
blog comments powered by Disqus