Showing posts with label Window Live Writer Plugin. Show all posts
Showing posts with label Window Live Writer Plugin. Show all posts

08 December 2007

Facebook for bloggers

tmpCB71



for

tmpCB73

Obviously, I have quite some time on my hand lately and somehow I got to install Windows Live Writer (WLW). To be honest, I know about it for quite some time but never had the chance to experience it first hand. As I was not blogging very often, the need for a good blogging tool never came to me - I just used MS Word 2007. So after checking it out for just a few minutes, I realized how much time I wasted fixing blog post design after publishing it. For everyone who is still struggling with Word or those nasty WYSIWYG editors - check WLW out!

Being always ready for interesting new stuff, I spotted that it also supports plugins. I started searching for what kind of plugin there are on the web. And it turned out that there were quite a few of them, bringing additional functionality to the tool - adding pictures and video content from different source (Flickr, Picassa, Soapbox, YouTube... etc.). Other plugins allowed starting up WLW and pre-populating it with different content. Suddenly, I started to realize that it will be great have such integration also with Facebook. It has great developer friendly platform and it will be a waste not to use it. There had to be someone who has done something on that end. Unfortunately there weren't any!

Cheer up pals! Nothing's lost. This was a good opportunity to start something new and build that kind of integration.

Windows Live Writer

tmpDA71

Developed as part of the Windows Live platform, WLW appears to be very powerful blogging tool - the best of all I have tried by now. It integrates great with a numerous blogging platforms - all of the most popular (Community Server, Blogger, WordPress, Spaces etc.). What I love about it is that it is fast, accurate and gives you the exact preview as it will look when you publish the post. What is even better, it is written in .NET.

Built on .NET 2.0

tmpDA91

Built on top of .NET Framework 2.0, it gives very easy way to see what it is doing and how (remember Reflector ;) ) and second it gives great ways to integrate with and extend its current functionalities. You can plug your own functionality or even export into it a whole blog post from somewhere.

How to get the plug in ...

tmpDAC1

Basically, you have two ways to integrate with WLW. The first one is by creating a "Blog this" kind of functionality. This is not exactly creating a real plugin, but more or less integrating with WLW. A good example for this is a FireFox plugin that allows you to blog the page you are currently on - you go to a page or blog post where you like something and want to blog about it, click the plugin button in the toolbar and in a few seconds you have WLW loaded with pre-populated content form the site .... cool ah ;). So this is one way of integrating that I will talk about very soon ... stick with me a little while and I'll explain more.

The second one is by creating a real plugin for WLW. This is the thing I'll be talking about in more details. The architecture beneath is quite simple - two base classes and a bunch of attributes for them. The classes are ContentSource and SmartContentSource - one for simple content and one for more complex suppliers. You build a class library with class deriving from one of them, override one of more methods (if necessary), compile the solution and drop the DLL into WLW Plugin directory. This is the simplest way you can do "the thing". Sure, there are more complicated ways of building and registering a plugin - adding registry keys etc., but for starters this is good enough. A good source of materials that can guide you through the process of building a WLW plugin is Windows Live Writer SDK pages in MSDN. There you can learn the basics and start experimenting.

Facebook and .NET

tmpDB00

Facebook is the most recent passion that has infected a huge number of people. Stefan had a talk a few weeks ago about developing Facebook application with ASP.NET and also created a add-in for Bookvar that imports friends and their pictures. What differentiates Facebook from the other Social Networking sites is the ability to extend the platform by creating your own addition (applications for it). You can develop you own application that shows then into your profile, everyone can see it and can also add it to their profile. Quite darn cool! This not only gives great flexibility but also allows for very fast spreading of your application. One can even make money by creating such applications.

Facebook.NET

In order to create such applications first you need to register in Facebook. Then register a new application and right after that you can start developing. In order to develop Facebook application in .NET you will need some wrapping library to do the service calls to Facebook for you. You can choose between two options - one is Facebook Developer's Toolkit and Facebook.NET. Both of them are open source and hosted on . I chose to use Facebook.NET created by Nikhil Kothari. Why ... I had a good look on both and this one I consider better for my case.

Building the plugin

What did I use and howtmpDC49

I used Visual Studio 2008 RTM (the latest and greatest), also the Facebook.NET library and in addition to that the WPF Samples Library for more friendly user experience.

For building this plugin, I decided to take as a reference Rick Strahl's Extended Amazon book plugin as it was doing similar things to what I wanted to achieve. There are a lot of open source plugins for WLW that you can explore and take advantage of.

