Today, I finally deployed the new widget framework of BlogEngine.NEXT to my blog. It’s been under development for some months now, so it’s nice to see it in action for the first time on a live site.

For some time now, I’ve wanted to write new widgets but didn’t have any places to put them. Before now that is. The first thing that came to my mind was to write a Twitter widget displaying my last Twits. You can see the result on the side panel to the right. The widget just took about an hour to write.

The video

If you are interested in seeing how the Twitter widget works or to get a sneak peak of the widget framework, then here is a new video that explains the Twitter widget. If you watched the video displaying the early prototype of the widget framework, you might notice a lot of the changes and improvements we’ve done so far.

Download the video 

The code

If you run the latest and greatest build of BlogEngine.NET available from CodePlex, then you can add the Twitter widget to your own blog. Just download the zip file below, and put the Twitter folder into your blog’s widget folder.

Twitter.zip (2,82 kb)

Gravatar is a service that associates your e-mail addresses with a picture of you for use on blog comments, forums and bulletin boards. I’ve been a happy user for years.

A cool thing about Gravatar images is that they can be used from any application either on a website or a desktop application. But still, they are primarily used on blogs and forums.

Today, I played with the thought of a wider use and wrote some code that makes working with Gravatars very easy on both web and the desktop. The reason for this is that I needed a way to collect Gravatar images for a list of users, but only the users that actually have a Gravatar associated with their e-mail address.

The Gravatar service doesn’t have an API you can use to check if an e-mail address is associated or not. But by downloading a Gravatar image, the response header Last-Modifed is 1970-01-01 if no image is found and the default image is returned. This information can be used to only store the images users have uploaded to the Gravatar service.

An example

The class is called Gravatar and is very simple and small. Here is an example of using the class to download a Gravatar image and save it to disk.

string email = "name@example.com";

Gravatar gravatar = new Gravatar(email);

 

if (!gravatar.IsDefaultImage)

{

  using (FileStream writer = new FileStream("c:\\" + email + ".jpg", FileMode.Create))

  {

    writer.Write(gravatar.Image, 0, gravatar.Image.Length);

  }

}

Download

Download the class below and put it in your App_Code folder. Then you can use the example above from any ASP.NET page or control.

Gravatar.zip (888,00 bytes)