coComment for CS 2007 updated

Every day you can learn something new. Today it was Scott who taught me ControlAdapters after he read my post about coComment with CommunityServer 2007. You know, ControlAdapters are not only good for tweaking CSS.

My original solution was a replacement for the WeblogPostCommentForm, i.e. for every blog theme you had to edit its post.aspx, register my new control and replace the original control.

ControlAdapters however give you the power to inject your code into any desired existing control. In a central file you specify which controls you want to customize, and that's it. No editing of any pages or controls is required.

So I took the chance and transformed my custom comment form into a ControlAdapter. In fact, it's as easy as writing a control. Here's the simplified code, just in case you're interested:

public class WeblogPostCommentFormAdapter : ControlAdapter
{
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        WeblogPostCommentForm commentForm = base.Control as WeblogPostCommentForm;
        if (commentForm != null)
        {
            string coCommentScript = GetCoCommentScript(commentForm);
            if (!String.IsNullOrEmpty(coCommentScript))
                CSControlUtility.Instance().RegisterStartupScript(base.Control, 
                    typeof (WeblogPostCommentForm), "cocomment", coCommentScript, false);
        }
    }

    private static string GetCoCommentScript(WeblogPostCommentForm commentForm)
    {
        // just boring stuff which creates the javascript code to make coComment happy
    }
}

Just drop the attached assembly to your ~/bin folder and add following line to the controlAdapters section in ~/App\_Browsers/default.browser:

<adapter controlType="CommunityServer.Blogs.Controls.WeblogPostCommentForm"
    adapterType="ThomasFreudenberg.CS2007.WeblogPostCommentFormAdapter, ThomasFreudenberg.CS2007" />

That's all, without further editing of any files1 coComment support is enabled for all blog themes automagically.

1 unless of course if you're already using the assembly I published yesterday; in this case revert all changes done to your post.aspx

coComment support for CS 2007

If you are one of my two regular readers, you may have noticed that I published many posts regarding coComment. In fact, I published instructions to integrate coComment in original CommunityServer and CS2.1SP1 (for CS2.0 and CS2.1 Keyvan was faster than me [:p])

(if you think I write so much about coComment is because I love it so much, you totally missed the point of my blog)

Anyway, if you follow the old instructions you'll see that there's bunch of script code you have to add to your blog theme. Unfortunately, that solution does not work anymore with CS 2007, because the controls in the comment form are wrapped in a new Chameleon control. I did not see a chance to access the ids of the contained controls and continue the old solution with my limited ASP.NET knowledge.

Instead, I developed another solution. I simply inherited a new control from WeblogPostCommentForm, where I have all access to the contained elements. And up to now I didn't know how easy it is to add some script in your code to be added to the rendered HTML

Long story short, here's my solution for coComment support in CS2007:

Drop the attached ThomasFreudenberg.CS2007.dll into your ~/bin folder.

Open post.aspx of your desired blog theme

  1. Add following line right after the imports:

    <%@ Register TagPrefix="TFr" Namespace="ThomasFreudenberg.CS2007"
        Assembly="ThomasFreudenberg.CS2007" %>
    
  2. Replace <CSBlog:WeblogPostCommentForm> with <TFr:WeblogPostCommentForm>

  3. and </CSBlog:WeblogPostCommentForm> with </TFr:WeblogPostCommentForm>

In fact, for me as a non-web developer that approach seems much more natural to me than adding fancy instructions in the web control.

ThomasFreudenberg.com Upgraded to CommunityServer 2007

This site has been upgraded to CommunityServer 2007 (I guess visitors to my site do know CommunityServer, and they already read the announcements.) Of all all CS MVPs, I am again late to the party [;)]

The upgrade was pretty easy. I spent about 2 hours on it, mainly because of my limited upload bandwidth. However, I had to create a new CS2007 package, because all the cool extensions I used for my old installation are not yet released for CS2007. But don´t worry, the CS MVPs are busy upgrading the CSMVP CSModule package.

I started to create my own theme a couple of weeks ago, but because of lack of time and CSS experience, it´s not finished yet. Therefore my site still looks the same as before.

BTW, Starting with CS 2007 there´s a new distributable called "One-Click Install"?. This package is a kinda XCOPY distribution, using Cassini and a file-based database. It's great for developers because you neither need to configure IIS nor the SQL Server.

Kathy Sierra

Community Comments

Generally I limit my posts to programming stuff, but after I read Kathy Sierra's Death threats against bloggers are NOT "protected speech"? (why I cancelled my ETech presentations) I have to break my habit.

If you don't know Kathy, she's one of my favorite bloggers. Her Creating Passionate Users should not only mandatory for UI developers, but gives insightful views on user experience every developer and manager should be aware of.

This sucks.

Update 1: Scoble stops blogging for one week, because he, as many others, feels with Kathy.