2021-02-20 15:48:51 +00:00
|
|
|
{% import "path/filepath" %}
|
|
|
|
{% import "strings" %}
|
2021-05-09 09:36:39 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
2021-02-20 15:48:51 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
|
|
|
|
{% func NaviTitleHTML(h *hyphae.Hypha) %}
|
|
|
|
{% code
|
|
|
|
var (
|
|
|
|
prevAcc = "/hypha/"
|
|
|
|
parts = strings.Split(h.Name, "/")
|
|
|
|
)
|
|
|
|
%}
|
|
|
|
<h1 class="navi-title">
|
|
|
|
{% stripspace %}
|
2021-05-09 09:36:39 +00:00
|
|
|
<a href="/hypha/{%s cfg.HomeHypha %}">
|
|
|
|
{%-s= cfg.NaviTitleIcon -%}
|
2021-02-20 15:48:51 +00:00
|
|
|
<span aria-hidden="true" class="navi-title__colon">:</span>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
{% for i, part := range parts %}
|
|
|
|
{% if i > 0 %}
|
|
|
|
<span aria-hidden="true" class="navi-title__separator">/</span>
|
|
|
|
{% endif %}
|
|
|
|
|
2021-04-04 17:22:14 +00:00
|
|
|
<a href="{%s prevAcc + part %}" rel="{% if i == len(parts) - 1 %}bookmark{% else %}up{% endif %}">
|
2021-02-20 15:48:51 +00:00
|
|
|
{%s= util.BeautifulName(part) %}
|
|
|
|
</a>
|
|
|
|
{% code prevAcc += part + "/" %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endstripspace %}
|
|
|
|
</h1>
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func AttachmentHTML(h *hyphae.Hypha) %}
|
|
|
|
{% switch filepath.Ext(h.BinaryPath) %}
|
|
|
|
|
|
|
|
{% case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico" %}
|
|
|
|
<div class="binary-container binary-container_with-img">
|
|
|
|
<a href="/binary/{%s= h.Name %}"><img src="/binary/{%s= h.Name %}"/></a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% case ".ogg", ".webm", ".mp4" %}
|
|
|
|
<div class="binary-container binary-container_with-video">
|
|
|
|
<video controls>
|
|
|
|
<source src="/binary/{%s= h.Name %}"/>
|
|
|
|
<p>Your browser does not support video. <a href="/binary/{%s= h.Name %}">Download video</a></p>
|
|
|
|
</video>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% case ".mp3" %}
|
|
|
|
<div class="binary-container binary-container_with-audio">
|
|
|
|
<audio controls>
|
|
|
|
<source src="/binary/{%s= h.Name %}"/>
|
|
|
|
<p>Your browser does not support audio. <a href="/binary/{%s= h.Name %}">Download audio</a></p>
|
|
|
|
</audio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% default %}
|
|
|
|
<div class="binary-container binary-container_with-nothing">
|
|
|
|
<p><a href="/binary/{%s= h.Name %}">Download media</a></p>
|
|
|
|
</div>
|
|
|
|
{% endswitch %}
|
|
|
|
{% endfunc %}
|