I have subscribed to my RSS Feed on my uBlogsy blog.
When I view my blog entries in Google Reader for instance, all the formatting, pictures and line breaks etc are missing so it is just displayed as one long block of text.
Is this by design or is there a setting that I have missed.
note: this will allow all html in your rss feed, thinking of it, this will render your rss feed invalid (as a lot of stuff needs to be encoded or removed) so it's actually not that easy to do.
"Please note that RSS specifications, including RSS 2.0, doesn't allow embed HTML. Suggest you to use Atom 1.0 format that allows to include (X)HTML contents even whithout escaping it. "
With a little bit of tinkering I managed to amend the CSHTML to use Atom 1.0. I have hardcoded a few of the values but I'm sure other people can customise it to their needs.
Thanks that Atom example code was helpful. I think it should be made the default for uBlogsy.
Couple of issues though: - the html should be encoded so the @Html.Raw function is not needed - the updated date for each entry should also be formatted with yyyy-MM-dd'T'HH:mm:ss'Z'
RSS Feed - preserve formatting in feed
Hi
I have subscribed to my RSS Feed on my uBlogsy blog.
When I view my blog entries in Google Reader for instance, all the formatting, pictures and line breaks etc are missing so it is just displayed as one long block of text.
Is this by design or is there a setting that I have missed.
Thanks
Barry
link?
Ah yes, sorry - doh! The RSS feed can be accessed here http://blog.codingbadger.com/rss/
in uBlogsyRSS.cshtml look for this line:
<description>@p.GetProperty("uBlogsyContentBody").Value.StripHtml().Trim()</description>
Try changing it to this:
<description>@p.GetProperty("uBlogsyContentBody").Value</description>
note: this will allow all html in your rss feed, thinking of it, this will render your rss feed invalid (as a lot of stuff needs to be encoded or removed) so it's actually not that easy to do.
"Please note that RSS specifications, including RSS 2.0, doesn't allow embed HTML. Suggest you to use Atom 1.0 format that allows to include (X)HTML contents even whithout escaping it. "
So, I guess if I just amend the CSHTML file to format it as per Atom 1.0 spec that should work fine?
i'd have to do additional research but it does look like it yes.
With a little bit of tinkering I managed to amend the CSHTML to use Atom 1.0. I have hardcoded a few of the values but I'm sure other people can customise it to their needs.
@{
/* 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://blog.codingbadger.com/rss/">
</link>
<author>
<name>Barry Mooring</name>
<email>barry@codingbadger.com</email>
</author>
<updated>@lastPubDate.FormatDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'")</updated>
<id>http://blog.codingbadger.com/</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("ddd, dd MMMM yyyy HH:mm:ss") </updated>
</entry>
}
</feed>
}
You might want to keep both feeds, not all readers handle atom, having both is just... better ;)
Thanks that Atom example code was helpful. I think it should be made the default for uBlogsy.
Couple of issues though:
- the html should be encoded so the @Html.Raw function is not needed
- the updated date for each entry should also be formatted with yyyy-MM-dd'T'HH:mm:ss'Z'
is working on a reply...