December 31, 2006

Comment Spam

Over the past couple of days my blog has been heavily hit with comment spam. In the last 10 hours I've gotten more than 100 spam message attempts posted to my blog. I moderate all comments so none of those messages saw the light of day but I still have to deal with them. I've never really tuned the comment spam features of MT and I still haven't. Instead I installed a CAPTCHA system. Previously I had required TypeKey in order to leave a comment but that felt a little to draconian. Not everyone has a TypeKey account or wants to create one. Email whitelists are another option but that still requires that I approve or junk email addresses when they are entered.

I'm all about not even having to look at the spam. While this may mean I automatically trash some important comment or email, I think most people are coming to realize that when 90% or more of all email is spam, people will take drastic measures and at some point a message will be lost. As such I'm now running the SCode plugin. The usability of CAPTCHAs is a concern but unless I go back to TypeKey only comments I don't have another good solution at this point. In fact the use of TypeKey on my system just means that your comment will automatically be posted but you still need to enter the security code in order to post.

Tags: links mt spam

May 31, 2006

Hacking Movable Type

While playing with the new tags feature I started with adding it to the main page of my site. The problem is that my older posts don't have any tags associated with them. The naive approach would just attach an empty "Tags: " line to each of those old posts. But even for my unskilled UI hacking skills that would be lame. There doesn't seem to be any kind of way to get the count of the number of tags associated with an entry in the Tags.app API. Doing some digging I did run across the MTIfNonEmpty template tag. I figured I could use that along with the MTTagsList widget to determine if a post had any tags.

Alas, it didn't work. Looking at the generated HTML there was a lot of excess whitespace. Thankfully I stumbled onto the trim filter. The documentation seems to indicate that the trim filter applied to the MTIfNonEmpty template tag would solve my problem.

Alas, it didn't work. After adding some debugging output to the MTIfNonEmpty template tag and the trim filter it looks to evaluate the value returned by the tag before applying the filters to the value. As a result the whitespace isn't getting trimmed correctly. Instead of trying to figure out why the call order looks to be out of order, I decided to take the easier approach and modify the definition of the MTIfNonEmpty test. The diff is below:

*** ./lib/MT/Template/ContextHandlers.pm~ Wed Aug 17 17:50:11 2005 --- ./lib/MT/Template/ContextHandlers.pm Thu May 4 23:54:42 2006 *************** *** 493,499 **** my $handler = $ctx->handler_for($args->{tag}); if (defined($handler)) { my $value = $handler->($ctx, { %$args }); ! if (defined($value) && $value ne '') # want to include "0" here { _hdlr_pass_tokens($ctx, $args, $cond); } else { --- 493,499 ---- my $handler = $ctx->handler_for($args->{tag}); if (defined($handler)) { my $value = $handler->($ctx, { %$args }); ! if (defined($value) && $value !~ /^\s*$/) # want to include "0" here { _hdlr_pass_tokens($ctx, $args, $cond); } else {

In short the template tag now considers any value that is only whitespace as being empty. I think given the nature of HTML (or XHTML) and optional whitespace, that this is a reasonable interpretation. Now to add the tags to other pages on the site, tag some of my older posts, and then see what my tag cloud starts to look like.

Tags: movabletype mt programming tags

May 31, 2006

Tags

I'm trying out a tagging plug-in for MT. I've not decided how good it is, but I figured I'd give it a try. It's called Tags.App. They have a nominal donation request, which is why I'm interested in trying it before spending any money. My first issue, like I've complained about in the past, is that the documentation for the product is pretty bad. I'm not an MT hacker by any means and the minimal documentation left me out in the cold. I'll have to see if I can figure out enough to make it work.

Tags: movabletype mt tags