/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
- @model Post
- @inject IOptionsSnapshot<BlogSettings> settings
- <section id="comments">
- <div class="container">
- <h2>Comments</h2>
- @foreach (var comment in Model.Comments)
- {
- <article id="@comment.ID" class="@(comment.IsAdmin ? "admin" : null)" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
- <h3>
- <time datetime="@comment.PubDate.ToString("s")" itemprop="datePublished">
- <a href="#@comment.ID" title="Permalink (#@comment.ID)">@comment.PubDate.ToString("MMMM d, yyyy")</a>
- </time>
- </h3>
- <figure class="gravatar">
- <img alt="@comment.Author" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" data-src="@comment.GetGravatar()" />
- </figure>
- <div class="content">
- <p itemprop="text">@comment.RenderContent()</p>
- <span itemprop="name">@comment.Author</span>
- @if (User.Identity.IsAuthenticated)
- {
- <a class="noline" href="mailto:@comment.Email" title="Send email to @comment.Email">✉</a>
- <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>
- }
- </div>
- </article>
- }
- @if (Model.AreCommentsOpen(settings.Value.CommentsCloseAfterDays))
- {
- if (Model.Comments.Count == 0)
- {
- <p>Be the first to post a comment</p>
- }
- <form method="post" asp-controller="Blog" asp-action="AddComment" asp-route-postid="@Model.ID" asp-antiforgery="false">
- <h3>Post a comment</h3>
- <br />
- <label for="content">Comment</label>
- <textarea id="content" name="content" rows="5" cols="100" onfocus="" required placeholder="Enter your comment here..."></textarea>
- <div class="details">
- <label for="author">Name</label>
- <input id="author" name="author" placeholder="Your name" required />
- <label for="email">E-mail</label>
- <input id="email" name="email" placeholder="Example: mary@outlook.com" required />
- <br />
- <input type="submit" value="Post comment" />
- <!-- This element is being removed by site.js. It is to prevent comment spam-->
- <input type="hidden" name="website" />
- </div>
- </form>
- <noscript>
- <br />
- <p>Enable JavaScript to post comments on this blog.</p>
- </noscript>
- }
- else
- {
- <br />
- <p>Comments are closed</p>
- }
- </div>
- </section>