mlmym/templates/comment.html
2023-10-04 13:45:45 -04:00

127 lines
5.3 KiB
HTML

<div class="comment{{if or (lt .P.Counts.Score -5) .P.Comment.Deleted .P.Comment.Removed }} hidden{{end}}" id="c{{.P.Comment.ID}}">
{{ if .State.Session }}
<div class="score">
<form class="link-btn{{ if eq .P.MyVote.String "1"}} like{{ else if eq .P.MyVote.String "-1"}} dislike{{end}}" method="POST">
<input type="submit" name="submit" value="▲">
<div></div>
{{ if .P.MyVote.IsValid}}
<input type="hidden" name="undo" value="{{.P.MyVote.String}}">
{{ end}}
<input type="hidden" name="op" value="vote_comment">
<input type="hidden" name="commentid" value="{{.P.Comment.ID }}">
<input type="submit" name="submit" value="▼">
</form>
</div>
{{ end }}
<div class="meta">
<a class="minimize" href="" for="c{{.P.Comment.ID}}">
{{- if or (lt .P.Counts.Score -5) .P.Comment.Deleted -}}
[+]
{{- else -}}
[-]
{{- end -}}
</a>
<a class="creator{{ if .P.Comment.Distinguished}}{{if .P.Creator.Admin}} admin{{end}} distinguished{{ else if .Submitter }} submitter{{end}}" href="/{{.State.Host}}/u/{{fullname .P.Creator}}">
{{- if .State.HideInstanceNames -}}
{{ .P.Creator.Name }}
{{- else -}}
{{ fullname .P.Creator }}
{{- end -}}
</a>
<b>{{.P.Counts.Score}} points</b> <span title="{{.P.Comment.Published.Time}}">{{ humanize .P.Comment.Published.Time }}</span>
{{- if gt .P.Comment.Updated.Time.Unix .P.Comment.Published.Time.Unix -}}
* (last edited <span title="{{.P.Comment.Updated.Time}}">{{ humanize .P.Comment.Updated.Time }}</span>)
{{ end }}
</div>
<div class="content">
{{ if eq .Op "edit" }}
{{ template "create_comment.html" .State }}
{{ else }}
{{if .P.Comment.Deleted}}
[deleted]
{{else if .P.Comment.Removed }}
[removed by mod]
{{else}}
<div {{ if and .Selected (not .State.XHR) (ne .State.Op "reply")}}class="highlight" {{end}}>
{{ markdown .State.Host .P.Comment.Content }}
</div>
{{end}}
{{ if eq .Op "source" }}
<div><textarea>{{.P.Comment.Content}}</textarea></div>
{{end}}
{{ end }}
<ul class="buttons">
<li><a href="/{{.State.Host}}/comment/{{.P.Comment.ID}}">permalink</a></li>
<li><a href="{{.P.Comment.ApID}}">fedilink</a></li>
{{ if ne .Op "source"}}
<li><a class="source" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?source">source</a></li>
{{ else }}
<li><a class="source" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?">hide source</a></li>
{{ end }}
{{ if .State.Session }}
{{ if and (eq .P.Comment.CreatorID .State.Session.UserID) (ne .Op "edit") }}
<li><a class="edit" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?edit">edit</a></li>
{{ if not .P.Comment.Deleted }}
<li>
<form class="delete" method="POST">
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
<input type="hidden" name="op" value="delete_comment">
<input type="submit" name="submit" value="delete">
</form>
</li>
{{ end }}
{{ end }}
<li>
<form class="link-btn" method="POST">
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
<input type="hidden" name="op" value="save_comment">
{{ if .P.Saved }}
<input type="submit" name="submit" value="unsave">
{{ else }}
<input type="submit" name="submit" value="save">
{{ end }}
</form>
</li>
<li>
<form class="link-btn" method="POST">
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
<input type="hidden" name="op" value="block_user">
<input type="hidden" name="user_id" value="{{.P.Creator.ID}}">
<input type="submit" name="submit" value="block">
</form>
</li>
<li>
<a class="reply" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?reply">
reply
</a>
</li>
{{ end }}
{{ if and .ParentID .State.CommentID (not .State.XHR) }}
<li>
<a href="/{{.State.Host}}/comment/{{.ParentID}}">parent</a>
</li>
{{ end }}
{{ if and .ParentID (or .State.Activities .State.Query) }}
<li>
<a href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?context=3">context</a>
</li>
{{ end }}
{{ if and .State.PostID (gt (add .P.Counts.ChildCount .ChildCount) 0) }}
<li><a class="hidechildren" for="c{{.P.Comment.ID}}" href=""><span class="hide">hide</span><span class="show">show {{add .P.Counts.ChildCount .ChildCount }}</span> child comments</a></li>
{{ end }}
</ul>
</div>
<div class="children">
{{ if and (eq .State.Op "reply") (eq .State.CommentID .P.Comment.ID)}}
{{ template "create_comment.html" .State }}
{{ end}}
{{ range $ci, $child := .C }}{{ template "comment.html" $child }}{{end}}
{{ if and (ne .P.Counts.ChildCount .ChildCount) (not .State.Activities) (not .State.Query) }}
<div class="morecomments">
<a class="loadmore" for="c{{ .P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?">load more comments</a>
<span class="gray">({{ sub .P.Counts.ChildCount .ChildCount}} replies)</span>
</div>
{{end}}
</div>
</div>