Thomas Freudenberg

Confessions of a caffeine addict

October 2005 - Posts

Update Rollup 2 brings MCE to the next level
Many announcements and blog posts regarding UR2 for MCE have been published during the last few days. But for me as a developer the most interesting change I've discovered in Michael Creasy's Update Rollup 2 for WIndows XP Media Center Edition is live!:
.NET Framework 1.1 support
Media Center now uses version 1.1 of the .NET Framework. Add-ins can now be built using 1.1, but 1.0 addins will still work.
Using Hyphens In Post Names
There was a discussion regarding naming of posts in a CommunityServer forum (a surprisingly unknown feature of CS::Blogs, though even dotText .96 supported it). CS replaces spaces with underscores. However, Jonathan stated that Google prefers hyphens to underscores. So I tried to use hyphens in the post name, but I've stumbed over two issues:
  1. You cannot enter hyphens in the post's name edit box because the field validator won't accept it. The regular expression is defined in the code as [a-zA-Z][1234567890a-zA-Z_\\s]{4,250}, i.e. only letters, digits, underscores, and white-spaces are allowed. To enable hyphens as well, you have to change line 155 in Blogs\WeblogPosts.cs to
    public static readonly string PostNamePattern = "^[a-zA-Z][1234567890a-zA-Z\\-_\\s]{4,250}$";

    and re-compile CommunityServer.Blogs.dll.
  2. When you want to visit the post using the named url, you'll get a 404 error. That's because the regular expression in SiteUrls.config is defined as \w+, i.e. only letters, digits, and underscores. Again no underscores. Fortunately, there's no compilation required, instead change the regular expressions for weblogpostName and weblogarticleName to:
    <url name="weblogpostName"
        location="weblogs" path="{0}/archive/{1}/{2}/{3}/{4}.aspx"
        pattern="([\w\.-]+)/archive/(\d{4})/(\d{1,2})/(\d{1,2})/([a-zA-Z][1234567890a-zA-Z\-_]*)\.aspx"
        vanity="post.aspx?App=$1&amp;y=$2&amp;m=$3&amp;d=$4&amp;PostName=$5" />
    <url name="weblogarticleName"
        location="weblogs" path="{0}/articles/{1}.aspx"
        pattern="([\w\.-]+)/articles/([a-zA-Z][1234567890a-zA-Z\-_]*)\.aspx"
        vanity="post.aspx?App=$1&amp;PostName=$2" />

    (Be careful if your SiteUrls.config differs from the default configuration, e.g. if you have used Ken Robertson's SiteUrls Generator.)
If you're using ScottW's auto-naming module, you can skip step one including the re-compilation and just edit your SiteUrls.config.
Save Bandwidth and Compress Your CommunityServer Feeds

Now that my vacation and the PDC are over, I can continue with all the stuff which I left unfinished on my desk. One of these is a mod for CommunityServer which compresses all the exposed feeds. I've written it some weeks ago already and deployed it on my web server. Since it seems to work properly, I now want to announce it publicly. Though my bandwidth at WebHost4Life isn't limited, for some of you it may save real money.

The HTTP standard defines the compression of any content in  RFC 2616, section 3.5. IIS supports compression, however, admin permissions on the server are required. So if your CS blog is hosted in a shared environment, you do not have access to the server. Therefore, you have to look for another solution.

Due to the nature of blogs, the most accessed part of a blog is its feed, or better, the feeds, as most blogs offer RSS as well as ATOM, and may even explose feeds for categories and comments. Therefore it makes sense to at least compress the feeds.

Some time ago Jeff Julian has written an add-on for dotText which compressed the RSS feed. I used to use this add-on on my blog as well, which reduced the size of my feed by about 80%.

Currently CommunityServer does not compress its feeds, and till now there is no add-on available which would add this functionality. Therefore I took Jeff's solution as a starting point and wrote a module myself. Now I'm happy to announce Thoemmi.CommunityServer.Compression :-)

The installation is pretty easy: Download the ZIP file and extract the DLL's to your bin folder. Then replace the handlers in the httpHandlers section in web.config to point to my classes. Here's a lineup of the corresponding items:

Original blog RSS handler
CommunityServer.Blogs.Components.WeblogRssHandler, CommunityServer.Blogs
Replacement
Thoemmi.CommunityServer.Compression.CompressedWeblogRssHandler, Thoemmi.CommunityServer.Compression
Original blog ATOM handler
CommunityServer.Blogs.Components.WeblogAtomHandler, CommunityServer.Blogs
Replacement
Thoemmi.CommunityServer.Compression.CompressedWeblogAtomHandler, Thoemmi.CommunityServer.Compression
Original blog comment RSS handler
CommunityServer.Blogs.Components.WeblogCommentRssHandler, CommunityServer.Blogs
Replacement
Thoemmi.CommunityServer.Compression.CompressedWeblogCommentRssHandler, Thoemmi.CommunityServer.Compression
Original gallery RSS handler
CommunityServer.Galleries.Components.GalleryRssHandler, CommunityServer.Galleries
Replacement
Thoemmi.CommunityServer.Compression.CompressedGalleryRssHandler, Thoemmi.CommunityServer.Compression
Original forum RSS handler
CommunityServer.Discussions.Components.ForumRssHandler, CommunityServer.Discussions
Replacement
Thoemmi.CommunityServer.Compression.CompressedForumRssHandler, Thoemmi.CommunityServer.Compression

If you have had a default installation before, the httpHandlers section should now contain following lines:

<add verb="GET" path="blogs/rss.aspx"
     type="Thoemmi.CommunityServer.Compression.CompressedWeblogRssHandler, Thoemmi.CommunityServer.Compression" />
 <add verb="GET" path="blogs/atom.aspx"
     type="Thoemmi.CommunityServer.Compression.CompressedWeblogAtomHandler, Thoemmi.CommunityServer.Compression" />
 <add verb="GET" path="blogs/commentrss.aspx"
     type="Thoemmi.CommunityServer.Compression.CompressedWeblogCommentRssHandler, Thoemmi.CommunityServer.Compression" />
 <add verb="GET" path="photos/rss.aspx"
     type="Thoemmi.CommunityServer.Compression.CompressedGalleryRssHandler, Thoemmi.CommunityServer.Compression" />
 <add verb="GET" path="forums/rss.aspx"
     type="Thoemmi.CommunityServer.Compression.CompressedForumRssHandler, Thoemmi.CommunityServer.Compression" />

That's it. By default, the feeds are compressed with deflate with normal compression. If you want to change the compression level or switch to gzip compression, have a look at web.config.merge in the ZIP file. My add-on uses Ben Lowery's HttpCompressionModule, which in turn uses SharpZipLib. Both assemblies are included in the ZIP file as well.


BTW, if you want to check the compression of your feeds, PipeBoost generates Web Compression Reports.

[Update 10/14/2005: Fixed broken link]