Exemplo n.º 1
0
        public ActionResult Index(RenderModel model, int?maxItems)
        {
            if (!maxItems.HasValue)
            {
                maxItems = 25;
            }

            var listNodes = model.Content.Children
                            .Where(x => x.DocumentTypeAlias.InvariantEquals("ArticulateArchive"))
                            .ToArray();

            if (listNodes.Length == 0)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var pager = new PagerModel(maxItems.Value, 0, 1);

            var listNodeIds = listNodes.Select(x => x.Id).ToArray();

            var listItems = Umbraco.GetPostsSortedByPublishedDate(pager, null, listNodeIds);

            var rootPageModel = new ListModel(listNodes[0], listItems, pager);

            var feed = FeedGenerator.GetFeed(rootPageModel, rootPageModel.Children <PostModel>());

            return(new RssResult(feed, rootPageModel));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a list of the most recent posts
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="masterModel"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static IEnumerable <PostModel> GetRecentPosts(this UmbracoHelper helper, IMasterModel masterModel, int count)
        {
            var listNode = masterModel.RootBlogNode.Children
                           .FirstOrDefault(x => x.DocumentTypeAlias.InvariantEquals("ArticulateArchive"));

            if (listNode == null)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var rootPageModel = new ListModel(listNode, new PagerModel(count, 0, 1));

            return(rootPageModel.Children <PostModel>());
        }
Exemplo n.º 3
0
        public ActionResult Index(RenderModel model, int?maxItems)
        {
            if (!maxItems.HasValue)
            {
                maxItems = 25;
            }

            var listNode = model.Content.Children
                           .FirstOrDefault(x => x.DocumentTypeAlias.InvariantEquals("ArticulateArchive"));

            if (listNode == null)
            {
                throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document");
            }

            var rootPageModel = new ListModel(listNode, new PagerModel(maxItems.Value, 0, 1));

            var feed = GetFeed(rootPageModel, rootPageModel.Children <PostModel>());

            return(new RssResult(feed, rootPageModel));
        }