As always happens, the first step is to get the ball rolling. Namely, download the code and play with it. This part is always easy! Rick did the hardest parts by doing the plugin and explaining who it works. Then comes the funny part - cutting and chopping it into pieces! Pieces that you need and pieces that you throw away. Finally, comes the hardest part - actually adding the new functionality that is necessary and stitching it all together. The good news is that Nikhil did a hell of a good job on Facebook.NET architecture and APIs, so to a developer, using it is almost as intuitive as having a walk in the park. The bad news is that there are still use cases in which the library returns errors - for example when the user has no albums in Facebook, or no photos in an album. Well nobody is perfect and I'm sure that this minor stuff will be fixed in future releases. For now I worked around those error with a bit more checking and a little work with FacebookRequest - FacebookResponce objects.

Finally, comes the sweet stuff - making the whole thing look and feel better with WPF image listing.

The code for the plugin is simple and where it becomes more complicated I took care to put appropriate comments.

image

Deployment

tmpDC88

Live.com requires a packaged msi installer for any plugin to be published. In the beginning I hesitated whether to publish it to live.com merely because of that requirement. Then I got back to searching the web for any tutorials on WLW plugin setup creation and there it was. Ben Hall wrote a very useful blog post on creating WLW Plugin Setup and I took advantage of it ;).

Yeah ... "My name is Deyan and I like learning from people's experience." And why not ... Should we reinvent the wheel and discover hot water every time ... You're getting what I mean :)

So that was it actually... Following Ben's simple guide I managed to package to all up and submit to Live.com. As by this moment, it is still pending approval ... may be soon it will be part of the huge gallery of WLW plugins.

Publishing

tmpDCC7

While doing this tiny plugin for Windows Live Writer I had to delve deep inside Facebook's APIs and I couldn't stop thinking of all those different possibilities of integration that could be achieved using that platform.

It is a tendency that people start to learn new stuff more from other people's blogs than from some book or article. Yeah, books and articles give you the basics but what you really need is not there. Event look at this post. I'm explaining how I did this plugin and mostly it is by using someone's experience on that matter.

So, back to the subject. Blogging is something that is very hot now and will be here to stay. Definitely a tool like WLW needs plugins to allow better blogging and why not bring them to it. I think there is much more space to extend Facebook and WLW integration and so I decided to publish this tiny bit to CodePlex. This way, everyone who feels capable and willing to contribute to the idea and the plugin set, can do it. In the future I'll try to expand the current plugin functionality and further add more stuff to the set. I see that Nikhil and Facebook will do the same thing, so I guess we are going to have a lot of fun. If you have any ideas or suggestions on the subject, please feel free to contact me or propose them in CodePlex.

Download and try!

If you are eager to see it working there are 2 things you need to have in mind. First and most important - you need to have Windows Live Writer installed - this is the tool that is running the plugin :). Second, as the plugin is using WPF, you need to have .NET Framework 3.0 - those of you with Vista don't worry, it comes as part of the installation. For the others with Windows XP SP2 and above - you need to install it if you don't already have it. For other OS, there is no need to discuss, as the first prerequisite - WLW - will also not work there. Here you can download the msi installer and from here you can download the source code.

Download, install and enjoy folks ... And again, if anyone wants to help in getting this forward, please feel free to contact me.

What' next to come

Currently, the plugin is using Facebook.NET's official release. For starters, I want to keep it that way. I tried to port the thing to the latest fixes that Nikhil did, but found some bits that become very rough. Tried fixing them messing a little bit with Facebook.NET's code .... and it took me much more time, than to do the plugin itself. Probably next week I'll spend some time extending Facebook.NET's support for desktop applications and submit a patch, so that the next release supports better Facebook's functionalities and the Facebook4LiveWriter becomes a better app for everyone.

Currently it allows you only to add photos that you have from Facebook with no formatting of sizing options. Other thing that will be good to add is allowing you to add photos your friends albums. You might have even crazier thoughts on Facebook photos integration ... Give them to me ;)! I hope this will become a full plugin set for live writer that will allow you easily add to your blog posts much more FB stuff.

P.S.: You will probably see that I have attached a file with the extension .bmm to this post. This is the format that our tool - Bookvar saves mind maps that you create. Yes, this post was not totally written in WLW! In fact, very little was done there. Most of the job I did by creating a mind map of it and started filling more notes. So, you can check it out in that "non-linear graphical format". With the next release of the tool, we will be having this kind of Bookvar - WLW integration - export a mind map into a blog post to WLW. Stick around for more info in later posts.

Bookvar Mind Map: Facebook for bloggers.bmm