mlmym/templates/post.html
2023-07-07 13:42:57 -04:00

89 lines
4.3 KiB
HTML

{{ if ne .State.Op "vote_post" }}
<div class="post{{if .Post.Deleted}} deleted{{end}}{{ if or .Post.FeaturedCommunity .Post.FeaturedLocal }} distinguished{{end}}" onclick="postClick(event)">
{{ if gt .Rank 0 }}
<div class="rank"> {{ .Rank }} </div>
{{ end }}
<div class="score">
{{ end }}
{{ if .State.Session }}
<form class="link-btn {{ if lt .Rank 1 }}squish{{end}}{{ if eq .MyVote.String "1" }} like{{else if eq .MyVote.String "-1"}} dislike{{end}}" method="POST" onsubmit="formSubmit(event)">
<input type="submit" name="vote" value="▲">
{{ if .MyVote.IsValid}}
<input type="hidden" name="undo" value="{{.MyVote.String}}">
{{ end}}
<input type="hidden" name="op" value="vote_post">
<input type="hidden" name="postid" value="{{.Post.ID }}">
<div>{{ .Counts.Score }}</div>
<input type="submit" name="vote" value="▼">
</form>
{{ else }}
<div style="margin-top: 19px;">{{ .Counts.Score }}</div>
{{ end }}
{{ if ne .State.Op "vote_post" }}
</div>
<div class="thumb"><div {{ if and .Post.NSFW (not (and .State.Community .State.Community.CommunityView.Community.NSFW))}}class="img-blur"{{end}} style="background-image: url({{thumbnail .Post}})"></div></div>
<div class="entry">
<div class="title">
<a class="url" href="{{ if .Post.URL.IsValid }}{{ .Post.URL }}{{ else }}/{{ .State.Host }}/post/{{ .Post.ID }}{{ end }}">{{ rmmarkdown .Post.Name }}</a>
({{ domain . }})
</div>
<div class="expando-button {{ if and (not (and .Post.Body.IsValid .Post.Body.String )) (not (isImage .Post.URL.String)) }}hidden{{else if eq .Rank 0}}open{{ end }}"></div>
<div class="meta">
submitted
<span title="{{.Post.Published.Time}}">{{ humanize .Post.Published.Time -}}</span>
{{- if gt .Post.Updated.Time.Unix .Post.Published.Time.Unix -}}
* (last edited <span title="{{.Post.Updated.Time}}">{{ humanize .Post.Updated.Time }}</span>)
{{ end }}
by
<a href="/{{ .State.Host }}/u/{{ fullname .Creator }}">{{ fullname .Creator }}</a>
to
<a href="/{{ .State.Host }}/c/{{ fullcname .Community }}">{{ fullcname .Community}}</a>
</div>
<div class="buttons">
{{ if .Post.NSFW }}<span class="nsfw">NSFW</span>{{end}}
<a href="/{{ .State.Host }}/post/{{ .Post.ID }}">{{ .Counts.Comments }} comments</a>
{{ if and .State.Session (eq .State.Session.UserID .Post.CreatorID) }}
{{ if not .Post.Deleted }}<a href="/{{ .State.Host }}/post/{{ .Post.ID }}?edit">edit</a>{{end}}
<form class="link-btn" method="POST">
<input type="hidden" name="postid" value="{{.Post.ID }}">
<input type="hidden" name="op" value="delete_post">
{{ if .Post.Deleted }}
<input type="submit" value="undelete">
<input type="hidden" name="undo" value="1">
{{ else }}
<input type="submit" value="delete">
{{ end }}
</form>
{{ end}}
{{ if .State.Session }}
<form class="link-btn" method="POST">
<input type="hidden" name="postid" value="{{.Post.ID }}">
<input type="hidden" name="op" value="save_post">
{{ if .PostView.Saved }}
<input type="submit" name="submit" value="unsave">
{{ else }}
<input type="submit" name="submit" value="save">
{{ end }}
</form>
{{end}}
{{ if .State.PostID }}
<a class="hidechildren" onclick="hideAllChildComments(event)" href="">hide all child comments</a>
{{ end }}
</div>
</div>
<div></div>
<div class="clearleft"></div>
<div class="expando {{ if eq .Rank 0 }}open{{ end}}">
{{ if (and .Post.Body.IsValid (ne .Post.Body.String "")) }}
<div class="md">{{ markdown .State.Host .Post.Body.String }}</div>
{{ end }}
{{ if isImage .Post.URL.String}}
<div class="image" style="background-image: url({{.Post.URL}})">
<img loading="lazy" src="{{ .Post.URL }}">
</div>
{{ end }}
<div class="embed"></div>
</div>
</div>
{{ end }}