Exemple #1
0
        public async Task<ActionResult> added()
        {
            var builds = Build.Select().OrderByDescending(b => b.Added).Take(20);

            RssDocument rdoc = new RssDocument()
            {
                Channel = new RssChannel()
                {
                    Title = "BuildFeed RSS - Recently Added",
                    Description = "",
                    Generator = "BuildFeed.net RSS Controller",
                    Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
                    SkipHours = new List<Hour>(),
                    SkipDays = new List<Day>(),

                    Items = (from build in builds
                             select new RssItem()
                             {
                                 Title = build.FullBuildString,
                                 Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
                                 Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
                                                      },
                                 InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
                             }).ToList()
                }
            };

            Response.ContentType = "application/rss+xml";

            await Response.Output.WriteAsync(rdoc.ToXml());

            return new EmptyResult();
        }
Exemple #2
0
        public async Task<ActionResult> index()
        {
            var builds = Build.SelectInBuildOrder().Take(20);

            RssDocument rdoc = new RssDocument()
            {
                Channel = new RssChannel()
                {
                    Title = "BuildFeed RSS - Recently Compiled",
                    Description = "",
                    Generator = "BuildFeed.net RSS Controller",
                    Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
                    SkipHours = new List<Hour>(),
                    SkipDays = new List<Day>(),

                    Items = (from build in builds
                             select new RssItem()
                             {
                                 Title = build.FullBuildString,
                                 Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
                                 Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
                             }).ToList()
                }
            };

            Response.ContentType = "application/rss+xml";

            await Response.Output.WriteAsync(rdoc.ToXml());

            return new EmptyResult();
        }
Exemple #3
0
        public static void WriteRSS(RssDocument value, Stream destination)
        {
            var xsn = new XmlSerializerNamespaces();

            xsn.Add("atom", "http://www.w3.org/2005/Atom");
            xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
            xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

            var ser = new XmlSerializer(value.GetType());

            ser.Serialize(destination, value, xsn);
        }
Exemple #4
0
        /// <summary>
        /// Render RSS to XML
        /// </summary>
        /// <returns></returns>
        public string ToXml()
        {
            var ms = new MemoryStream();

            RssDocument.WriteRSS(this, ms);

            //var xml = Encoding.UTF8.GetString(ms.GetBuffer()).Trim('\0');
            System.ArraySegment <byte> buffer;
            var xml = String.Empty;

            if (ms.TryGetBuffer(out buffer))
            {
                xml = Encoding.UTF8.GetString(buffer.Array).Trim('\0');
            }

            return(xml);
        }
Exemple #5
0
        public static void WriteRSS(RssDocument value, Stream destination)
        {
            var xsn = new XmlSerializerNamespaces();
            xsn.Add("atom", "http://www.w3.org/2005/Atom");
            xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
            xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

            var ser = new XmlSerializer(value.GetType());
            ser.Serialize(destination, value, xsn);
        }