@using OurUmbraco.Forum.Extensions
@using OurUmbraco.Forum.Services
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
    Response.Clear();
    Response.ContentType = "application/rss+xml";
    var baseUrl = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Host);
    var selfUrl = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, Request.Url.PathAndQuery);
    var topicService = new TopicService(ApplicationContext.DatabaseContext);
    var topics = topicService.GetLatestTopics(50L, 1L, true).OrderByDescending(x => x.Created);
}<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <atom:link href="@selfUrl" rel="self" type="application/rss+xml" />
        <title>@Model.Content.Name</title>
        @Html.Raw(string.Format("<link>{0}</link>", @baseUrl))
        <pubDate>@string.Format("{0:ddd, dd MMM yyyy} {0:HH:mm:ss zzz}", DateTime.Now)</pubDate>
        <generator>umbraco</generator>
        <description>Latests topics from the forum on our.umbraco.org</description>
        <language>en</language>
        @foreach (var topic in topics)
        {
            var bodyNoControlCharacters = new string(topic.Body.Where(c => !char.IsControl(c)).ToArray());
            <item>
                <title>@topic.Title</title>
                @Html.Raw(string.Format("<link>{0}{1}</link>", baseUrl, topic.GetUrl()))
                <guid isPermaLink="true">@string.Format("{0}{1}", baseUrl, topic.GetUrl())</guid>
                <description><![CDATA[@Umbraco.StripHtml(Umbraco.Truncate(bodyNoControlCharacters, 100, false))]]></description>
                <content:encoded><![CDATA[@topic.Body.Sanitize()]]></content:encoded>
                <dc:creator>@topic.AuthorName</dc:creator>
                <pubDate>@string.Format("{0:ddd, dd MMM yyyy} {0:HH:mm:ss zzz}", topic.Created)</pubDate>
            </item>
        }
    </channel>
</rss>