mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-15 14:30:26 +00:00
41 lines
1.5 KiB
Plaintext
41 lines
1.5 KiB
Plaintext
{% import "path/filepath" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
{% func beautifulLink(hyphaName string) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% endfunc %}
|
|
|
|
{% 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 %}
|