Esempio n. 1
0
        public async Task <ActionResult> ListHome(int pageIndex)
        {
            ViewBag.AppendTenantName = false;

            var siteSettings = await _siteSettingsService.Get();

            return(List(pageIndex, _postService.GetHomeList(), siteSettings.Seo, true));
        }
Esempio n. 2
0
        public void Index()
        {
            var list = _postService.GetHomeList();

            var tenantName  = _siteSettings.Name;
            var description = _siteSettings.Seo.Description;
            var url         = Request.Url;
            var link        = $"{url.Scheme}://{url.Authority}";

            var document = new XDocument(new XDeclaration("1.0", "utf-8", "false"));

            var rss = new XElement("rss");

            rss.SetAttributeValue("version", "2.0");

            document.Add(rss);

            var change = new XElement("channel",
                                      new XElement("title", tenantName),
                                      new XElement("link", link + Request.ApplicationPath),
                                      new XElement("description", description),
                                      new XElement("language", CultureInfo.CurrentCulture.EnglishName),
                                      //                new XElement("pubDate", "aaaaaa"),
                                      new XElement("lastBuildDate", DateTime.Now));

            rss.Add(change);

            foreach (var post in list)
            {
                var itemElement = new XElement("item",
                                               new XElement("title", post.Title),
                                               new XElement("description", post.Summary),
                                               new XElement("author", post.User.Name),
                                               new XElement("pubDate", post.CreateTime));

                var category = post.Categorys.FirstOrDefault();
                if (category != null)
                {
                    var categoryElement = new XElement("category", "asasd");
                    //            categoryElement.SetAttributeValue("domain", "http://www.fool.com/cusip");
                    itemElement.Add(categoryElement);
                }

                var routeValues = new RouteValueDictionary(new { area = "Rabbit.Blogs", post.Route.Path });
                routeValues.Add("CategoryRoutePath", category != null ? post.Route.Path : "unclassified");
                var postUrl = link + Url.Action("Detailed", "Post", routeValues);

                itemElement.Add(new XElement("link", postUrl));
                itemElement.Add(new XElement("comments", postUrl + "#comments"));
                itemElement.Add(new XElement("guid", postUrl));

                var sourceElement = new XElement("source", tenantName);
                sourceElement.SetAttributeValue("url", link);
                itemElement.Add(sourceElement);

                change.Add(itemElement);
            }

            document.Save(Response.OutputStream);

            Response.ContentType = "text/xml";
        }