Enabling FeedFlare on dasBlog

I spent some time last night fooling around with some of the options available from FeedBurner (which is an excellent service, by the way), and decided to enable the FeedFlare features. Doing so for your feed is trivial, since feedburner serves it with all done automatically for you.

FeedFlare.pngHowever, enabling it for your site does require you to add a <script/> tag to your item template. I implemented this fairly easily in the end (though it took me a while to figure out how) by creating a custom dasBlog macro. Here's the code for the macro:

//
// FeedFlareMacros.cs
//
// Author:
// Tomas Restrepo (tomasr@mvps.org)
//

using System;
using System.Web;
using System.Web.UI;
using newtelligence.DasBlog.Runtime;
using newtelligence.DasBlog.Web.Core;

namespace Winterdom.Commonality.Macros
{
   public class FeedFlareMacros
   {
      protected SharedBasePage _requestPage;
      protected Entry _item;

      public FeedFlareMacros(SharedBasePage page, Entry item)
      {
         _requestPage = page;
         _item = item;
      }

      public virtual Control FeedFlare()
      {
         const string scriptTag = "<script src=\"http://feeds.feedburner.com/{0}?flareitem={1}\" type=\"text/javascript\"></script>";

         string feedburnerName = _requestPage.SiteConfig.FeedBurnerName;
         if ( feedburnerName != null && feedburnerName.Length > 0 )
         {
            string script = string.Format(scriptTag, feedburnerName, HttpUtility.HtmlEncode(Utils.GetPermaLinkUrl(_requestPage.SiteConfig, _item.EntryId)));
            return new LiteralControl(script);
         }
         return null;
      }
   }
} // namespace Winterdom.Commonality.Macros

I then simply enabled it in the web.config file and inserted this into my blog template:

   <%FeedFlare()|FeedFlare%>

Not the most elegant solution, I'm sure, but it did the trick :). Seeing how Scott already went through this, I'm guessing a future dasBlog build might have built-in support for this stuff.

 

Comments (2)

Scott HanselmanApril 16th, 2006 at 7:44 pm

Shiny. I’ll check it in as a standard macro!

JRFJuly 30th, 2006 at 1:51 am

Argh, I wish this had been listed as a feature of the latest build. I went off and made one of these too.
http://www.jforsythe.com/jforsytheblog/2006/07/27/GotFeedburnerFeedflaresWorkingWithDasBlog18.aspx
I like yours though.

Leave a comment

Your comment