This is a concoction of geeky posts, programming posts and just general stuff that is in my brain.

It might be updated often but then again it might not...

 

 

Umbraco - How to amend uBlogsy to use Atom 1.0

I use the uBlogsy blog package for Umbraco for my blog, whilst looking at my blog posts in Google Reader I noticed that all formatting, images, links etc where being stripped out.

So after a bit of digging around on the Umbraco forums, it appears the uBlogsy strips out any HTML. This was easy to resolve but it was then pointed out to me by Rik Helsen that my RSS 2.0 feed would be invalid.

So, with a bit of tinkering I re-wrote the Razor file to use the Atom 1.0 format rather than RSS 2.0, with the advantage that you can include HTML in Atom.

The Razor file you need to amend is located in the Developer section under:

/ScriptingFiles/uBlogsyRSS.cshtml

There are certain sections that I have hard coded which you will have to change for your own site.

If you have any questions feel free to drop me an email or post a comment on this post. 

 

@{
     /*  RSS  FEED  */
}

@using  System.Linq
@using  System.Xml.Linq
@using  umbraco.MacroEngines
@using  uBlogsy.Web.Extensions
@
     //  get  all  posts
     DynamicNodeList  postList  =  Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyPost");
     var  posts  =  postList.Items.OrderByDescending(x  =>  x.GetProperty("uBlogsyPostDate").Value);

     string  lastPubDate;
     if  (posts.Count()  ==  0)
     {
         lastPubDate  =  DateTime.Now.ToString();
     }
     else   
     {   
         lastPubDate  =  posts.FirstOrDefault().GetProperty("uBlogsyPostDate").Value;   
     }   
     //  get  landing  page   
     var  landing  =  Model.AncestorOrSelf(1).DescendantsOrSelf("uBlogsyLanding").First();   
     <feed  xmlns="http://www.w3.org/2005/Atom">   
         
             <title>@landing.uBlogsyRssTitle</title>   
             <link  rel="self"  href="{http://YOUR RSS FEED ADDRESS/}">   
             </link>   
             <author>   
               <name>{YOUR NAME}</name>   
               <email>{YOUR EMAIL ADDRESS}</email>   
             </author>   
             <updated>@lastPubDate.FormatDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'")</updated>   
             <id>{http://YOUR BLOG ADDRESS/}</id>   
   
   
             @foreach  (var  p  in  posts)   
             {   
                     <entry>   
                             <id>@p.Url</id>   
                             <title>@p.GetProperty("uBlogsyContentTitle").Value</title>   
                             <author>   
                                  <name>@p.GetProperty("uBlogsyPostAuthor").Value</name>   
                             </author>   
                             <rights>@landing.uBlogsyRssCopyright</rights>   
                             <link  href="@p.Url"></link>   
                             <content  type="html">   
                                   @Html.Raw(@p.GetProperty("uBlogsyContentBody").Value)   
                              </content>                             
                             <updated>@p.GetProperty("uBlogsyPostDate").Value.FormatDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'")  </updated>   
                     </entry>   
             }   
     </feed>   
}

 

Posted by codingbadger at 12:21

Authors

Recent Comments

Powered by Disqus