April 2007 - Posts
Some time ago I wrote a blog publisher for CruiseControl.NET, but didn't manage to blog about it. In fact, it totally slipped my mind. However, my machine behaves more and more weird lately, so I started to clean up the hard disks and back up all my data. So today it happened that I stumbled over my old blog publisher and finally posted it here.
Background: CruiseControl.NET (CC.NET) is a continuous integration server for .NET. Publishers are tasks that are executed by CC.NET after a build is done, and are primarily used to report the build results, e.g. by sending emails.
There are instructions on how to write your own publisher available, so I created one which posts the build results to a blog. It stood to reason to access the blog using MetaWeblog API. Fortunately, Charles Cook wrote the XML-RPC.NET library, so my publisher degenerated to a simple gateway 
The installation is simple: just drop the assemblies from the ZIP file to the server folder of CC.NET and restart the server. CC.NET uses a fixed naming scheme to find all extensions, that's why the assembly has that weird name ccnet.BlogPublisher.plugin.
The minimal configuration just takes details required to access a particular blog:
<publishers>
...
<blog>
<url><a href="http://localhost/MetaWeblog" class="linkification-ext" title="Linkification: http://localhost/MetaWeblog">http://localhost/MetaWeblog</a> url</url>
<blog>blog</blog>
<username>username</username>
<password>password</password>
</blog>
With this configuration the publisher uses the default XSL files to transform the build results before posting them. But if you want to change the content of the blog post, you can specify which XSL files sould be used. Additionally you can specify categories for the post:
<publishers>
...
<blog>
<url><a href="http://localhost/MetaWeblog" class="linkification-ext" title="Linkification: http://localhost/MetaWeblog">http://localhost/MetaWeblog</a> url</url>
<blog>blog</blog>
<username>username</username>
<password>password</password>
<categories>
<category>category 1</category>
<category>category 2</category>
</categories>
<xslFiles>
<xslFile>xsl\header.xsl</xslFile>
<xslFile>xsl\modifications.xsl</xslFile>
<xslFile>xsl\msbuild2ccnet.xsl</xslFile>
</xslFiles>
</blog>
The assembly is built with .NET 2.0, but it shouldn't be too difficult to change that. I even put the .NET 1.1 version of XML-RPC.NET into the ZIP file.
Brendan Tompkins released CAPTCHA for CommunityServer 2007:
I'm happy to announce that CodeBetter.Com is carrying on the legacy of CAPTCHA
for Community
Server. CAPTCHA for CS2007 is the next generation of CS Guru Dave
Burke's most excellent CAPTCHA control for
Community Server 2.1. This
version is implemented as a Control Adapter which allows CAPTCHA to be added
to Community Server site-wide without touching any ASPX or ASCX markup code.
You
can get the dll and source code here.
The installation is pretty easy since Brendan leverages the same technique as I did for my CS2007 coComment support: by using ControlAdapters not a single page or control must be touched.
In the past I always hesitated to use CAPTCHA on my blog because it´s an additional obstacle a commenter must overcome. Adding this hurdle seemed like a capitulation. But because spam has taken the upper hand over all comments I get, and CAPTCHAs are commonly used everywhere so the regular visitor is used to them, I´ll give it try and add Brendan´s CAPTCHA to my blog.
Mark August 24th 2007 in your calendar. On that date we (Just Community e.V.) stage nrw07, the largest community event 2007 in North Rhine-Westphalia.
This year it will take place in Die Börse in Wuppertal.
List of Speaker and agenda are not finished yet, but we'll promise it will be a top-class conference.
Don't miss it!
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'
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
)
(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
- Add following line right after the imports:
<%@ Register TagPrefix="TFr" Namespace="ThomasFreudenberg.CS2007"
Assembly="ThomasFreudenberg.CS2007" %>
- Replace <CSBlog:WeblogPostCommentForm … with <TFr:WeblogPostCommentForm …
- 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.
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.