mlmym/templates/comment.html

89 lines
4 KiB
HTML
Raw Normal View History

2023-06-30 19:41:35 +00:00
<div class="comment{{if or (lt .P.Counts.Score -5) .P.Comment.Deleted }} hidden{{end}}" id="c{{.P.Comment.ID}}" onclick="commentClick(event)">
<div class="meta">
2023-07-03 22:12:32 +00:00
{{ 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">
2023-06-30 19:41:35 +00:00
<input type="submit" name="vote" value="▲">
<div></div>
2023-07-03 22:12:32 +00:00
{{ if .P.MyVote.IsValid}}
2023-06-30 19:41:35 +00:00
<input type="hidden" name="undo" value="{{.P.MyVote.String}}">
2023-07-03 22:12:32 +00:00
{{ end}}
2023-06-30 19:41:35 +00:00
<input type="hidden" name="op" value="vote_comment">
<input type="hidden" name="commentid" value="{{.P.Comment.ID }}">
<input type="submit" name="vote" value="▼">
2023-06-30 19:41:35 +00:00
</form>
</div>
2023-07-03 22:12:32 +00:00
{{ end }}
2023-06-30 19:41:35 +00:00
<a class="minimize" href="" for="c{{.P.Comment.ID}}">
2023-07-03 22:12:32 +00:00
{{if or (lt .P.Counts.Score -5) .P.Comment.Deleted }}
2023-06-30 19:41:35 +00:00
[+]
2023-07-03 22:12:32 +00:00
{{ else }}
2023-06-30 19:41:35 +00:00
[-]
2023-07-03 22:12:32 +00:00
{{ end }}
2023-06-30 19:41:35 +00:00
</a>
<a {{ if .P.Comment.Distinguished}}class="distinguished"{{ else if .Submitter }}class="submitter"{{end}} href="/{{.State.Host}}/u/{{fullname .P.Creator}}">{{fullname .P.Creator}}</a>
2023-06-30 19:41:35 +00:00
{{.P.Counts.Score}} points <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>
2023-07-03 22:12:32 +00:00
{{ if eq .Op "edit" }}
2023-06-30 19:41:35 +00:00
<form class="savecomment" method="POST">
<div>
<textarea required name="content">{{ .P.Comment.Content }}</textarea>
</div>
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
<input type="hidden" name="op" value="edit_comment">
<input type="submit" value="save">
</form>
2023-07-03 22:12:32 +00:00
{{ else }}
2023-06-30 19:41:35 +00:00
<div class="content{{ if and .Selected}} highlight{{end}}">{{if .P.Comment.Deleted}}[removed]{{else}}{{ markdown .State.Host .P.Comment.Content }}{{end}}</div>
2023-07-03 22:12:32 +00:00
{{ if eq .Op "source" }}
<div><textarea>{{.P.Comment.Content}}</textarea></div>
{{end}}
{{ end }}
2023-06-30 19:41:35 +00:00
<ul class="buttons">
<li><a href="/{{.State.Host}}/comment/{{.P.Comment.ID}}">permalink</a></li>
2023-07-03 22:12:32 +00:00
{{ if ne .Op "source"}}
2023-06-30 19:41:35 +00:00
<li><a class="source" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?source">source</a></li>
2023-07-03 22:12:32 +00:00
{{ else }}
2023-06-30 19:41:35 +00:00
<li><a class="source" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?">hide source</a></li>
2023-07-03 22:12:32 +00:00
{{ end }}
{{ if .State.Session }}
{{ if and (eq .P.Comment.CreatorID .State.Session.UserID) (ne .Op "edit")}}
2023-06-30 19:41:35 +00:00
<li><a class="edit" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?edit">edit</a></li>
<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" value="delete">
</form>
</li>
2023-07-03 22:12:32 +00:00
{{ end }}
{{ if ne .Op "reply"}}
2023-06-30 19:41:35 +00:00
<li><a class="reply" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?reply">reply</a></li>
2023-07-03 22:12:32 +00:00
{{ end }}
{{ end }}
2023-06-30 19:41:35 +00:00
</ul>
<div class="children">
2023-07-03 22:12:32 +00:00
{{ if and (eq .State.Op "reply") (eq .State.CommentID .P.Comment.ID)}}
2023-06-30 19:41:35 +00:00
<form class="savecomment" method="POST">
<div>
<textarea required name="content"></textarea>
</div>
<input type="hidden" name="parentid" value="{{.P.Comment.ID}}">
<input type="hidden" name="op" value="create_comment">
<input type="submit" value="save">
</form>
2023-07-03 22:12:32 +00:00
{{ end}}
2023-06-30 19:41:35 +00:00
{{ range $ci, $child := .C }}{{ template "comment.html" $child }}{{end}}
</div>
2023-07-03 22:12:32 +00:00
{{ if ne .P.Counts.ChildCount .ChildCount}}
2023-06-30 19:41:35 +00:00
<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>
2023-07-03 22:12:32 +00:00
{{end}}
2023-06-30 19:41:35 +00:00
</div>