コード例 #1
0
        public ActionResult Index()
        {
            string domain = DbConvention.GetBaseDomain(this.HttpContext, true);

            if (string.IsNullOrWhiteSpace(domain))
            {
                return(this.Failed("Could not generate sitemap.", HttpStatusCode.InternalServerError));
            }
            string siteMap = SiteMapGenerator.Get(domain);

            return(this.Content(siteMap, "text/xml", Encoding.UTF8));
        }
コード例 #2
0
ファイル: ContentSearch.cs プロジェクト: Zero-Xiong/frapid
        public List <SearchResultContent> Search(string query)
        {
            var    context = new HttpContextWrapper(HttpContext.Current);
            var    result  = DAL.Contents.Search(query);
            string domain  = DbConvention.GetBaseDomain(context, true);

            return(result.Select(item => new SearchResultContent
            {
                Title = item.Title,
                Contents = item.Contents.ToText().Truncate(200),
                LastUpdatedOn = item.LastEditedOn,
                LinkUrl = item.IsBlog ?
                          UrlHelper.CombineUrl(domain, "/blog/" + item.CategoryAlias + "/" + item.Alias)
                : UrlHelper.CombineUrl(domain, "/site/" + item.CategoryAlias + "/" + item.Alias)
            }).ToList());
        }
コード例 #3
0
        public static RssChannel GetRssChannel(HttpContextBase context, string categoryAlias, int pageNumber)
        {
            string title     = Configuration.Get("BlogTitle");
            string copyright = Configuration.Get("RssCopyrightText");
            int    ttl       = Configuration.Get("RssTtl").To <int>();
            int    limit     = Configuration.Get("RssPageSize").To <int>();
            int    offset    = (pageNumber - 1) * limit;

            List <PublishedContentView> contents;
            string category = string.Empty;

            if (!string.IsNullOrWhiteSpace(categoryAlias))
            {
                contents = Contents.GetBlogContents(categoryAlias, limit, offset).ToList();
                category = contents.Select(x => x.CategoryName).FirstOrDefault();
            }
            else
            {
                contents = Contents.GetBlogContents(limit, offset).ToList();
            }


            string domain = DbConvention.GetBaseDomain(context, true);

            var items = contents.Select(view => new RssItem
            {
                Title         = view.Title,
                Description   = view.Contents,
                Link          = UrlHelper.CombineUrl(domain, "/blog/" + view.CategoryAlias + "/" + view.Alias),
                Ttl           = ttl,
                Category      = view.CategoryName,
                PublishDate   = view.PublishOn,
                LastBuildDate = view.LastEditedOn
            }).ToList();

            var channel = new RssChannel
            {
                Title       = title,
                Description = "Category: " + category,
                Link        = UrlHelper.CombineUrl(domain, "/blog"),
                Items       = items,
                Copyright   = copyright,
                Category    = category
            };

            return(channel);
        }