Codemania Partner Summit 2010


At last weeks partner summit I once again had the pleasure and honor of entertaining the übber-geeks for a while together with Magnus “EPiServer God” Stråle. If you missed this great event, you can find the video here. As promised, I’ll share what I had to show.

In my mind, the absolute coolest thing shown was Johan Olofssons LINQ 2 PageQuery code which he kindly blogged a few days ago. I also demonstrated my own QuickWatchGadget – even though it’s old news.

The last thing on my sheet (besides a crazy little powerpoint gadget) was a small system of plugable outputformat providers. The idea is that you can plugin your own output format providers and thereby output any page in whatever form you want it.

It’s easy to write your own output formats. Just implement a simple interface and attach an attribute to register it. Like this:

   1: [OutputFormatPlugin(AcceptedFormats="txt")]
   2: public class TxtOutputFormat : IOutputFormat
   3: {
   5:     #region IOutputFormat Members
   7:     public void HandleFormat(EPiServer.Core.PageData Page, System.Web.HttpContext Context)
   8:     {
   9:         Context.Response.Clear();
  10:         Context.Response.AddHeader("Content-Type", "text/plain");
  12:         Context.Response.Write(Page.PageName + Environment.NewLine);
  13:         Context.Response.Write(Environment.NewLine);
  14:         string propname = Context.Request["bodyproperty"];
  15:         if(propname==null)  propname="MainBody";
  16:         Context.Response.Write(
  17:             Context.Server.HtmlDecode(EPiServer.Core.Html.TextIndexer.StripHtml((string)Page[propname], ((string)Page[propname]).Length)));
  18:         Context.Response.End();
  19:     }
  21:     #endregion
  22: }

You access the output formats by calling the url with the “outputformat” attribute. Like this:[format] [&optional parameters]

The implemented output formats out of the box in this little project right now are:

  • Text (txt) output format. Returns a text file with the page name as a title and a mainbody as the text.
  • Image (jpg,png,gif) output formats. Returns an image of the page. Optional parameters are width and height.
  • Pdf output format. Returns a pdf of the page.
  • Xml output format. Returns the page as xml. Add “children=true” to also include child-pages.
  • Json output format. Returns the page as json. Add the “children=true” to also include child-pages.

To get started just drop the assemblies in the bin and add a reference in your project. If you are running Windows 7 you might want to make sure you ‘unblock’ the downloaded assemblies first.

I have a lot of additional ideas for output formats, but haven’t gotten around to making them – like rss, atom, yaml, pivot, and so on.

Download the assemblies here. I only release them here as binaries due to license restrictions on the external PDF/Image library I use.

NOTE: Released AS-IS. As always, use at your own risk. This is experimental and not officially supported code.

Download here for CMS 6.


I hope everybody at the Partner Summit enjoyed it as much as I did.

Post Comments()