diff --git a/internal/api/util/template.go b/internal/api/util/template.go index ec04a4d97..38e79484f 100644 --- a/internal/api/util/template.go +++ b/internal/api/util/template.go @@ -48,10 +48,10 @@ type WebPage struct { // Can be nil. Stylesheets []string - // Paths to JS files to add to - // the page as "script" entries. + // JS files to add to the + // page as "script" entries. // Can be nil. - Javascript []string + Javascript []JavascriptEntry // Extra parameters to pass to // the template for rendering, @@ -60,6 +60,21 @@ type WebPage struct { Extra map[string]any } +type JavascriptEntry struct { + // Insert + {{- if not .Bottom }} + + {{- end }} {{- end }} {{- template "instanceTitle" . -}} @@ -82,5 +84,10 @@ image/webp + {{- range .javascript }} + {{- if .Bottom }} + + {{- end }} + {{- end }} \ No newline at end of file diff --git a/web/template/status_attachment.tmpl b/web/template/status_attachment.tmpl index bdfafa96f..4dda7298f 100644 --- a/web/template/status_attachment.tmpl +++ b/web/template/status_attachment.tmpl @@ -17,33 +17,7 @@ // along with this program. If not, see . */ -}} -{{- define "imagePreview" }} -{{- .Description -}} -{{- end }} - -{{- define "videoPreview" }} -{{- .Description -}} -{{- end }} - -{{- define "audioPreview" }} +{{- define "preview" }} {{- if and .PreviewURL .Meta.Small.Width }} {{- else }}
- + - + - {{- if or (eq .Item.Type "video") (eq .Item.Type "gifv") }} - {{- include "videoPreview" .Item | indent 3 }} - {{- else if eq .Item.Type "image" }} - {{- include "imagePreview" .Item | indent 3 }} - {{- else if eq .Item.Type "audio" }} - {{- include "audioPreview" .Item | indent 3 }} + {{- if and (not (eq .Item.Type "unknown")) .Item.Meta.Small.Width }} +
{{- end }}
{{- if or (eq .Item.Type "video") (eq .Item.Type "gifv") }}