2023-12-05 12:43:07 +01:00
|
|
|
{{- /*
|
|
|
|
// GoToSocial
|
|
|
|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/ -}}
|
|
|
|
|
|
|
|
{{- /*
|
2023-12-27 11:23:52 +01:00
|
|
|
Template for rendering a gallery of status media attachments.
|
|
|
|
To use this template, pass a web view status into it.
|
2023-12-05 12:43:07 +01:00
|
|
|
*/ -}}
|
|
|
|
|
2023-12-27 11:23:52 +01:00
|
|
|
{{- define "imagePreview" }}
|
|
|
|
<img
|
|
|
|
src="{{- .PreviewURL -}}"
|
|
|
|
loading="lazy"
|
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- .Description -}}"
|
|
|
|
title="{{- .Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
width="{{- .Meta.Original.Width -}}"
|
|
|
|
height="{{- .Meta.Original.Height -}}"
|
|
|
|
/>
|
2023-12-05 12:43:07 +01:00
|
|
|
{{- end }}
|
2023-12-27 11:23:52 +01:00
|
|
|
|
|
|
|
{{- define "videoPreview" }}
|
2024-07-15 11:47:57 +02:00
|
|
|
<img
|
|
|
|
src="{{- .PreviewURL -}}"
|
|
|
|
loading="lazy"
|
2023-12-27 11:23:52 +01:00
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- .Description -}}"
|
|
|
|
title="{{- .Description -}}"
|
|
|
|
{{- end }}
|
2024-07-15 11:47:57 +02:00
|
|
|
width="{{- .Meta.Small.Width -}}"
|
|
|
|
height="{{- .Meta.Small.Height -}}"
|
|
|
|
/>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- define "audioPreview" }}
|
|
|
|
{{- if and .PreviewURL .Meta.Small.Width }}
|
|
|
|
<img
|
|
|
|
src="{{- .PreviewURL -}}"
|
|
|
|
loading="lazy"
|
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- .Description -}}"
|
|
|
|
title="{{- .Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
width="{{- .Meta.Small.Width -}}"
|
|
|
|
height="{{- .Meta.Small.Height -}}"
|
|
|
|
/>
|
|
|
|
{{- else }}
|
|
|
|
<img
|
|
|
|
src="/assets/logo.png"
|
|
|
|
loading="lazy"
|
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- .Description -}}"
|
|
|
|
title="{{- .Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
width="518"
|
|
|
|
height="460"
|
|
|
|
/>
|
|
|
|
{{- end }}
|
2023-12-27 11:23:52 +01:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- /* Produces something like "1 attachment", "2 attachments", etc */ -}}
|
|
|
|
{{- define "attachmentsLength" -}}
|
|
|
|
{{- (len .) }}{{- if eq (len .) 1 }} attachment{{- else }} attachments{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- /* Produces something like "media photoswipe-gallery odd single" */ -}}
|
|
|
|
{{- define "galleryClass" -}}
|
|
|
|
media photoswipe-gallery {{ (len .) | oddOrEven }} {{ if eq (len .) 1 }}single{{ else if eq (len .) 2 }}double{{ end }}
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- with .MediaAttachments }}
|
|
|
|
<div
|
|
|
|
class="{{- template "galleryClass" . -}}"
|
|
|
|
role="group"
|
|
|
|
aria-label="{{- template "attachmentsLength" . -}}"
|
|
|
|
>
|
|
|
|
{{- range $index, $media := . }}
|
|
|
|
<div class="media-wrapper">
|
|
|
|
<details class="{{- $media.Type -}}-spoiler media-spoiler" {{- if not $media.Sensitive }} open{{- end -}}>
|
|
|
|
<summary>
|
|
|
|
<div class="show sensitive button" aria-hidden="true">Show sensitive media</div>
|
|
|
|
<span class="eye button" role="button" tabindex="0" aria-label="Toggle media">
|
|
|
|
<i class="hide fa fa-fw fa-eye-slash" aria-hidden="true"></i>
|
|
|
|
<i class="show fa fa-fw fa-eye" aria-hidden="true"></i>
|
|
|
|
</span>
|
|
|
|
{{- if eq .Type "video" }}
|
|
|
|
{{- include "videoPreview" $media | indent 4 }}
|
|
|
|
{{- else if eq .Type "image" }}
|
|
|
|
{{- include "imagePreview" $media | indent 4 }}
|
2024-07-15 11:47:57 +02:00
|
|
|
{{- else if eq .Type "audio" }}
|
|
|
|
{{- include "audioPreview" $media | indent 4 }}
|
2023-12-27 11:23:52 +01:00
|
|
|
{{- end }}
|
|
|
|
</summary>
|
|
|
|
{{- if eq .Type "video" }}
|
|
|
|
<video
|
2024-07-15 11:47:57 +02:00
|
|
|
preload="none"
|
2023-12-27 11:23:52 +01:00
|
|
|
class="plyr-video photoswipe-slide"
|
|
|
|
controls
|
|
|
|
data-pswp-index="{{- $index -}}"
|
2024-07-15 11:47:57 +02:00
|
|
|
poster="{{- .PreviewURL -}}"
|
|
|
|
data-pswp-width="{{- $media.Meta.Small.Width -}}px"
|
|
|
|
data-pswp-height="{{- $media.Meta.Small.Height -}}px"
|
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- $media.Description -}}"
|
|
|
|
title="{{- $media.Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
>
|
|
|
|
<source type="{{- $media.MIMEType -}}" src="{{- $media.URL -}}"/>
|
|
|
|
</video>
|
|
|
|
{{- else if eq .Type "audio" }}
|
|
|
|
<video
|
|
|
|
preload="none"
|
|
|
|
class="plyr-video photoswipe-slide"
|
|
|
|
controls
|
|
|
|
data-pswp-index="{{- $index -}}"
|
|
|
|
{{- if and $media.PreviewURL $media.Meta.Small.Width }}
|
|
|
|
poster="{{- .PreviewURL -}}"
|
|
|
|
data-pswp-width="{{- $media.Meta.Small.Width -}}px"
|
|
|
|
data-pswp-height="{{- $media.Meta.Small.Height -}}px"
|
|
|
|
{{- else }}
|
|
|
|
poster="/assets/logo.png"
|
|
|
|
width="518px"
|
|
|
|
height="460px"
|
|
|
|
{{- end }}
|
2023-12-27 11:23:52 +01:00
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- $media.Description -}}"
|
|
|
|
title="{{- $media.Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
>
|
2024-07-15 11:47:57 +02:00
|
|
|
<source type="{{- $media.MIMEType -}}" src="{{- $media.URL -}}"/>
|
2023-12-27 11:23:52 +01:00
|
|
|
</video>
|
|
|
|
{{- else if eq .Type "image" }}
|
|
|
|
<a
|
|
|
|
class="photoswipe-slide"
|
|
|
|
href="{{- $media.URL -}}"
|
|
|
|
target="_blank"
|
|
|
|
data-pswp-width="{{- $media.Meta.Original.Width -}}px"
|
|
|
|
data-pswp-height="{{- $media.Meta.Original.Height -}}px"
|
|
|
|
data-cropped="true"
|
|
|
|
{{- if .Description }}
|
|
|
|
alt="{{- $media.Description -}}"
|
|
|
|
title="{{- $media.Description -}}"
|
|
|
|
{{- end }}
|
|
|
|
>
|
|
|
|
{{- with $media }}
|
|
|
|
{{- include "imagePreview" . | indent 4 }}
|
|
|
|
{{- end }}
|
|
|
|
</a>
|
|
|
|
{{- else }}
|
|
|
|
<a
|
|
|
|
class="unknown-attachment"
|
|
|
|
href="{{- $media.RemoteURL -}}"
|
|
|
|
rel="nofollow noreferrer noopener"
|
|
|
|
target="_blank"
|
|
|
|
{{- if .Description }}
|
|
|
|
title="Open external media: {{ $media.Description -}} {{- $media.RemoteURL -}}"
|
|
|
|
{{- else }}
|
|
|
|
title="Open external media. {{- $media.RemoteURL -}}"
|
|
|
|
{{- end }}
|
|
|
|
>
|
|
|
|
<div class="placeholder" aria-hidden="true">
|
|
|
|
<i class="placeholder-external-link fa fa-external-link"></i>
|
|
|
|
<i class="placeholder-icon fa fa-file-text"></i>
|
|
|
|
<div class="placeholder-link-to">External media</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
{{- end }}
|
|
|
|
</details>
|
|
|
|
</div>
|
|
|
|
{{- end }}
|
|
|
|
</div>
|
|
|
|
{{- end }}
|