public virtual ActionResult Page(PageName page, PageModel model) { var entry = Repository.FindFirstOrDefault(new EntryByNameQuery(page)); if (entry == null) return RedirectToAction("Recent"); if (!ModelState.IsValid) { model.Entry = entry; model.Page = page; ViewData.Model = model; return new PageTemplateActionResult(entry.PageTemplate, "Page"); } var comment = entry.Entry.Value.Comment(); comment.AuthorEmail = model.CommenterEmail ?? string.Empty; comment.AuthorName = model.CommenterName ?? string.Empty; comment.AuthorUrl = model.CommenterBlog ?? string.Empty; comment.AuthorIp = Request.UserHostAddress; comment.EntryRevisionNumber = entry.LatestRevisionNumber; comment.Body = model.Comments; try { SpamChecker.Verify(comment); } catch (Exception ex) { HttpContext.Trace.Warn("Akismet is offline, comment cannot be validated: " + ex); } // Anything posted after the disable date is considered spam (the comment box shouldn't be visible anyway) var settings = SettingsProvider.GetSettings<FunnelWebSettings>(); if (settings.DisableCommentsOlderThan > 0 && DateTime.UtcNow.AddDays(settings.DisableCommentsOlderThan) > entry.Published) { comment.IsSpam = true; entry.Entry.Value.CommentCount = entry.Entry.Value.Comments.Count(c => !c.IsSpam); } EventPublisher.Publish(new CommentPostedEvent(entry.Entry.Value, comment)); return RedirectToAction("Page", new { page }) .AndFlash("Thanks, your comment has been posted."); }
public ActionResult Page(PageName page, int? revision) { if (revision != null && !SettingsProvider.GetSettings<FunnelWebSettings>().EnablePublicHistory) { return RedirectToAction("Page", "Wiki", new { page, revision = (int?)null }); } var entry = revision == null ? Repository.FindFirstOrDefault(new EntryByNameQuery(page)) : Repository.FindFirstOrDefault(new EntryByNameAndRevisionQuery(page, revision.Value)); if (entry == null) { return Thread.CurrentPrincipal.IsAuthenticated() ? RedirectToAction("Edit", "WikiAdmin", new { Area = "Admin", page }) : Search(page, true); } if (entry.Status == EntryStatus.Private && !Thread.CurrentPrincipal.IsAuthenticated()) { return Search(page, true); } var pageModel = new PageModel(page, entry); ClaimsPrincipal claimsPrincipal = Thread.CurrentPrincipal.AsClaimsPrincipal(); Claim claim; if (claimsPrincipal.TryFindFirstClaim(c => c.Type == ClaimTypes.Name, out claim)) { pageModel.CommenterName = claim.Value; } if (claimsPrincipal.TryFindFirstClaim(c => c.Type == ClaimTypes.Email, out claim)) { pageModel.CommenterEmail = claim.Value; } ViewData.Model = pageModel; return new PageTemplateActionResult(entry.PageTemplate); }