public ActionResult Index(string pageUrl, string status) { var pages = GetPages(); var page = pages.SingleOrDefault(p => p.PostUrl == pageUrl && p.EntryType == 2); if (page == null) { throw new UrlNotFoundException("Unable to find a page w/ the url {0}", pageUrl); } if (page.IsPrivate) { page.PostTitle = string.Format("[Private] {0}", page.PostTitle); } if (!Request.IsAuthenticated && status == "comment-posted") { var recentPage = _postRepository.GetPostByUrl(pageUrl, 2); page.Comments = recentPage.Comments; } var model = new ViewPostOrPageModel { Post = page, BlogSharingEnabled = SettingsRepository.BlogSocialSharing, SharingType = SettingsRepository.BlogSocialSharingChoice, UserCanEdit = Request.IsAuthenticated && GetUserId() == 1, BlogName = SettingsRepository.BlogName, BlogCaption = SettingsRepository.BlogCaption, CommentEntity = GetCommentEntityByAuth(), DisqusEnabled = SettingsRepository.DisqusEnabled, DisqusUrl = GetRootUrl().TrimEnd('/') + Url.RouteUrl("Pages", new { pageUrl = page.PostUrl }), ShortName = SettingsRepository.BlogDisqusShortName, DisqusDevMode = System.Web.HttpContext.Current.IsDebuggingEnabled }; return View(model); }
// // GET: /2011/12/some-url public ActionResult View(string year, string month, string url, string status) { var allPosts = GetPostsInternal(); var currentPost = allPosts.SingleOrDefault(p => p.PostUrl == url && p.EntryType == 1); if (currentPost == null) { throw new UrlNotFoundException("Unable to find a post w/ the url {0} for the month {1} and year {2}", url, month, year); } var index = allPosts.IndexOf(currentPost); if (!Request.IsAuthenticated && status == "comment-posted") { var recentPost = _postRepository.GetPostByUrl(url, 1); currentPost.Comments = recentPost.Comments; } var model = new ViewPostOrPageModel { Post = currentPost, BlogSharingEnabled = SettingsRepository.BlogSocialSharing, SharingType = SettingsRepository.BlogSocialSharingChoice, PreviousPost = index == 0 || index < 0 ? null : allPosts[index - 1], NextPost = index == (allPosts.Count - 1) || index < 0 ? null : allPosts[index + 1], UserCanEdit = Request.IsAuthenticated && (currentPost.OwnerUserID == GetUserId() || User.IsInRole("SuperAdmin")), BlogName = SettingsRepository.BlogName, BlogCaption = SettingsRepository.BlogCaption, CommentEntity = GetCommentEntityByAuth(), DisqusEnabled = SettingsRepository.DisqusEnabled, DisqusUrl = GetRootUrl().TrimEnd('/') + Url.RouteUrl("IndividualPost", new { year = currentPost.PostAddedDate.Year.ToString(), month = currentPost.PostMonth, url = currentPost.PostUrl }), ShortName = SettingsRepository.BlogDisqusShortName, DisqusDevMode = System.Web.HttpContext.Current.IsDebuggingEnabled }; return View(model); }
public ActionResult Index(string pageUrl, string status) { var pages = GetPages(); var page = pages.SingleOrDefault(p => p.PostUrl == pageUrl && p.EntryType == 2); if (page == null) { throw new UrlNotFoundException("Unable to find a page w/ the url {0}", pageUrl); } if (page.IsPrivate) { page.PostTitle = string.Format("[Private] {0}", page.PostTitle); } if (!Request.IsAuthenticated && status == "comment-posted") { var recentPage = _postRepository.GetPostByUrl(pageUrl, 2); page.Comments = recentPage.Comments; } var model = new ViewPostOrPageModel { Post = page, BlogSharingEnabled = SettingsRepository.BlogSocialSharing, SharingType = SettingsRepository.BlogSocialSharingChoice, UserCanEdit = Request.IsAuthenticated && GetUserId() == 1, BlogName = SettingsRepository.BlogName, BlogCaption = SettingsRepository.BlogCaption, CommentEntity = GetCommentEntityByAuth() }; return View(model); }
// // GET: /2011/12/some-url public ActionResult View(string year, string month, string url, string status) { var allPosts = GetPostsInternal(); var currentPost = allPosts.SingleOrDefault(p => p.PostUrl == url && p.EntryType == 1); if (currentPost == null) { throw new UrlNotFoundException("Unable to find a post w/ the url {0} for the month {1} and year {2}", url, month, year); } var index = allPosts.IndexOf(currentPost); if (!Request.IsAuthenticated && status == "comment-posted") { var recentPost = _postRepository.GetPostByUrl(url, 1); currentPost.Comments = recentPost.Comments; } var model = new ViewPostOrPageModel { Post = currentPost, BlogSharingEnabled = SettingsRepository.BlogSocialSharing, SharingType = SettingsRepository.BlogSocialSharingChoice, PreviousPost = index == 0 || index < 0 ? null : allPosts[index - 1], NextPost = index == (allPosts.Count - 1) || index < 0 ? null : allPosts[index + 1], UserCanEdit = Request.IsAuthenticated && (currentPost.OwnerUserID == GetUserId() || GetUserId() == 1), BlogName = SettingsRepository.BlogName, BlogCaption = SettingsRepository.BlogCaption, CommentEntity = GetCommentEntityByAuth() }; return View(model); }