The Akismet Spam Rule included in Alabaster

Though I spoke about my Akismet spam rule a couple of weeks ago, I didn't draw that much attention to it. However, now that the first version of CSMVP's CSModules package, code name Alabaster, is released for more than a week, I'd like to spent some words on it, though Jayson mentioned it in his CS Tidbits: Exploring The CS Spam Blocker.

Akismet provides a web service, which evaluates a comment or trackback based on several tests and returns a thumb up or thumb down. (Additionally, it can be trained, but that's not supported by my spam rule.)

The spam rule I wrote and contributed to Alabaster calls this Akismet web service. The implementation is straight forward, for a general spam rule implementation see Jose Lema's instructions on the CS Forum. Well, there some tips missing, but Keyvan forwarded me an advice from Jose: if you use a web service in a spam rule, make that external call only if absolutely necessary. If the "cheaper" spam rules such as link count already identifies a comment as spam, an "expensive" call to an external service would be redundant.

The spam rule engine in Community Server evaluates comments three-stage. In the implementation of your spam rule you can specify at which stage your rule should be visited. Additionally, you can restrict your rule based on the result of previously visited spam rules. In the case of the Akismet spam rule, I specified that the rule should be visited in the third stage, and only if the comment is not considered spam yet:

/// <summary>
/// Gets the pass criteria.
/// </summary>
/// <value>The pass criteria.</value>
public override PassCriteria PassCriteria
    get { return PassCriteria.ThirdPass; }

/// <summary>
/// Gets the status criteria.
/// </summary>
/// <value>The status criteria.</value>
public override StatusCriteria StatusCriteria
    get { return StatusCriteria.NotSpam; }

Ok, enough about the implementation. The installation is pretty easy. Contrary to CSModules, spam rules do not need to be registered in any .config files. Instead, the spam rule engine finds all rules via reflection on all assemblies in CS' bin folder.

For the configuration, first of all you need a WordPress API key, because Akismet requires it. Though you can get a key for free, the Akismet is free only for personal use. If you are a commercial entity or making more than $500 from your personal blog, you need a commercial key.

Akismet configuration

Pretending you have your API key now, go to Control Panel -> Administration -> System Tools -> Manage Spam Blocker (~/ControlPanel/Tools/ManageSpamRules.aspx). Tick the spam rule and click on Configure. In the configuration window enter your API key and your desired points for detected spam (I chose 5, so it gets moderated automatically. I trust Akismet [;)]). Click Save to close the configuration window and again Save to accept the selected spam rules.

Windows Live Writer and WLWPlugins

Development, Software Comments

I just want to note that my last post was brought to you by Windows Live Writer and Code Syntax Highlighter.

Till now I always used Community Server's editing facilities, but often enough I lost my drafts for several reasons. WLW provides an auto-save option, which would have saved me a lot of time in the past.

But the coolest feature of WLW is its extensibility. Keyvan Nayyeri wrote a nice tutorial about how to create a Technorati tag plugin.

Mixing C# and VB.NET in one assembly

Development, MSBuild, CSMVPs Comments

A couple of weeks ago Jayson Knight invited me to join the CSMVP's' CSModules package. This project was created to incorporate several CSModules written by CS MVP's. So I bought into that project by bringing along my Akismet spam rule.

At that point in time, for each CSModule there was a single Visual Studio project, all bound together in a Visual Studio solution. But our goal was to incorporate all modules into a single assembly, so the user only has to copy one DLL to his /bin web folder.

My first idea was to put all sources into a single project. However, since every CS MVP wrote his module in his favorite language, there were both C# and VB.NET projects. Unfortunately, in Visual Studio projects have a certain type supporting only a single language.

But luckily, even if there's no support by the IDE, you still can compile different .NET languages into one assembly. The solution are modules. A module is a unit of compilation, comparable to .obj files in C++. It can't stand by its own, but must be linked into an assembly before it can be used. Basically, a module is an assembly without a manifest. You can get more details on MSDN at .netmodule Files as Linker Input. Additionally I recommend reading Junfeng Zhang's Netmodule vs. Assembly and Multimodule Assemblies.

Knowing the concept of modules, I was able to write a MSBuild project file to compile all CSModules into a single assembly. Here's an (extremely) simplified version:

  <!-- Target folders -->

  <!-- Specify the sources to include, excluding any assembly info's -->
      Exclude="$(SourcePath)/**/assemblyinfo.vb;$(SourcePath)/**/My Project/*"/>

  <!-- Specify all referenced assembly -->
    <References Include="lib/2.1 RTM/*.dll" />

  <!-- Target files -->

  <!-- builds the CSMVPs.CSModules assembly -->

    <!-- compile C# sources -->
    <!-- compile VB.NET sources -->

    <!-- link the C# and VB.NET modules -->
      Command="link /dll /ltcg /out:$(OutputModule).dll *.netmodule" />

Pimp my Community Server

Yesterday I upgraded my site to Community Server 2.1 RTM. I'm astonished how many additional mods I'm already using:

Community Server MVP's Alabaster CSModule Package 
A collection of CSModules written by CS MVPs and myself. (I contributed the Akismet spam rule btw)

Provides a secure RSS feed for all comments within a certain blog. It also provides information like if it is an actual comment or a trackback, the post's name, URL, if it is approved, and then it gives quick links to approve/disapprove, view, or delete the comment.

A Lightbox module for any photo from the gallery, an URL or Flickr.

Improved version of Scott's Flickr for Community Server
Add a Flickr area to the content selector, which enables you to select images from your Flickr account.

This module allows you to easily map one URL within Community Server to another. I for instance use it to map both my blog and my gallery to the root.

Syntax Highlighting module
Formats code snippets with syntax highlighting. I cannot give you any link, because I'm using a modified version of a CS1.1 module, and I don't know the original author anymore.

CommunityServer OpenSearch Handler
Adds OpenSearch support to your blog, allowing IE7 users to search your site from their toolbar without any installation.

CoComment support
Tracks your comments across the blogosphere.

I just noticed that three and a half modules of the modules are written by Ken Robertson. Seems as he is the most active guy on the Community Server community. [;)]