Ejemplo n.º 1
0
        public async Task <IActionResult> Feed()
        {
            var feed = new Feed()
            {
                Title       = "Sascha Manns's Twilight Zone - English Feed",
                Description = "Blog about Linux, Windows (WSL, Insider), Programming (Ruby, Python, Java, Android ASP and Mono/.NET) and other random stuff",
                Link        = new Uri("https://saschamanns.de/feed"),
                Copyright   = "©" + " " + MyYear + " " + " Sascha Manns"
            };

            var license = @"<div>
        <div style=""float: left;"">
          <a rel=""license"" href=""https://creativecommons.org/licenses/by-sa/3.0/de/deed.en"">
            <img alt=""Creative Commons License"" style=""border-width: 0"" src=""https://i.creativecommons.org/l/by-sa/3.0/de/88x31.png"" /></a></div>
        <div>
          This work by <a xmlns:cc=""http://creativecommons.org/ns#"" href=""https://saschamanns.de""
            property=""cc:attributionName"" rel=""cc:attributionURL"">Sascha Manns</a> is
          licensed under a <a rel=""license"" href=""https://creativecommons.org/licenses/by-sa/3.0/de/deed.en/"">
            Attribution-ShareAlike 3.0 Germany License (CC BY-SA 3.0 DE)</a>.<br />
          Based on a work at <a xmlns:dct=""https://purl.org/dc/terms/"" href=""https://saschamanns.de""
            rel=""dct:source"">saschamanns.de</a>.</div>
        </div>";

            var ad      = "If you liked this article: " + _adService.InlineAdd();
            var entries = await _repo.GetStoriesByTag("en-US", 25, 1);

            foreach (var entry in entries.Stories)
            {
                var item = new Item()
                {
                    Title       = entry.Title,
                    Body        = string.Concat(entry.Body, license, ad), // Removed ad
                    Link        = new Uri(new Uri(Request.GetEncodedUrl()), entry.Slug),
                    Permalink   = new Uri(new Uri(Request.GetEncodedUrl()), entry.Slug).ToString(),
                    PublishDate = entry.DatePublished,
                    Author      = new Author()
                    {
                        Name = "Sascha Manns", Email = "*****@*****.**"
                    }
                };

                foreach (var cat in entry.Categories.Split(','))
                {
                    item.Categories.Add(cat);
                }
                feed.Items.Add(item);
            }

            return(File(Encoding.UTF8.GetBytes(feed.Serialize()), "text/xml"));
        }