/src/Views/Blog/Comments.cshtml

https://github.com/madskristensen/Miniblog.Core · Razor · 73 lines · 60 code · 12 blank · 1 comment · 2 complexity · d3da7607b7b3c9a6a3f9d0ae3de55764 MD5 · raw file

  1. @model Post
  2. @inject IOptionsSnapshot<BlogSettings> settings
  3. <section id="comments">
  4. <div class="container">
  5. <h2>Comments</h2>
  6. @foreach (var comment in Model.Comments)
  7. {
  8. <article id="@comment.ID" class="@(comment.IsAdmin ? "admin" : null)" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
  9. <h3>
  10. <time datetime="@comment.PubDate.ToString("s")" itemprop="datePublished">
  11. <a href="#@comment.ID" title="Permalink (#@comment.ID)">@comment.PubDate.ToString("MMMM d, yyyy")</a>
  12. </time>
  13. </h3>
  14. <figure class="gravatar">
  15. <img alt="@comment.Author" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" data-src="@comment.GetGravatar()" />
  16. </figure>
  17. <div class="content">
  18. <p itemprop="text">@comment.RenderContent()</p>
  19. <span itemprop="name">@comment.Author</span>
  20. @if (User.Identity.IsAuthenticated)
  21. {
  22. <a class="noline" href="mailto:@comment.Email" title="Send email to @comment.Email">&#x2709;</a>
  23. <a class="delete noline" asp-controller="Blog" asp-Action="DeleteComment" asp-route-postid="@Model.ID" asp-route-commentid="@comment.ID" asp-route-afrt="@ViewData["afrt"]" title="Delete the comment...">Delete...</a>
  24. }
  25. </div>
  26. </article>
  27. }
  28. @if (Model.AreCommentsOpen(settings.Value.CommentsCloseAfterDays))
  29. {
  30. if (Model.Comments.Count == 0)
  31. {
  32. <p>Be the first to post a comment</p>
  33. }
  34. <form method="post" asp-controller="Blog" asp-action="AddComment" asp-route-postid="@Model.ID" asp-antiforgery="false">
  35. <h3>Post a comment</h3>
  36. <br />
  37. <label for="content">Comment</label>
  38. <textarea id="content" name="content" rows="5" cols="100" onfocus="" required placeholder="Enter your comment here..."></textarea>
  39. <div class="details">
  40. <label for="author">Name</label>
  41. <input id="author" name="author" placeholder="Your name" required />
  42. <label for="email">E-mail</label>
  43. <input id="email" name="email" placeholder="Example: mary@outlook.com" required />
  44. <br />
  45. <input type="submit" value="Post comment" />
  46. <!-- This element is being removed by site.js. It is to prevent comment spam-->
  47. <input type="hidden" name="website" />
  48. </div>
  49. </form>
  50. <noscript>
  51. <br />
  52. <p>Enable JavaScript to post comments on this blog.</p>
  53. </noscript>
  54. }
  55. else
  56. {
  57. <br />
  58. <p>Comments are closed</p>
  59. }
  60. </div>
  61. </section>