public IActionResult Search(string searchText)
        {
            var lpvm    = new ListPostsViewModel();
            var entries = blogManager.SearchEntries(WebUtility.HtmlEncode(searchText), Request.Headers["Accept-Language"])?.Where(e => e.IsPublic)?.ToList();

            if (entries != null)
            {
                lpvm.Posts = entries.Select(entry => mapper.Map <PostViewModel>(entry)).ToList();

                return(View(BLOG_PAGE, lpvm));
            }

            return(RedirectToAction("index", "home"));
        }
Example #2
0
        private ListPostsViewModel EditContentDescription(ListPostsViewModel listPostsViewModel)
        {
            if (dasBlogSettings.SiteConfiguration.ShowItemDescriptionInAggregatedViews)
            {
                if (listPostsViewModel != null && listPostsViewModel.Posts != null)
                {
                    foreach (var post in listPostsViewModel.Posts)
                    {
                        post.Content = post.Description;
                    }
                }
            }

            return(listPostsViewModel);
        }
Example #3
0
        public IActionResult Post(string posttitle, string day, string month, string year)
        {
            var      lpvm       = new ListPostsViewModel();
            DateTime postDtTime = DateTime.MinValue;
            int      dayYear    = 0;

            if (dasBlogSettings.SiteConfiguration.EnableTitlePermaLinkUnique)
            {
                dayYear = Convert.ToInt32(string.Format("{0}{1}{2}", year, month, day));
            }

            var routeAffectedFunctions = new RouteAffectedFunctions(dasBlogSettings.SiteConfiguration.EnableTitlePermaLinkUnique);

            if (!routeAffectedFunctions.IsValidDay(dayYear))
            {
                return(NotFound());
            }

            var dt = routeAffectedFunctions.ConvertDayToDate(dayYear);

            if (routeAffectedFunctions.IsSpecificPostRequested(posttitle, dayYear))
            {
                var entry = blogManager.GetBlogPost(posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement, string.Empty), dt);
                if (entry != null)
                {
                    var pvm = mapper.Map <PostViewModel>(entry);

                    if (httpContextAccessor.HttpContext.Request.Path.Value.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
                    {
                        return(RedirectPermanent(pvm.PermaLink));
                    }

                    lpvm.Posts = new List <PostViewModel>()
                    {
                        pvm
                    };
                    return(SinglePostView(lpvm));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(RedirectToAction("index", "home"));
            }
        }
Example #4
0
        public IActionResult Comment(string posttitle, string day, string month, string year)
        {
            ListPostsViewModel lpvm = null;

            NBR.Entry entry    = null;
            var       postguid = Guid.Empty;

            var uniquelinkdate = ValidateUniquePostDate(year, month, day);

            entry = blogManager.GetBlogPost(posttitle, uniquelinkdate);

            if (entry == null && Guid.TryParse(posttitle, out postguid))
            {
                entry = blogManager.GetBlogPostByGuid(postguid);

                var pvm = mapper.Map <PostViewModel>(entry);

                return(RedirectPermanent(dasBlogSettings.GetCommentViewUrl(pvm.PermaLink)));
            }

            if (entry != null)
            {
                lpvm = new ListPostsViewModel
                {
                    Posts = new List <PostViewModel> {
                        mapper.Map <PostViewModel>(entry)
                    }
                };

                if (dasBlogSettings.SiteConfiguration.EnableComments)
                {
                    var lcvm = new ListCommentsViewModel
                    {
                        Comments = blogManager.GetComments(entry.EntryId, false)
                                   .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(),
                        PostId        = entry.EntryId,
                        PostDate      = entry.CreatedUtc,
                        CommentUrl    = dasBlogSettings.GetCommentViewUrl(posttitle),
                        ShowComments  = true,
                        AllowComments = entry.AllowComments
                    };

                    lpvm.Posts.First().Comments = lcvm;
                }
            }

            return(SinglePostView(lpvm));
        }
Example #5
0
        protected ViewResult AggregatePostView(ListPostsViewModel listPostsViewModel)
        {
            DefaultPage();

            if (dasBlogSettings.SiteConfiguration.ShowItemDescriptionInAggregatedViews)
            {
                listPostsViewModel = EditContentDescription(listPostsViewModel);
            }

            if (dasBlogSettings.SiteConfiguration.ShowItemSummaryInAggregatedViews)
            {
                return(View(BLOG_PAGESUMMARY, listPostsViewModel));
            }

            return(View(BLOG_PAGE, listPostsViewModel));
        }
        public IActionResult GetCategory(string category)
        {
            if (string.IsNullOrEmpty(category))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var lpvm = new ListPostsViewModel();

            lpvm.Posts = categoryManager.GetEntries(category, httpContextAccessor.HttpContext.Request.Headers["Accept-Language"])
                         .Select(entry => mapper.Map <PostViewModel>(entry)).ToList();

            DefaultPage();

            return(View(BLOG_PAGE, lpvm));
        }
        public IActionResult Comment(Guid postid)
        {
            // ~/CommentView.aspx?title=GeneralPatternsusedtoDetectaLeak

            // Get post by GUID bbecae4b-e3a3-47a2-b6a6-b4cc405f8663
            Entry entry = _blogRepository.GetBlogPost(postid.ToString());

            ListPostsViewModel lpvm = new ListPostsViewModel();

            lpvm.Posts = new List <PostViewModel> {
                _mapper.Map <PostViewModel>(entry)
            };

            SinglePost(lpvm.Posts.First());

            return(ThemedView("Page", lpvm));
        }
        public ActionResult MicroSummary()
        {
            if (!memoryCache.TryGetValue(CACHEKEY_FRONTPAGE, out ListPostsViewModel lpvm))
            {
                lpvm = new ListPostsViewModel
                {
                    Posts = blogManager.GetFrontPagePosts(Request.Headers["Accept-Language"])
                            .Select(entry => mapper.Map <PostViewModel>(entry))
                            .Select(editentry => editentry).ToList()
                };

                memoryCache.Set(CACHEKEY_FRONTPAGE, lpvm, SiteCacheSettings());
            }
            ;

            return(Ok(lpvm?.Posts.FirstOrDefault()?.Title));
        }
        private ListPostsViewModel AddComments(ListPostsViewModel listPostsViewModel)
        {
            foreach (var post in listPostsViewModel.Posts)
            {
                var lcvm = new ListCommentsViewModel
                {
                    Comments = blogManager.GetComments(post.EntryId, false)
                               .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(),
                    PostId     = post.EntryId,
                    PostDate   = post.CreatedDateTime,
                    CommentUrl = dasBlogSettings.GetCommentViewUrl(post.PermaLink)
                };
                post.Comments = lcvm;
            }

            return(listPostsViewModel);
        }
        public IActionResult Search(string searchText)
        {
            var lpvm    = new ListPostsViewModel();
            var entries = blogManager.SearchEntries(WebUtility.HtmlEncode(searchText), Request.Headers["Accept-Language"])?.Where(e => e.IsPublic)?.ToList();

            if (entries != null)
            {
                lpvm.Posts = entries.Select(entry => mapper.Map <PostViewModel>(entry)).ToList();
                ViewData[Constants.ShowPageControl] = false;

                logger.LogInformation(new EventDataItem(EventCodes.Search, null, "Search request: '{0}'", searchText));

                return(View(BLOG_PAGE, lpvm));
            }

            return(RedirectToAction("index", "home"));
        }
Example #11
0
        public IActionResult Index()
        {
            var lpvm = new ListPostsViewModel
            {
                Posts = blogManager.GetFrontPagePosts(Request.Headers["Accept-Language"])
                        .Select(entry => mapper.Map <PostViewModel>(entry)).
                        Select(editentry => editentry).ToList()
            };

            ViewData[Constants.ShowPageControl] = true;
            ViewData[Constants.PageNumber]      = 0;
            ViewData[Constants.PostCount]       = lpvm.Posts.Count;

            logger.LogDebug($"In Index - {lpvm.Posts.Count} post found");

            return(AggregatePostView(lpvm));
        }
Example #12
0
        public IActionResult Page(int index)
        {
            if (index == 0)
            {
                return(Index());
            }

            ViewData["Message"] = string.Format("Page...{0}", index);

            var lpvm = new ListPostsViewModel
            {
                Posts = blogManager.GetEntriesForPage(index, Request.Headers["Accept-Language"])
                        .Select(entry => mapper.Map <PostViewModel>(entry)).ToList()
            };

            return(AggregatePostView(lpvm));
        }
Example #13
0
        public IActionResult Page(int index)
        {
            if (index == 0)
            {
                return(Index());
            }

            ViewData["Message"] = string.Format("Page...{0}", index);

            ListPostsViewModel lpvm = new ListPostsViewModel();

            lpvm.Posts = _blogManager.GetEntriesForPage(index, Request.Headers["Accept-Language"])
                         .Select(entry => _mapper.Map <PostViewModel>(entry)).ToList();

            DefaultPage();

            return(View("Page", lpvm));
        }
Example #14
0
        public IActionResult Page(int index)
        {
            if (index == 0)
            {
                return(Index());
            }

            ViewData["Message"] = string.Format("Page...{0}", index);

            ListPostsViewModel lpvm = new ListPostsViewModel();

            lpvm.Posts = _blogRepository.GetEntriesForPage(index)
                         .Select(entry => _mapper.Map <PostViewModel>(entry)).ToList();

            DefaultPage();

            return(ThemedView("Page", lpvm));
        }
        public IActionResult Index(string slug = "")
        {
            //var remoteIpAddress = this.Request.HttpContext.Connection.RemoteIpAddress;
            List <Post> posts;

            if (string.IsNullOrWhiteSpace(slug))
            {
                posts = this.postRepository.GetAllPublished();
            }
            else
            {
                var tag = this.tagRepository.GetBySlug(slug);
                posts = this.postRepository.GetAllPublished(tag);
            }
            var viewModel = new ListPostsViewModel(posts);

            return(View(viewModel));
        }
Example #16
0
        public IActionResult CommentError(AddCommentViewModel comment, List <string> errors)
        {
            ListPostsViewModel lpvm = null;

            NBR.Entry entry    = null;
            var       postguid = Guid.Parse(comment.TargetEntryId);

            entry = blogManager.GetBlogPostByGuid(postguid);
            if (entry != null)
            {
                lpvm = new ListPostsViewModel
                {
                    Posts = new List <PostViewModel> {
                        mapper.Map <PostViewModel>(entry)
                    }
                };

                if (dasBlogSettings.SiteConfiguration.EnableComments)
                {
                    var lcvm = new ListCommentsViewModel
                    {
                        Comments = blogManager.GetComments(entry.EntryId, false)
                                   .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(),
                        PostId        = entry.EntryId,
                        PostDate      = entry.CreatedUtc,
                        CommentUrl    = dasBlogSettings.GetCommentViewUrl(comment.TargetEntryId),
                        ShowComments  = true,
                        AllowComments = entry.AllowComments
                    };

                    if (comment != null)
                    {
                        lcvm.CurrentComment = comment;
                    }
                    lpvm.Posts.First().Comments = lcvm;
                    if (errors != null && errors.Count > 0)
                    {
                        lpvm.Posts.First().ErrorMessages = errors;
                    }
                }
            }

            return(SinglePostView(lpvm));
        }
        public IActionResult PostGuid(Guid postid)
        {
            var lpvm  = new ListPostsViewModel();
            var entry = blogManager.GetBlogPostByGuid(postid);

            if (entry != null)
            {
                lpvm.Posts = new List <PostViewModel>()
                {
                    mapper.Map <PostViewModel>(entry)
                };

                return(SinglePostView(lpvm));
            }
            else
            {
                return(NotFound());
            }
        }
Example #18
0
        public ActionResult Index(int page = 1)
        {
            var viewModel = new ListPostsViewModel
            {
                ListaPosts = _postsServicio
                             .Posts()
                             .Select(m => new PostItemManagmentViewModel
                {
                    Slug    = m.Slug,
                    Title   = m.Title,
                    Id      = m.Id,
                    TagList = m.Tags
                })
                             .OrderByDescending(m => m.Id)
                             .ToPagedList(page, pageSize: 100)
            };


            return(View(viewModel));
        }
Example #19
0
        public IActionResult Page(int index)
        {
            if (index == 0)
            {
                return(Index());
            }


            var lpvm = new ListPostsViewModel
            {
                Posts = blogManager.GetEntriesForPage(index, Request.Headers["Accept-Language"])
                        .Select(entry => mapper.Map <PostViewModel>(entry)).ToList()
            };

            ViewData["Message"] = string.Format("Page...{0}", index);
            ViewData[Constants.ShowPageControl] = true;
            ViewData[Constants.PageNumber]      = index;
            ViewData[Constants.PostCount]       = lpvm.Posts.Count;

            return(AggregatePostView(lpvm));
        }
Example #20
0
        public IActionResult PostGuid(Guid postid)
        {
            var lpvm  = new ListPostsViewModel();
            var entry = blogManager.GetBlogPost(postid.ToString(), null);

            if (entry != null)
            {
                lpvm.Posts = new List <PostViewModel>()
                {
                    mapper.Map <PostViewModel>(entry)
                };

                SinglePost(lpvm.Posts.First());

                return(View("Page", lpvm));
            }
            else
            {
                return(NotFound());
            }
        }
Example #21
0
        public IActionResult Post(string posttitle, string day, string month, string year)
        {
            var lpvm = new ListPostsViewModel();

            var uniquelinkdate = ValidateUniquePostDate(year, month, day);

            var entry = blogManager.GetBlogPost(posttitle, uniquelinkdate);

            if (entry != null)
            {
                var pvm = mapper.Map <PostViewModel>(entry);

                var lcvm = new ListCommentsViewModel
                {
                    Comments = blogManager.GetComments(entry.EntryId, false)
                               .Select(comment => mapper.Map <CommentViewModel>(comment)).ToList(),
                    PostId        = entry.EntryId,
                    PostDate      = entry.CreatedUtc,
                    CommentUrl    = dasBlogSettings.GetCommentViewUrl(posttitle),
                    ShowComments  = dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry,
                    AllowComments = entry.AllowComments
                };
                pvm.Comments = lcvm;

                if (!dasBlogSettings.SiteConfiguration.UseAspxExtension && httpContextAccessor.HttpContext.Request.Path.Value.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
                {
                    return(RedirectPermanent(pvm.PermaLink));
                }

                lpvm.Posts = new List <PostViewModel>()
                {
                    pvm
                };
                return(SinglePostView(lpvm));
            }
            else
            {
                return(RedirectToAction("index", "home"));
            }
        }
Example #22
0
        public IActionResult Index()
        {
            ListPostsViewModel lpvm = new ListPostsViewModel();

            lpvm.Posts = _blogRepository.GetFrontPagePosts()
                         .Select(entry => new PostViewModel
            {
                Author          = entry.Author,
                Content         = entry.Content,
                Categories      = entry.Categories,
                Description     = entry.Description,
                EntryId         = entry.EntryId,
                AllowComments   = entry.AllowComments,
                IsPublic        = entry.IsPublic,
                PermaLink       = entry.Link,
                Title           = entry.Title,
                CreatedDateTime = entry.CreatedLocalTime
            }).ToList();
            DefaultPage();

            return(ThemedView("Page", lpvm));
        }
Example #23
0
        public IActionResult Post(string posttitle)
        {
            ListPostsViewModel lpvm = new ListPostsViewModel();

            if (!string.IsNullOrEmpty(posttitle))
            {
                var entry = _blogRepository.GetBlogPost(posttitle);
                if (entry != null)
                {
                    lpvm.Posts = new List <PostViewModel>()
                    {
                        new PostViewModel {
                            Author          = entry.Author,
                            Content         = entry.Content,
                            Categories      = entry.Categories,
                            Description     = entry.Description,
                            EntryId         = entry.EntryId,
                            AllowComments   = entry.AllowComments,
                            IsPublic        = entry.IsPublic,
                            PermaLink       = entry.Link,
                            Title           = entry.Title,
                            CreatedDateTime = entry.CreatedLocalTime
                        }
                    };

                    SinglePost(lpvm.Posts.First());

                    return(ThemedView("Page", lpvm));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(Index());
            }
        }
Example #24
0
        public IActionResult Index()
        {
            if (!memoryCache.TryGetValue(CACHEKEY_FRONTPAGE, out ListPostsViewModel lpvm))
            {
                lpvm = new ListPostsViewModel
                {
                    Posts = blogManager.GetFrontPagePosts(Request.Headers["Accept-Language"])
                            .Select(entry => mapper.Map <PostViewModel>(entry))
                            .Select(editentry => editentry).ToList()
                };

                memoryCache.Set(CACHEKEY_FRONTPAGE, lpvm, SiteCacheSettings());

                logger.LogDebug($"In Index - {lpvm.Posts.Count} post found");
            }

            ViewData[Constants.ShowPageControl] = true;
            ViewData[Constants.PageNumber]      = 0;
            ViewData[Constants.PostCount]       = lpvm.Posts.Count;

            return(AggregatePostView(lpvm));
        }
Example #25
0
        public IActionResult Post(string posttitle, int day)
        {
            ListPostsViewModel     lpvm = new ListPostsViewModel();
            RouteAffectedFunctions routeAffectedFunctions = new RouteAffectedFunctions(
                dasBlogSettings.SiteConfiguration.EnableTitlePermaLinkUnique);

            if (!routeAffectedFunctions.IsValidDay(day))
            {
                return(NotFound());
            }

            DateTime?dt = routeAffectedFunctions.ConvertDayToDate(day);

            if (routeAffectedFunctions.IsSpecificPostRequested(posttitle, day))
            {
                var entry = blogManager.GetBlogPost(posttitle.Replace(dasBlogSettings.SiteConfiguration.TitlePermalinkSpaceReplacement,
                                                                      string.Empty), dt);
                if (entry != null)
                {
                    lpvm.Posts = new List <PostViewModel>()
                    {
                        mapper.Map <PostViewModel>(entry)
                    };

                    SinglePost(lpvm.Posts.First());

                    return(View("Page", lpvm));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(RedirectToAction("index", "home"));
            }
        }
Example #26
0
		protected ViewResult ThemedView(string view, ListPostsViewModel listpostsviewmodel)
		{
			return View(string.Format("/Themes/{0}/{1}.cshtml",
						_dasBlogSettings.SiteConfiguration.Theme, view), listpostsviewmodel);
		}
Example #27
0
 public ActionResult Index()
 {
     _model = new ListPostsViewModel(_storage);
     return(View(_model));
 }
Example #28
0
 protected ViewResult SinglePostView(ListPostsViewModel listPostsViewModel)
 {
     SinglePost(listPostsViewModel?.Posts?.First());
     ViewData[Constants.ShowPageControl] = false;
     return(View(BLOG_PAGE, listPostsViewModel));
 }
Example #29
0
        protected ViewResult SinglePostView(ListPostsViewModel listPostsViewModel)
        {
            SinglePost(listPostsViewModel?.Posts?.First());

            return(View(BLOG_PAGE, listPostsViewModel));
        }
 //TODO: Maybe a helper or base class?
 private ViewResult ThemedView(string v, ListPostsViewModel lpvm)
 {
     return(View(string.Format("/Themes/{0}/{1}.cshtml",
                               _dasBlogSettings.SiteConfiguration.Theme, v), lpvm));
 }