tavern/templates/partials/view_object.html

139 lines
6.8 KiB
HTML

{{ define "view_object" }}
<div id="{{ .ViewContext.ShortHash }}"
class="media pt-2 {{ if .ViewContext.Focus }} pl-2 border-top border-left border-primary{{ else }} border-top border-secondary{{ end }} tavern-feed-item">
<img class="pr-1" src="{{ .ViewContext.Icon }}" alt="icon"/>
<div class="media-body">
<div class="dropdown float-right">
<button class="btn btn-sm btn-outline-primary dropdown-toggle tavern-feed-item-menu" type="button"
id="menu{{ .ViewContext.ShortHash }}" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<i class="fas fa-tools"></i>
</button>
<div class="dropdown-menu" aria-labelledby="menu{{ .ViewContext.ShortHash }}">
{{ if .ViewContext.LinkView }}
<a href="{{ .ViewContext.LinkViewURL }}" class="dropdown-item">
<i class="fas fa-comment-alt"></i>
View
</a>
{{ end }}
{{ if .ViewContext.HasParent }}
<a href="{{ .ViewContext.ParentObjectLink }}" class="dropdown-item">
<i class="fas fa-comments-alt"></i>
View Parent
</a>
{{ end }}
{{ if .ViewContext.LinkReply }}
<a href="{{ .ViewContext.LinkReplyURL }}" class="dropdown-item">
<i class="fas fa-comment-alt-plus"></i>
Reply
</a>
{{ end }}
{{ if .ViewContext.LinkAnnounce }}
<a href="#" class="dropdown-item announce"
data-object="{{ .ViewContext.ObjectID }}">
<i class="fas fa-bullhorn"></i>
Announce
</a>
{{ end }}
{{ if .ViewContext.LinkLike }}
<a href="#" class="dropdown-item like"
data-object="{{ .ViewContext.ObjectID }}">
<i class="far fa-thumbs-up"></i>
Like
</a>
{{ end }}
{{ if and (or .ViewContext.LinkView .ViewContext.LinkReply) .ViewContext.LinkDelete }}
{{ end }}
{{ if .ViewContext.LinkDelete }}
<a href="#" class="dropdown-item owner_delete">
<i class="fas fa-comment-alt-slash"></i>
Delete
</a>
{{ end }}
</div>
</div>
<p>
<span class="w-auto border-bottom">
{{ if .ViewContext.HasParent }}
<a href="{{ .ViewContext.AttributedToLink }}">{{ .ViewContext.AttributedTo }}</a>
{{ if not (eq .ViewContext.ParentAttributedToLink .ViewContext.AttributedToLink) }}
replied to
{{ if eq .ViewContext.ParentAttributedTo "unknown" }}
<span class="text-danger">unknown</span>
{{ else }}
<a href="{{ .ViewContext.ParentAttributedToLink }}">{{ .ViewContext.ParentAttributedTo }}</a>
{{ end }}
{{ else }}
continued
{{ end }}
{{ else }}
<a href="{{ .ViewContext.AttributedToLink }}">{{ .ViewContext.AttributedTo }}</a> wrote
{{ end }}
{{ if .ViewContext.HasPublishedAt }}
on {{ datetime .ViewContext.PublishedAt }}
{{ end }}
{{ if .ViewContext.HasAnnouncers }}
boosted by
{{ range $name, $link := .ViewContext.Announcers }}
<a href="{{ $link }}">{{ $name }}</a>
{{ end }}
{{ end }}
</span>
</p>
{{ if .ViewContext.Sensitive }}
<p class="text-danger" data-toggle="collapse" data-target="#content{{ .ViewContext.ShortHash }}"
aria-expanded="false"
aria-controls="content{{ .ViewContext.ShortHash }}">
<span style="border-bottom-style: dashed; border-bottom-width: 1px; border-bottom-color: red;">
Content Warning: {{ .ViewContext.ContentWarning }}
</span>
</p>
<div class="collapse" id="content{{ .ViewContext.ShortHash }}">
{{ with .ViewContext.Content }}
{{ . | wrapMaybe | toHTML }}
{{ end }}
</div>
{{ else }}
{{ with .ViewContext.Content }}
{{ . | wrapMaybe | toHTML }}
{{ end }}
{{ end }}
{{ if .ViewContext.Media }}
<ul class="list-inline">
{{ range $m := .ViewContext.Media }}
<li class="list-inline-item">
<a href="{{ $m.URL }}" target="_blank">
<img class="img-thumbnail" src="{{ $m.Thumbnail }}" alt="blurred thumbnail of media"/>
</a>
</li>
{{ end }}
</ul>
{{ end }}
{{ if or .ViewContext.TotalAnnounces .ViewContext.TotalReplies .ViewContext.TotalLikes .ViewContext.ViewerAnnounced }}
<ul class="list-inline text-muted">
{{ if .ViewContext.TotalAnnounces }}
<li class="list-inline-item">
{{ .ViewContext.TotalAnnounces }} boosts
{{ if .ViewContext.ViewerAnnounced }}
<span class="badge badge-success">You</span>
{{ end }}
</li>
{{ end }}
{{ if .ViewContext.TotalReplies }}
<li class="list-inline-item">{{ .ViewContext.TotalReplies }} replies</li>
{{ end }}
{{ if .ViewContext.TotalLikes }}
<li class="list-inline-item">{{ .ViewContext.TotalLikes }} likes</li>
{{ end }}
</ul>
{{ end }}
{{ range .Children }}
{{template "view_object" . }}
{{ end }}
</div>
</div>
{{ end }}