Пример #1
0
        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            object value;

            if (values.TryGetValue(parameterName, out value))
            {
                var parameterValue = Convert.ToString(value);

                var path = FindPath(parameterValue);
                if (path == null)
                {
                    return(false);
                }

                var archiveData = FindArchiveData(parameterValue);
                if (archiveData == null)
                {
                    return(false);
                }

                return(_blogPathConstraint.FindPath(path) != null);
            }

            return(false);
        }
Пример #2
0
        protected override DriverResult Display(BlogArchivesPart part, string displayType, dynamic shapeHelper)
        {
            return(ContentShape("Parts_Blogs_BlogArchives",
                                () => {
                var path = _blogPathConstraint.FindPath(part.ForBlog);
                BlogPart blog = _blogService.Get(path);

                if (blog == null)
                {
                    return null;
                }

                return shapeHelper.Parts_Blogs_BlogArchives(ContentItem: part.ContentItem, Blog: blog, Archives: _blogPostService.GetArchives(blog));
            }));
        }
Пример #3
0
        public ActionResult Item(string blogPath, PagerParameters pagerParameters)
        {
            Pager pager         = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var   correctedPath = _blogPathConstraint.FindPath(blogPath);

            if (correctedPath == null)
            {
                return(HttpNotFound());
            }

            var blogPart = _blogService.Get(correctedPath);

            if (blogPart == null)
            {
                return(HttpNotFound());
            }

            // primary action run for a home paged item shall not pass
            if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext") &&
                blogPart.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage))
            {
                return(HttpNotFound());
            }

            _feedManager.Register(blogPart);
            var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
                            .Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
            dynamic blog = _services.ContentManager.BuildDisplay(blogPart);

            var list = Shape.List();

            list.AddRange(blogPosts);
            blog.Content.Add(Shape.Parts_Blogs_BlogPost_List(ContentItems: list), "5");

            var totalItemCount = _blogPostService.PostCount(blogPart);

            blog.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after");

            return(new ShapeResult(this, blog));
        }
        protected override DriverResult Display(RecentBlogPostsPart part, string displayType, dynamic shapeHelper)
        {
            var      path = _blogPathConstraint.FindPath(part.ForBlog);
            BlogPart blog = _blogService.Get(path);

            if (blog == null)
            {
                return(null);
            }

            var blogPosts = _contentManager.Query(VersionOptions.Published, "BlogPost")
                            .Join <CommonPartRecord>().Where(cr => cr.Container == blog.Record.ContentItemRecord)
                            .OrderByDescending(cr => cr.CreatedUtc)
                            .Slice(0, part.Count)
                            .Select(ci => ci.As <BlogPostPart>());

            var list = shapeHelper.List();

            list.AddRange(blogPosts.Select(bp => _contentManager.BuildDisplay(bp, "Summary")));

            var blogPostList = shapeHelper.Parts_Blogs_BlogPost_List(ContentPart: part, ContentItems: list);

            return(ContentShape(shapeHelper.Parts_Blogs_RecentBlogPosts(ContentItem: part.ContentItem, ContentItems: blogPostList)));
        }