As the Beta2 release of the CKS:EBE is now available I thought that it would be good to write some articles around it. In them I'll try to describe the architecture, the projects and the code. This first article will look at how the CKS:EBE is implemented and all the different 'bits' involved.
Standard WSS blog site
The first thing to say about the CKS:EBE is that it is a feature, not a site template. Essentially this means that you can create a standard WSS blog site and use it, later you can add the EBE functionality if you want. This is very useful as it does not require you to make a decision about what type of blog you are going to use when you initially create the WSS site.
Once your site is created and you decide to use the CKS:EBE then you can easily add the solution to the farm and activate the feature on your blog site. All the CKS:EBE functionality will become available to you and your blog will switch to the default CKS:EBE site template. This can be done immediately after creating the site or after months of use. If you then decide you wish to go back to the original blog site template, then just de-activate the feature...everything will return to normal.
I should point out here that currently the CKS:EBE leaves behind all the lists and columns it creates when you de-activate it. This is so that you do not lose any information by de-activating the feature. If you don't want them anymore then you can safely delete them.
Four features deployed
The installation is very straight forward, as we use SharePoint solution deployment to install all the binaries and features. The main consideration after deploying the solution is activating the two required features.
The main feature is the obvious one. After the .WSP has been deployed you should see a new feature in the 'Site Features' section of the site settings. However there is another one which is hidden away in central administration. The site will not use the EBE without both of these features being activated.
WebApplication feature
This feature is the one responsible for modifying web.config, and so it makes sense to have it as a WebApplication feature...activating it affects all sites using that IIS application.
But also, as explained in a previous post, you need greater privileges to create timer jobs which modify web.config. Activating the feature in central administration generally ensures you have the rights to create these jobs.
Site (Web) Feature
The site feature contains all the pages, lists and new columns needed for the EBE. Upon activation the feature receiver executes code which performs all the updates, modifications and additions. This code also activates two other features to the web.
Themes Feature
The themes feature is the one which contains all the default themes shipped with the CKS:EBE. These can be used as they are, extended with new functionality or used as the basis for a theme of your own. This feature is hidden and is activated by the site feature.
Trackback Feature
The EBE now includes functionality for track backs. When activated this feature creates the required lists and adds columns to the Posts list. This feature is also hidden and is activated by the site feature.
New Lists and Columns
When you activate the feature the existing Posts list has some columns added to it and a two new lists are created.
Post List
The post list has some new columns added...Categories, PostTitleForUrl, CategoriesAsText. They provide the data for the new functionality of the EBE.
Media
A new document library is created called Media. This is used by the MetaWeblog API to store all the media posted to the blog using LiveWriter, or a similar blogging tool.
HttpHandler and HttpModules
The CKS:EBE makes use of handlers and modules to achieve a lot of the functionality. The main two are...
RssFeedHandler.cs
This handles requests for your RSS feeds. The handler lists the 10 most recent posts and formats it into an RSS feed. During the formatting process the CKS:EBE fixes some of the missing or incorrect tags in the feed, adds the required DC tags and the DC namespace.
Also during this process the links within the posts are fixed so that absolute URLs are used for the images and URL references. This also gives the EBE the chance to fix any links which use '/post.aspx?ID=', by changing it to use the friendly URL.
This handler also allows feeds based on categories or tags. By adding ?cat= to the end of your feed URL, the latest 10 posts with that category are included.
HttpModule.cs
This is the main HttpModule used in the feature. It is responsible for re-writing the URLs, protecting 'system' pages (if so desired), authenticating the MetaBlogApi requests and switching the .master for the current theme.
New EBE base SharePoint controls
The CKS:EBE contains a number of controls, most of which produce XML. These controls provide all the basic functionality for the blog and are what allow the blog to skinned with themes. The CKS:EBE provides a number of base classes which you can extend to provide additional functionality.
BaseXmlControl.cs
This is the basis for the majority of the controls. It provides all the methods and properties to transform the XmlDocument produced by the inheriting control. This control handles the rendering, by making use of the XslTransformControl.
XslTransformControl.cs
This is the control used to transform the XML into the HTML. Other controls in the project do not actually produce any HTML themselves as they are only responsible for producing the XML, they all delegate the production of HTML to the XslTransformControl. This control knows how to retrieve the XSL from SharePoint, do any caching and render the HTML from the supplied XML document.
BaseQueryControl.cs
This is the base control for anything that queries the site using the SPSiteDataQuery object. It exposes all the properties of the CAML query and allows you to add a specific query to any of your layouts without writing any code. Generally this control is inherited from and the Query, ViewFields, etc are set within the inheriting control.
ListControl.cs
This control gives you access to a specific list XML. You can place this control within a page layout, specifying the list name and it will return the XML. This gives you the ability to create any list in WSS and display its content within your blog using XSL.
The Themes - Modular Theme Framework - MTF
The modular theme framework is what allows the blogs to be skinned and also allows them to be easily switched. The MTF gives blog owners the ability to switch themes as desired and makes creating custom themes for WSS blogs much easier.
The MTF uses of XSL and CSS to style a blog by transforming the XML produced by the EBE. Creating a new theme involves modifying the .master page, creating some new CSS and modifying the XSL...for the most part new themes can re-use existing XSL provided OOTB.
Ari, has written an excellent user and design guide how implement a new theme using the MTF.
Next time I will try to expand on the inner workings and how some of the more interesting features are implemented.