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