2021-02-20 15:48:51 +00:00
|
|
|
{% import "path/filepath" %}
|
2021-05-14 09:05:07 +00:00
|
|
|
|
2021-02-20 15:48:51 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
2021-09-06 17:46:34 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
2021-02-20 15:48:51 +00:00
|
|
|
|
2022-06-10 15:45:27 +00:00
|
|
|
{% func mediaRaw(h *hyphae.MediaHypha) %}{%= Media(h, l18n.New("en", "en")) %}{% endfunc %}
|
2021-09-06 17:46:34 +00:00
|
|
|
|
2022-03-20 21:24:40 +00:00
|
|
|
{% func Media(h *hyphae.MediaHypha, lc *l18n.Localizer) %}
|
2022-02-19 08:26:38 +00:00
|
|
|
{% switch filepath.Ext(h.MediaFilePath()) %}
|
2021-02-20 15:48:51 +00:00
|
|
|
|
|
|
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
|
|
|
<div class="binary-container binary-container_with-img">
|
2022-02-03 22:29:01 +00:00
|
|
|
<a href="/binary/{%s= h.CanonicalName() %}"><img src="/binary/{%s= h.CanonicalName() %}"/></a>
|
2021-02-20 15:48:51 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{% case ".ogg", ".webm", ".mp4" %}
|
|
|
|
<div class="binary-container binary-container_with-video">
|
|
|
|
<video controls>
|
2022-02-03 22:29:01 +00:00
|
|
|
<source src="/binary/{%s= h.CanonicalName() %}"/>
|
|
|
|
<p>{%s lc.Get("ui.media_novideo") %} <a href="/binary/{%s= h.CanonicalName() %}">{%s lc.Get("ui.media_novideo_link") %}</a></p>
|
2021-02-20 15:48:51 +00:00
|
|
|
</video>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% case ".mp3" %}
|
|
|
|
<div class="binary-container binary-container_with-audio">
|
|
|
|
<audio controls>
|
2022-02-03 22:29:01 +00:00
|
|
|
<source src="/binary/{%s= h.CanonicalName() %}"/>
|
|
|
|
<p>{%s lc.Get("ui.media_noaudio") %} <a href="/binary/{%s= h.CanonicalName() %}">{%s lc.Get("ui.media_noaudio_link") %}</a></p>
|
2021-02-20 15:48:51 +00:00
|
|
|
</audio>
|
|
|
|
</div>
|
2024-08-25 16:18:02 +00:00
|
|
|
|
2021-02-20 15:48:51 +00:00
|
|
|
{% default %}
|
|
|
|
<div class="binary-container binary-container_with-nothing">
|
2022-02-03 22:29:01 +00:00
|
|
|
<p><a href="/binary/{%s= h.CanonicalName() %}">{%s lc.Get("ui.media_download") %}</a></p>
|
2021-02-20 15:48:51 +00:00
|
|
|
</div>
|
|
|
|
{% endswitch %}
|
|
|
|
{% endfunc %}
|