mlmym/templates/post.html

140 lines
6.5 KiB
HTML

{{- if and (ne .State.Op "vote_post") (ne .State.Op "save_post") -}}
<div class="post{{if .Post.Deleted}} deleted{{end}}{{ if .Post.FeaturedCommunity }} distinguished{{end}}{{if .Post.FeaturedLocal }} announcement{{end}}" id="p{{.Post.ID}}">
{{- if gt .Rank 0 }}
<div class="rank"> {{ .Rank }} </div>
{{- end }}
<div class="score">
{{- end }}
{{- if or (ne .State.Op "save_post") (eq .State.Op "vote_post") }}
{{- 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">
<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 }}
{{- end }}
{{- if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
</div>
{{ if not .State.HideThumbnails }}
<div class="thumb">
<a class="url" href="{{ if .Post.URL.IsValid }}{{ .Post.URL }}{{ else }}/{{ .State.Host }}/post/{{ .Post.ID }}{{ end }}"
{{- if .State.LinksInNewWindow }} target="_blank" {{ end }}>
<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>
</a>
</div>
{{ end }}
<div class="entry">
<div class="title{{ if .Read}} visited{{end}}">
<a class="url" href="{{ if .Post.URL.IsValid }}{{ .Post.URL }}{{ else }}/{{ .State.Host }}/post/{{ .Post.ID }}{{ end }}"
{{- if .State.LinksInNewWindow }} target="_blank" {{ 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)) (not (isYoutube .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.ValueOrZero.Time.Unix .Post.Published.Time.Unix -}}
* (last edited <span title="{{.Post.Updated.ValueOrZero.Time}}">{{ humanize .Post.Updated.ValueOrZero.Time }}</span>)
{{ end }}
by
<a class="submitter{{ if false}} admin{{end}}" href="/{{ .State.Host }}/u/{{ fullname .Creator }}">
{{- if .State.HideInstanceNames -}}
{{ .Creator.Name }}
{{- else -}}
{{ fullname .Creator }}
{{- end -}}
</a>
to
<a class="community" href="/{{ .State.Host }}/c/{{ fullcname .Community }}">
c/{{ if .State.HideInstanceNames -}}
{{ .Community.Name }}
{{ else -}}
{{ fullcname .Community }}
{{ end }}
</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>
<a href="{{ .Post.ApID}}">fedilink</a>
{{- if .State.Session }}
<a href="/{{ .State.Host }}/post/{{ .Post.ID }}/block" rel="xhr" target="block{{ .Post.ID }}">block</a>
<span class="blockpopup" name="block{{.Post.ID}}"></span>
{{- end }}
{{- 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}}
{{- end }}
{{- if or (ne .State.Op "vote_post") (eq .State.Op "save_post") }}
{{- 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}}
{{- end }}
{{- if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
{{- if .State.PostID }}
<a id="hidechildren" class="scripting" href="">hide all child comments</a>
{{- end }}
{{- if and .State.Site .State.Site.MyUser.IsValid (not .State.Site.MyUser.ValueOrZero.LocalUserView.LocalUser.ShowReadPosts) }}
<form class="link-btn" method="POST">
<input type="hidden" name="postid" value="{{.Post.ID }}">
<input type="hidden" name="op" value="read_post">
{{- if .Post.Deleted }}
<input type="submit" name="submit" value="mark unread">
{{- else }}
<input type="submit" name="submit" value="mark read">
{{- end }}
</form>
{{- end }}
</div>
</div>
<div class="expando{{ if eq .Rank 0 }} open{{ end}}">
{{- if or ((and .Post.Body.IsValid (ne .Post.Body.String ""))) (isImage .Post.URL.String)}}
{{- if gt .Rank 0 }}
<div class="rank"></div>
{{- end }}
{{ if not .State.HideThumbnails }}
<div class="thumb"></div>
{{ end }}
{{- end }}
<div>
{{- 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}}
<img class="image" loading="lazy" src="{{ .Post.URL }}">
{{- end }}
<div class="embed"></div>
</div>
</div>
</div>
{{- end -}}