public PostSearchCriteriaViewModel(FrontMatterSearchCriteria entity)
 {
     From = entity.From.Value;
     Limit = entity.Limit;
     Offset = entity.Offset;
     Order = entity.Order.ToString().ToLower();
     To = entity.To.Value;
 }
예제 #2
0
        public PageOfPostsViewModel Get(int limit = SearchCriteria.DefaultLimit, int offset = SearchCriteria.DefaultOffset, string order = "descending")
        {
            var from = FrontMatterSearchCriteria.DefaultFrom;
            var to = FrontMatterSearchCriteria.DefaultTo;
            var orderParsed = SearchCriteria.DefaultOrder;
            Enum.TryParse<Order>(order, true, out orderParsed);
            var searchCriteria = new FrontMatterSearchCriteria(limit, offset, orderParsed, PostPath, from, to, string.Empty, true);
            var pageOfPost = FrontMatterRepository.Get(searchCriteria);

            var pageOfPostViewModel = new PageOfPostsViewModel(pageOfPost, MarkupProcessorFactory);

            return pageOfPostViewModel;
        }
예제 #3
0
        public ActionResult Atom()
        {
            var config = ConfigRepository.Read(ConfigPath);
            var configViewModel = new ConfigurationViewModel(config);

            var postSearchCriteria = new FrontMatterSearchCriteria(10, 0, Order.Descending, PostPath, FrontMatterSearchCriteria.DefaultFrom, FrontMatterSearchCriteria.DefaultTo, string.Empty, true);
            var pageOfPosts = FrontMatterRepository.Get(postSearchCriteria);
            var pageOfPostsViewModel = new PageOfPostsViewModel(pageOfPosts, MarkupProcessorFactory);

            var layoutViewModel = new LayoutViewModel();

            var homeViewModel = new HomeViewModel(configViewModel, layoutViewModel, pageOfPostsViewModel);

            return new AtomViewResult(homeViewModel);
        }
예제 #4
0
        public ActionResult Get(int limit = 10, int offset = 0)
        {
            var config = ConfigRepository.Read(ConfigPath);
            var configViewModel = new ConfigurationViewModel(config);

            var searchCriteria = new FrontMatterSearchCriteria(limit, offset, Domain.Common.Order.Descending, PostPath, FrontMatterSearchCriteria.DefaultFrom, FrontMatterSearchCriteria.DefaultTo, string.Empty, true);
            var pageOfPosts = FrontMatterRepository.Get(searchCriteria);
            var pageOfPostViewModel = new PageOfPostsViewModel(pageOfPosts, MarkupProcessorFactory);

            var layoutPath = GetLayoutPath("home");
            var layout = LayoutParser.Parse(layoutPath);
            var layoutViewModel = new LayoutViewModel(layout);

            var homeViewModel = new HomeViewModel(configViewModel, layoutViewModel, pageOfPostViewModel);

            return View(homeViewModel);
        }
예제 #5
0
        public virtual PageOf<IFrontMatter, FrontMatterSearchCriteria> Get(FrontMatterSearchCriteria searchCriteria)
        {
            var entities = new List<IFrontMatter>() as IEnumerable<IFrontMatter>;

            entities = GetAllFrontMatterFiles(searchCriteria.Path);

            //Filter
            entities = entities.Where(p => p.Published.Equals(searchCriteria.Published));

            if (searchCriteria.From.HasValue)
            {
                entities = entities.Where(p => p.DateTime.HasValue && p.DateTime >= searchCriteria.From);
            }

            if (searchCriteria.To.HasValue)
            {
                entities = entities.Where(p => p.DateTime.HasValue && p.DateTime <= searchCriteria.To);
            }

            if (!string.IsNullOrWhiteSpace(searchCriteria.Permalink))
            {
                entities = entities.Where(e => e.Permalinks.Any(p => p.Equals(searchCriteria.Permalink, StringComparison.OrdinalIgnoreCase)));
            }

            var totalCount = entities.Count();

            //Cut
            if (searchCriteria.Order == Order.Ascending)
            {
                entities = entities.OrderBy(e => e.DateTime).ThenBy(e => e.Title);
            }
            else
            {
                entities = entities.OrderByDescending(e => e.DateTime).ThenByDescending(e => e.Title);
            }

            entities = entities.Count() > searchCriteria.Offset ? entities.Skip(searchCriteria.Offset).Take(searchCriteria.Limit) : new List<IFrontMatter>();

            return new PageOf<IFrontMatter, FrontMatterSearchCriteria>(searchCriteria, entities, totalCount);
        }
