mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-16 06:50:26 +00:00
110 lines
4.0 KiB
Plaintext
110 lines
4.0 KiB
Plaintext
{% import "path/filepath" %}
|
|
{% import "strings" %}
|
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
{% func beautifulLink(hyphaName string) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% endfunc %}
|
|
|
|
{% func mycoLink(lc *l18n.Localizer) %}<a href="/help/en/mycomarkup" class="shy-link">{%s lc.Get("ui.notexist_write_myco") %}</a>{% endfunc %}
|
|
|
|
{% func nonExistentHyphaNotice(h hyphae.Hypha, u *user.User, lc *l18n.Localizer) %}
|
|
<section class="non-existent-hypha">
|
|
<h2 class="non-existent-hypha__title">{%s lc.Get("ui.notexist_heading") %}</h2>
|
|
{% if cfg.UseAuth && u.Group == "anon" %}
|
|
<p>{%s lc.Get("ui.notexist_norights") %}</p>
|
|
<ul>
|
|
<li><a href="/login">{%s lc.Get("ui.notexist_login") %}</a></li>
|
|
{% if cfg.AllowRegistration %}<li><a href="/register">{%s lc.Get("ui.notexist_register") %}</a></li>{% endif %}
|
|
</ul>
|
|
{% else %}
|
|
|
|
<div class="non-existent-hypha__ways">
|
|
<section class="non-existent-hypha__way">
|
|
<h3 class="non-existent-hypha__subtitle">📝 {%s lc.Get("ui.notexist_write") %}</h3>
|
|
<p>{%s= lc.Get("ui.notexist_write_tip1", &l18n.Replacements{"myco": mycoLink(lc)}) %}</p>
|
|
<p>{%s lc.Get("ui.notexist_write_tip2") %}</p>
|
|
<a class="btn btn_accent stick-to-bottom" href="/edit/{%s h.CanonicalName() %}">{%s lc.Get("ui.notexist_write_button") %}</a>
|
|
</section>
|
|
|
|
<section class="non-existent-hypha__way">
|
|
<h3 class="non-existent-hypha__subtitle">🖼 {%s lc.Get("ui.notexist_media") %}</h3>
|
|
<p>{%s lc.Get("ui.notexist_media_tip1") %}</p>
|
|
<form action="/upload-binary/{%s h.CanonicalName() %}"
|
|
method="post" enctype="multipart/form-data"
|
|
class="upload-binary">
|
|
<label for="upload-binary__input"></label>
|
|
<input type="file" id="upload-binary__input" name="binary">
|
|
|
|
<button type="submit" class="btn stick-to-bottom" value="Upload">{%s lc.Get("ui.media_upload")%}</button>
|
|
</form>
|
|
</section>
|
|
</div>
|
|
{% endif %}
|
|
</section>
|
|
{% endfunc %}
|
|
|
|
{% func NaviTitle(h hyphae.Hypha) %}
|
|
{% code
|
|
var (
|
|
prevAcc = "/hypha/"
|
|
parts = strings.Split(h.CanonicalName(), "/")
|
|
)
|
|
%}
|
|
<h1 class="navi-title">
|
|
{% stripspace %}
|
|
<a href="/hypha/{%s cfg.HomeHypha %}">
|
|
{%-s= cfg.NaviTitleIcon -%}
|
|
<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 %}
|
|
|
|
<a href="{%s prevAcc + part %}" rel="{% if i == len(parts) - 1 %}bookmark{% else %}up{% endif %}">
|
|
{%s= util.BeautifulName(part) %}
|
|
</a>
|
|
{% code prevAcc += part + "/" %}
|
|
{% endfor %}
|
|
{% endstripspace %}
|
|
</h1>
|
|
{% 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 %}
|