Sharing Extension for Graffiti

Graffiti Comments

Two weeks ago Telligent published the second beta of their upcoming new product Graffiti. It is a simple lightweight content management system. And by simple I don't mean lame. Far from it! It is simple in the sense of easy deployment, management, and publishing.

Additionally it's easy to extend. Keyvan, who I got to know and appreciate while working on the Community Server Modules, already wrote several extensions for Graffiti. To wrap up all his addons and provide a simple installation experience he started the Graffiti Extras project on CodePlex. And he was kind enough to accept me as a contributor.

So here it is, my first extension for Graffiti. In fact, I was inspired by Danny Douglass' Social Bookmarks extension for BlogEngine.NET. It enables you to link your posts to some of the most popular social bookmarking sites. The image to the right depicts an exemplary post with the extension rendered below.

Implementation

The Sharing extension is implemented as a so called chalk. Think of chalks as of macros. How to write your own chalk is well-documented, so I won't describe how I implemented the Sharing extension. If you want to have a look at the sources, go to the GraffitiExtras project on CodePlex and either download them or browse them online.

Installation

To install the Sharing chalk (and all other extensions provided in Graffiti Extras) download the attached ZIP File. This archive contains two root folders: in the bin folder you can find the GraffitiExtras.dll which you must drop into the bin folder of your Graffiti installation. The second folder, sharing-images, contains two flavors of icons in different sizes (16x16, 24x24, 32x32, and 48x48) for several social bookmarking sites (original icons are provided by FastIcon). Either copy that folder entirely or only the desired flavor/sizes somewhere to the Graffiti web folder.

Usage

To add the sharing extension to your posts, you just have to add a single line to your theme file:

$sharing.Write($post, "<image folder>")

Replace image folder with the path to the desired images. E.g. if you have copied the entire sharing-images folder to the root of your web application, and you want to see the round images with a size of 16x16, you would add following line:

$sharing.Write($post, "/sharing-images/circle/16x16/")

By default the different images are separated by a non-breaking space (&nbsp;) but you can change that with the optional third parameter:

$sharing.Write($post, "<image folder>", " | ")

.NET-Forum.de launched

Community Server, Community Comments

.NET Forum

A couple of days ago Jan Welker launched a new German .NET related community site, .NET-Forum.de. I didn't expect the developsphere to require just another site, but there are already 51 users registered, even though the site wasn't advertised anywhere except the dotnet-snippets.de newsletter.

Jan set up Community Server 2007.1 to drive the site (Did you know that .NET related non-profit communities may receive a free license?) I try to support Jan whenever he experiences issues with CS or has a configuration question. So for me it's an appreciated opportunity to get to learn CS's forum capabilities (Till now I only used the blogging part.)

I wish Jan success, and maybe this post will lead some more people to his site.

String.IsNullOrEmpty as Extension Method

.NET Comments

Most you will probably know about Extension Method introduced with C# 3.0. If not, I strongly recommend to read ScottGu's explanation.

Anyway, a couple of days ago Brad Wilson posted an experiment:

What I wasn't sure was whether or not you could call these extension methods when you have a null instance of the object, since they're instance methods. The C++ guy in me said "sure, that should be legal", and the C# guy in me said "it's probably illegal, and that's too bad". Amazingly, the C++ guy in me won!

This code executes perfectly:

using System;

public static class MyExtensions {
    public static bool IsNull(this object @object) {
        return @object == null;
    }
}

public class MainClass {
    public static void Main() {
        object obj1 = new object();
        Console.WriteLine(obj1.IsNull());

        object obj2 = null;
        Console.WriteLine(obj2.IsNull());
    }
}

When you run it, it prints out "False" and "True". Excellent!

When I read that I immediatley thought of another application. I guess all my readers are familiar with String.IsNullOrEmpty which was introduced with .NET 2.0. So I asked myself if you can make IsNullOrEmpty a parameterless extension method:

using System;

public static class MyExtensions
{
    public static bool IsNullOrEmpty(this String s)
    {
        return String.IsNullOrEmpty(s);
    }
}

public class MainClass
{
    public static void Main()
    {
        string s1 = "Hello world";
        Console.WriteLine(s1.IsNullOrEmpty());

        string s2 = null;
        Console.WriteLine(s2.IsNullOrEmpty());
    }
}

Again, it prints out false and true. And in my opinion this syntactic sugar looks much more elegant than the ordinary String.IsNullOrEmpty(s2)`.

If only C# would support extension properties...

Goodbye Aachen, Hello Hamburg

Hamburg, Proximity, Cycos Comments

Cycos

After more than 8 years I´ll leave my current employer Cycos by the end of this year. Starting 1/1/08 I'll work as a Senior Software Developer at Proximity (international website.)

Cycos is my first employer, I started here right after university in 1999. Originally I didn't plan to stay that long here but 5 years at maximum. However, because the work was so diversified and the working atmosphere so prolific, I stayed some years longer. E.g. I was delegated to Munich and San Jose (CA) for several month each, and they paid me the attendances and expenses for both PDC´03 and ´05 in LA. In other words, I can´t accuse myself of being inflexible or inmobil. And it was always fun working at Cycos. I´ll be contended if the working atmosphere at my new job is half as prolific as I got to know it in the past.

However, after 8 years it´s time for a change. Most of my time at Cycos I wrote proprietary software, mainly clients for computer telephony integration. In contrast, at Proximity I will leverage Microsoft products such as MOSS and BizTalk, i.e. areas I don´t have a clue about where I can gain experience. But don´t get me wrong, I´m really looking forward for the new job.

Proximity

And I´m not only changing the employer, but the town as well. I´ll move to Hamburg, which is 500 km away from Würselen/Aachen (for my American friends: that´s about 310 miles). Therefore the search of a new domicile has my highest priority at the moment. I have 18 paid leave days left, and I want to complete my relocation this year. So this blog will stay quite silent the next few weeks. But stay tuned, I´ll keep you informed.

XTOPIA 2007

Community, Conference, Xtopia Comments

Now Germany has its own Mix conference, though here Microsoft calls it Xtopia. It will cover Silverlight, WPF, the Expression suite, and much more. It will take place in Berlin from 10th to 12th of October (if you include the post-conference on Friday).

I'll go to Berlin tomorrow already, and stay until Saturday. My Hotel is the Quality Hotel & Suites Berlin City East. If you want to join me for a beer or two, drop me a line or call me at +49 (173) 285 21 81. Lars, I'm expecting your call.