Many people use Disqus as a commenting system for their (static) blog. It's a free service, easy to get started with, and it has everything you'd expect from a commenting system. It's free up to the point where Disqus decides to show advertisements alongside the comments, and these advertisements are so bad, you will look for better options very quickly. The way out of advertisements, of course, is to start paying for their services. Actually, I would have paid already for their service, if only they would have reduced the tremendous amount of stuff they load on your page. And the cookies they need for tracking you across the internet of course.
So, even though I did start paying for Disqus to at least get rid of the horrible ads, I added a little card on my Trello board saying: "Replace Disqus". This turned out to be a nice side project, and after spending many hours on it, it's now ready for production. In fact, there has been a silent launch, but nobody has been using it so far. Let's see if that changes after today.
The commenting system that now finally replaces Disqus is called MailComments. I'm planning to make the software more widely available in a couple of months, but I first need some feedback from running it in production before releasing it in any way.
The idea is rather simple, but of course, there are many implementation details to be considered. In its essence, MailComments allows you to write comments by email. Below every post there is a
mailto link. When you click on it, you can compose a comment in your own mail client. After sending it, it will arrive in a dedicated mailbox. MailComments reads new emails in that mailbox, and starts processing them. After a short while, the message is converted into an HTML snippet that can be included in the blog's own HTML page.
When you open up a mailbox and allow people to use it to post messages directly to your website, of course you're asking for trouble. That's why I've added a few security measures:
- HTML emails will be cleaned first. Any imaginable thing that I wouldn't want on my website will be removed (e.g.
<script>tags, and much more).
- Messages won't be processed until I have marked them as "seen" and I didn't delete them within x seconds.
I'm particularly proud of the design and development process behind this piece of software. At its core is a domain model for posts and comments. It has ports for creating posts, adding comments to posts, replying to comments, deleting comments, and deleting posts. The adapters for these ports use the ddboer/imap package to connect to the mailbox using IMAP. They take incoming email messages and convert them to commands that can be processed by the application services.
The test suite consists of unit tests for the domain model (PHPUnit), acceptance tests for the application layer (Behat), integration tests for the port adapters (PHPUnit), and system tests (Behat) that show that everything works well together, using Greenmail which is an SMTP and IMAP server you can use for local testing.
The application consists of two main components: a long-running process that checks the mailbox and processes incoming messages, and a client package which the blog maintainer can use to run special commands via email. For instance: you can export your Disqus comments as XML and import them by sending an email to the MailComments system itself. It will take the XML file and import the comments. There is also a Sculpin plugin (this blog runs on Sculpin), which registers new posts with the MailComments system (also by sending an email to it).
You can find some more information about mail comments on its website, mailcomments.com (which for now redirects to a page on this blog).
Happy commenting everyone! And I can now finally archive that card on my Trello board ;)