예제 #6
0
        public virtual PageOf <IFrontMatter, FrontMatterSearchCriteria> Get(FrontMatterSearchCriteria searchCriteria)
        {
            var entities = new List <IFrontMatter>() as IEnumerable <IFrontMatter>;

            entities = GetAllFrontMatterFiles(searchCriteria.Path);

            //Filter
            entities = entities.Where(p => p.Published.Equals(searchCriteria.Published));

            if (searchCriteria.From.HasValue)
            {
                entities = entities.Where(p => p.DateTime.HasValue && p.DateTime >= searchCriteria.From);
            }

            if (searchCriteria.To.HasValue)
            {
                entities = entities.Where(p => p.DateTime.HasValue && p.DateTime <= searchCriteria.To);
            }

            if (!string.IsNullOrWhiteSpace(searchCriteria.Permalink))
            {
                entities = entities.Where(e => e.Permalinks.Any(p => p.Equals(searchCriteria.Permalink, StringComparison.OrdinalIgnoreCase)));
            }

            var totalCount = entities.Count();

            //Cut
            if (searchCriteria.Order == Order.Ascending)
            {
                entities = entities.OrderBy(e => e.DateTime).ThenBy(e => e.Title);
            }
            else
            {
                entities = entities.OrderByDescending(e => e.DateTime).ThenByDescending(e => e.Title);
            }

            entities = entities.Count() > searchCriteria.Offset ? entities.Skip(searchCriteria.Offset).Take(searchCriteria.Limit) : new List <IFrontMatter>();

            return(new PageOf <IFrontMatter, FrontMatterSearchCriteria>(searchCriteria, entities, totalCount));
        }
예제 #7
0
 private bool IsPost(string url)
 {
     var searchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Descending, PostPath, FrontMatterSearchCriteria.DefaultFrom, FrontMatterSearchCriteria.DefaultTo, url, true);
     var pageOf = FrontMatterRepository.Get(searchCriteria);
     return pageOf.Entities.Any();
 }
예제 #8
0
 private bool IsPage(string url)
 {
     var searchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Ascending, SitePath, null, null, url, true);
     var pageOf = FrontMatterRepository.Get(searchCriteria);
     return pageOf.Entities.Any();
 }
예제 #9
0
        private ActionResult GetPost(string url)
        {
            var config = ConfigRepository.Read(ConfigPath);
            var configViewModel = new ConfigurationViewModel(config);

            var postSearchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Descending, PostPath, FrontMatterSearchCriteria.DefaultFrom, FrontMatterSearchCriteria.DefaultTo, url, true);
            var pageOfPost = FrontMatterRepository.Get(postSearchCriteria);
            var post = pageOfPost.Entities.First();
            var postViewModel = new PostViewModel(post, MarkupProcessorFactory);

            var layoutPath = GetLayoutPath(post.Layout);
            var layout = LayoutParser.Parse(layoutPath);
            var layoutViewModel = new LayoutViewModel(layout);

            var pageOfPostViewModel = new PageOfPostViewModel(configViewModel, layoutViewModel, postViewModel);

            return View("Post", pageOfPostViewModel);
        }
예제 #10
0
        private ActionResult GetPage(string url)
        {
            var config = ConfigRepository.Read(ConfigPath);
            var configViewModel = new ConfigurationViewModel(config);

            var searchCriteria = new FrontMatterSearchCriteria(1, 0, Order.Ascending, SitePath, null, null, url, true);
            var pageOfPages = FrontMatterRepository.Get(searchCriteria);
            var frontMatter = pageOfPages.Entities.First();
            var frontMatterContentViewModel = new ContentViewModel(frontMatter, MarkupProcessorFactory);

            var layoutPath = GetLayoutPath(frontMatter.Layout);
            var layout = LayoutParser.Parse(layoutPath);
            var layoutViewModel = new LayoutViewModel(layout);

            var pageOfFrontMatterContentViewModel = new PageOfContentViewModel(configViewModel, layoutViewModel, frontMatterContentViewModel);

            return View("Default", pageOfFrontMatterContentViewModel);
        }