mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 13:30:26 +00:00
38 lines
1.4 KiB
Plaintext
38 lines
1.4 KiB
Plaintext
{% import "path/filepath" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
|
|
|
{% func mediaRaw(h *hyphae.MediaHypha) %}{%= Media(h, l18n.New("en", "en")) %}{% endfunc %}
|
|
|
|
{% func Media(h *hyphae.MediaHypha, lc *l18n.Localizer) %}
|
|
{% switch filepath.Ext(h.MediaFilePath()) %}
|
|
|
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
|
<div class="binary-container binary-container_with-img">
|
|
<a href="/binary/{%s= h.CanonicalName() %}"><img src="/binary/{%s= h.CanonicalName() %}"/></a>
|
|
</div>
|
|
|
|
{% case ".ogg", ".webm", ".mp4" %}
|
|
<div class="binary-container binary-container_with-video">
|
|
<video controls>
|
|
<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>
|
|
</video>
|
|
</div>
|
|
|
|
{% case ".mp3" %}
|
|
<div class="binary-container binary-container_with-audio">
|
|
<audio controls>
|
|
<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>
|
|
</audio>
|
|
</div>
|
|
|
|
{% default %}
|
|
<div class="binary-container binary-container_with-nothing">
|
|
<p><a href="/binary/{%s= h.CanonicalName() %}">{%s lc.Get("ui.media_download") %}</a></p>
|
|
</div>
|
|
{% endswitch %}
|
|
{% endfunc %}
|