列表页评论
This commit is contained in:
parent
3636c3952a
commit
75f6afcddc
|
@ -50,22 +50,20 @@ func Detail(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
pw := sessions.Default(c).Get("post_password")
|
||||
showComment := true
|
||||
showComment := false
|
||||
if post.CommentCount > 0 || post.CommentStatus == "open" {
|
||||
showComment = true
|
||||
}
|
||||
common.PasswordProjectTitle(&post)
|
||||
if post.PostPassword != "" && pw != post.PostPassword {
|
||||
common.PasswdProjectContent(&post)
|
||||
showComment = false
|
||||
}
|
||||
canComment := false
|
||||
if post.CommentStatus == "open" {
|
||||
canComment = true
|
||||
}
|
||||
prev, next, err := common.GetContextPost(post.Id, post.PostDate)
|
||||
|
||||
h["title"] = fmt.Sprintf("%s-%s", post.PostTitle, models.Options["blogname"])
|
||||
h["post"] = post
|
||||
h["comment"] = showComment
|
||||
h["canComment"] = canComment
|
||||
h["showComment"] = showComment
|
||||
h["prev"] = prev
|
||||
h["next"] = next
|
||||
}
|
||||
|
|
|
@ -40,90 +40,92 @@
|
|||
|
||||
</article><!-- #post-1 -->
|
||||
|
||||
<div id="comments" class="comments-area">
|
||||
{{ if .showComment}}
|
||||
<div id="comments" class="comments-area">
|
||||
{{ if gt .post.CommentCount 0}}
|
||||
<h2 class="comments-title">《{{.post.PostTitle}}》上有{{.post.CommentCount}}条评论 </h2>
|
||||
<ol class="comment-list">
|
||||
<li id="comment-1" class="comment even thread-even depth-1">
|
||||
<article id="div-comment-1" class="comment-body">
|
||||
<footer class="comment-meta">
|
||||
<div class="comment-author vcard">
|
||||
<img alt=""
|
||||
src="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=56&d=mm&r=g"
|
||||
srcset="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=112&d=mm&r=g 2x"
|
||||
class="avatar avatar-56 photo" height="56" width="56" loading="lazy">
|
||||
<b class="fn">
|
||||
<a href="https://cn.wordpress.org/" rel="external nofollow ugc"
|
||||
class="url">一位WordPress评论者</a>
|
||||
</b>
|
||||
<span class="says">说道:</span></div><!-- .comment-author -->
|
||||
|
||||
<h2 class="comments-title">
|
||||
《{{.post.PostTitle}}》上有1条评论 </h2>
|
||||
<div class="comment-metadata">
|
||||
<a href="/p/1#comment-1">
|
||||
<time datetime="2022-08-19T09:26:37+08:00">2022年 8月 19日 上午9:26</time>
|
||||
</a></div><!-- .comment-metadata -->
|
||||
|
||||
</footer><!-- .comment-meta -->
|
||||
|
||||
<ol class="comment-list">
|
||||
<li id="comment-1" class="comment even thread-even depth-1">
|
||||
<article id="div-comment-1" class="comment-body">
|
||||
<footer class="comment-meta">
|
||||
<div class="comment-author vcard">
|
||||
<img alt=""
|
||||
src="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=56&d=mm&r=g"
|
||||
srcset="http://1.gravatar.com/avatar/d7a973c7dab26985da5f961be7b74480?s=112&d=mm&r=g 2x"
|
||||
class="avatar avatar-56 photo" height="56" width="56" loading="lazy">
|
||||
<b class="fn">
|
||||
<a href="https://cn.wordpress.org/" rel="external nofollow ugc"
|
||||
class="url">一位WordPress评论者</a>
|
||||
</b>
|
||||
<span class="says">说道:</span></div><!-- .comment-author -->
|
||||
<div class="comment-content">
|
||||
<p>您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 <a
|
||||
href="https://cn.gravatar.com/">Gravatar</a>。</p>
|
||||
</div><!-- .comment-content -->
|
||||
|
||||
<div class="comment-metadata">
|
||||
<a href="/p/1#comment-1">
|
||||
<time datetime="2022-08-19T09:26:37+08:00">2022年 8月 19日 上午9:26</time>
|
||||
</a></div><!-- .comment-metadata -->
|
||||
<div class="reply">
|
||||
<a rel="nofollow" class="comment-reply-link"
|
||||
href="/p/1?replytocom=1#respond" data-commentid="1" data-postid="1"
|
||||
data-belowelement="div-comment-1" data-respondelement="respond"
|
||||
data-replyto="回复给一位WordPress评论者"
|
||||
aria-label="回复给一位WordPress评论者">回复</a>
|
||||
</div>
|
||||
</article><!-- .comment-body -->
|
||||
</li><!-- #comment-## -->
|
||||
</ol><!-- .comment-list -->
|
||||
{{end}}
|
||||
{{if eq .post.CommentStatus "open"}}
|
||||
<div id="respond" class="comment-respond">
|
||||
<h3 id="reply-title" class="comment-reply-title">发表回复
|
||||
<small>
|
||||
<a rel="nofollow" id="cancel-comment-reply-link" href="/p/{{.post.Id}}#respond" style="display:none;">取消回复</a>
|
||||
</small>
|
||||
</h3>
|
||||
<form action="/wp-comments-post.php" method="post" id="commentform" class="comment-form"
|
||||
novalidate="">
|
||||
<p class="comment-notes">
|
||||
<span id="email-notes">您的电子邮箱地址不会被公开。</span>
|
||||
<span class="required-field-message" aria-hidden="true">必填项已用<span class="required" aria-hidden="true">*</span>标注</span>
|
||||
</p>
|
||||
<p class="comment-form-comment">
|
||||
<label for="comment">评论 <span class="required" aria-hidden="true">*</span></label>
|
||||
<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required=""></textarea></p>
|
||||
<p class="comment-form-author">
|
||||
<label for="author">显示名称 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="author" name="author" type="text" value="" size="30" maxlength="245"
|
||||
required=""></p>
|
||||
<p class="comment-form-email">
|
||||
<label for="email">电子邮箱地址 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="email" name="email" type="email" value="" size="30" maxlength="100"
|
||||
aria-describedby="email-notes" required="">
|
||||
</p>
|
||||
<p class="comment-form-url"><label for="url">网站地址</label>
|
||||
<input id="url" name="url" type="url" value="" size="30" maxlength="200"></p>
|
||||
<p class="comment-form-cookies-consent">
|
||||
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes">
|
||||
<label for="wp-comment-cookies-consent">在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。</label>
|
||||
</p>
|
||||
<p class="form-submit">
|
||||
<input name="submit" type="submit" id="submit" class="submit" value="发表评论">
|
||||
<input type="hidden" name="comment_post_ID" value="{{.post.Id}}" id="comment_post_ID">
|
||||
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
|
||||
</p>
|
||||
</form>
|
||||
</div><!-- #respond -->
|
||||
{{else}}
|
||||
<p class="no-comments">评论已关闭。</p>
|
||||
{{end}}
|
||||
</div><!-- .comments-area -->
|
||||
{{end}}
|
||||
|
||||
</footer><!-- .comment-meta -->
|
||||
|
||||
<div class="comment-content">
|
||||
<p>您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 <a
|
||||
href="https://cn.gravatar.com/">Gravatar</a>。</p>
|
||||
</div><!-- .comment-content -->
|
||||
|
||||
<div class="reply">
|
||||
<a rel="nofollow" class="comment-reply-link"
|
||||
href="/p/1?replytocom=1#respond" data-commentid="1" data-postid="1"
|
||||
data-belowelement="div-comment-1" data-respondelement="respond"
|
||||
data-replyto="回复给一位WordPress评论者"
|
||||
aria-label="回复给一位WordPress评论者">回复</a>
|
||||
</div>
|
||||
</article><!-- .comment-body -->
|
||||
</li><!-- #comment-## -->
|
||||
</ol><!-- .comment-list -->
|
||||
|
||||
{{if .canComment}}
|
||||
<div id="respond" class="comment-respond">
|
||||
<h3 id="reply-title" class="comment-reply-title">发表回复
|
||||
<small>
|
||||
<a rel="nofollow" id="cancel-comment-reply-link" href="/p/{{.post.Id}}#respond" style="display:none;">取消回复</a>
|
||||
</small>
|
||||
</h3>
|
||||
<form action="/wp-comments-post.php" method="post" id="commentform" class="comment-form"
|
||||
novalidate="">
|
||||
<p class="comment-notes">
|
||||
<span id="email-notes">您的电子邮箱地址不会被公开。</span>
|
||||
<span class="required-field-message" aria-hidden="true">必填项已用<span class="required" aria-hidden="true">*</span>标注</span>
|
||||
</p>
|
||||
<p class="comment-form-comment">
|
||||
<label for="comment">评论 <span class="required" aria-hidden="true">*</span></label>
|
||||
<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required=""></textarea></p>
|
||||
<p class="comment-form-author">
|
||||
<label for="author">显示名称 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="author" name="author" type="text" value="" size="30" maxlength="245"
|
||||
required=""></p>
|
||||
<p class="comment-form-email">
|
||||
<label for="email">电子邮箱地址 <span class="required" aria-hidden="true">*</span></label>
|
||||
<input id="email" name="email" type="email" value="" size="30" maxlength="100"
|
||||
aria-describedby="email-notes" required="">
|
||||
</p>
|
||||
<p class="comment-form-url"><label for="url">网站地址</label>
|
||||
<input id="url" name="url" type="url" value="" size="30" maxlength="200"></p>
|
||||
<p class="comment-form-cookies-consent">
|
||||
<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes">
|
||||
<label for="wp-comment-cookies-consent">在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。</label>
|
||||
</p>
|
||||
<p class="form-submit">
|
||||
<input name="submit" type="submit" id="submit" class="submit" value="发表评论">
|
||||
<input type="hidden" name="comment_post_ID" value="{{.post.Id}}" id="comment_post_ID">
|
||||
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
|
||||
</p>
|
||||
</form>
|
||||
</div><!-- #respond -->
|
||||
{{end}}
|
||||
</div><!-- .comments-area -->
|
||||
|
||||
<nav class="navigation post-navigation" aria-label="文章">
|
||||
<h2 class="screen-reader-text">文章导航</h2>
|
||||
|
|
|
@ -49,12 +49,14 @@
|
|||
{{$v.TagsHtml|unescaped}}
|
||||
</span>
|
||||
{{end}}
|
||||
{{if gt $v.CommentCount 0}}
|
||||
<span class="comments-link">
|
||||
<a href="/p/{{$v.Id}}#comments">
|
||||
<span class="screen-reader-text">{{$v.PostTitle}}</span>有{{$v.CommentCount}}条评论
|
||||
</a>
|
||||
</span>
|
||||
{{end}}
|
||||
|
||||
<span class="comments-link">
|
||||
<a href="/p/1#comments">
|
||||
<span class="screen-reader-text">{{$v.PostTitle}}</span>有1条评论
|
||||
</a>
|
||||
</span>
|
||||
</footer><!-- .entry-footer -->
|
||||
|
||||
</article><!-- #post-{{$v.Id}} -->
|
||||
|
|
Loading…
Reference in New Issue
Block a user