1{% import "git.sr.ht/~gabrielgio/img/pkg/database/repository" %}
2
3{% code
4type MediaPage struct {
5 Medias []*repository.Media
6 Next *repository.Pagination
7 Settings *repository.Settings
8}
9
10func (m *MediaPage) PreloadAttr() string {
11 if m.Settings.PreloadVideoMetadata {
12 return "metadata"
13 }
14 return "none"
15}
16%}
17
18{% func (p *MediaPage) Title() %}Media{% endfunc %}
19
20{% func (p *MediaPage) Content() %}
21<div class="columns is-multiline">
22{% for _, media := range p.Medias %}
23 <div class="card-image">
24 {% if media.IsVideo() %}
25 <video class="image is-fit" controls muted="true" poster="/media/thumbnail/?path_hash={%s media.PathHash %}" preload="{%s p.PreloadAttr() %}">
26 <source src="/media/image/?path_hash={%s media.PathHash %}" type="{%s media.MIMEType %}">
27 </video>
28 {% else %}
29 <figure class="image is-fit">
30 <img src="/media/thumbnail/?path_hash={%s media.PathHash %}">
31 </figure>
32 {% endif %}
33 </div>
34{% endfor %}
35</div>
36<div class="row">
37 <a href="/media/?page={%d p.Next.Page %}" class="button is-pulled-right">next</a>
38</div>
39{% endfunc %}
40
41{% func (p *MediaPage) Script() %}
42{% endfunc %}