Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Barry 15 posts 94 karma points
    Oct 12, 2011 @ 09:45
    Barry
    0

    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

  • Rik Helsen 670 posts 873 karma points
    Oct 12, 2011 @ 11:08
    Rik Helsen
    0

    link?

  • Barry 15 posts 94 karma points
    Oct 12, 2011 @ 11:14
    Barry
    0

    Ah yes, sorry - doh! The RSS feed can be accessed here http://blog.codingbadger.com/rss/


  • Rik Helsen 670 posts 873 karma points
    Oct 12, 2011 @ 11:30
    Rik Helsen
    0

    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>

  • Rik Helsen 670 posts 873 karma points
    Oct 12, 2011 @ 11:32
    Rik Helsen
    0

    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. "

  • Barry 15 posts 94 karma points
    Oct 12, 2011 @ 11:42
    Barry
    0

    So, I guess if I just amend the CSHTML file to format it as per Atom 1.0 spec that should work fine?

  • Rik Helsen 670 posts 873 karma points
    Oct 12, 2011 @ 11:56
    Rik Helsen
    0

    i'd have to do additional research but it does look like it yes.

  • Barry 15 posts 94 karma points
    Oct 12, 2011 @ 13:06
    Barry
    0

    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.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 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>
    }

  • Rik Helsen 670 posts 873 karma points
    Oct 12, 2011 @ 14:17
    Rik Helsen
    0

    You might want to keep both feeds, not all readers handle atom, having both is just... better ;)

     

  • Zac 39 posts 61 karma points
    Feb 28, 2012 @ 00:04
    Zac
    0

    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'



Please Sign in or register to post replies

Write your reply to:

Draft