{{ $masIns := .Get 0 }} {{ $tootLink := "" }} {{ $card := "" }} {{ $handleInst := "" }} {{ $mediaMD5 := "" }} {{ $imageCount := 0 }} {{ $votesCount := 0 }} {{ $id := .Get 1 }} {{ $urlToGet := print "https://" $masIns "/api/v1/statuses/" $id }} {{- with resources.GetRemote $urlToGet -}} {{ if (resources.GetRemote $urlToGet).Err }}
{{ else }} {{ $json := unmarshal .Content }} {{ $jsonHolder := $json }}{{/* Being safe */}} {{ if isset $json "account" }} {{ $tootLink = print "https://" $masIns "@" $json.account.acct "/status/" $id }} {{ $handleInst = print "@" $json.account.acct "@" $masIns }} {{ end }} {{ if isset $json "content" }}[Source not online
at time of site build.]
{{ end }} {{ end }} {{- end -}}{{ $json.content | safeHTML }} {{ with $json.media_attachments }} {{ range $media_attachments := . }} {{ if eq $media_attachments.type "image" }} {{ $imageCount = (add ($imageCount) 1) }} {{ end }} {{ end }}{{ range $media_attachments := . }} {{ if eq $media_attachments.type "image" }} {{ $mediaMD5 = md5 $media_attachments.url }}{{/* N.B.: The above results in an empty, no-height div when there's no image but there **is** at least one item in `$media_attachments`. Unfortunately, it seems to be the only way to accomplish this. Not a good HTML practice, but gets the job done. */}} {{ range $media_attachments := . }} {{ if eq $media_attachments.type "video" }} {{ $mediaMD5 = md5 $media_attachments.url }}{{- if $json.sensitive -}}
Sensitive content{{- end -}} {{ end }} {{ end }}
(flagged at origin){{- if $json.sensitive -}}{{ end }} {{ if eq $media_attachments.type "gifv" }} {{ $mediaMD5 = md5 $media_attachments.url }}Sensitive content{{- end -}}
(flagged at origin){{- if $json.sensitive -}}{{ end }} {{ end }} {{ end }} {{ with $json.card }} {{- $cardData := . -}} {{- with $cardData.image -}}Sensitive content{{- end -}}
(flagged at origin){{- end -}} {{ end }} {{ with $json.poll }} {{ $poll := . }} {{ with $poll.options }} {{ range $pollOptions := . }} {{ $votesCount = add $votesCount $pollOptions.votes_count }} {{ end }}![]()
{{ $cardData.title }}
{{ $cardData.description }}
{{ range $pollOptions := . }}{{ (mul 100 (div $pollOptions.votes_count $votesCount)) | lang.FormatPercent 1 }} {{ $pollOptions.title }}{{ end }}{{ $votesCount }} people
{{ end }} {{ end }}