2021-02-20 15:48:51 +00:00
|
|
|
{% import "path/filepath" %}
|
|
|
|
{% import "strings" %}
|
2021-05-14 09:05:07 +00:00
|
|
|
|
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" %}
|
2021-09-06 17:46:34 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
|
2021-05-14 09:05:07 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
2021-02-20 15:48:51 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
{% func beautifulLink(hyphaName string) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% endfunc %}
|
2021-08-08 19:38:41 +00:00
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
{% func mycoLink(lc *l18n.Localizer) %}<a href="/help/{%s lc.Locale %}/mycomarkup" class="shy-link">{%s lc.Get("ui.notexist_write_myco") %}</a>{% endfunc %}
|
|
|
|
|
|
|
|
{% func nonExistentHyphaNotice(h *hyphae.Hypha, u *user.User, lc *l18n.Localizer) %}
|
2021-05-14 09:05:07 +00:00
|
|
|
<section class="non-existent-hypha">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h2 class="non-existent-hypha__title">{%s lc.Get("ui.notexist_heading") %}</h2>
|
2021-07-02 08:20:03 +00:00
|
|
|
{% if cfg.UseAuth && u.Group == "anon" %}
|
2021-09-06 17:46:34 +00:00
|
|
|
<p>{%s lc.Get("ui.notexist_norights") %}</p>
|
2021-05-14 09:05:07 +00:00
|
|
|
<ul>
|
2021-09-06 17:46:34 +00:00
|
|
|
<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 %}
|
2021-05-14 09:05:07 +00:00
|
|
|
</ul>
|
|
|
|
{% else %}
|
|
|
|
|
|
|
|
<div class="non-existent-hypha__ways">
|
|
|
|
<section class="non-existent-hypha__way">
|
2021-09-06 17:46:34 +00:00
|
|
|
<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.Name %}">{%s lc.Get("ui.notexist_write_button") %}</a>
|
2021-05-14 09:05:07 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="non-existent-hypha__way">
|
2021-09-06 17:46:34 +00:00
|
|
|
<h3 class="non-existent-hypha__subtitle">🖼 {%s lc.Get("ui.notexist_media") %}</h3>
|
|
|
|
<p>{%s lc.Get("ui.notexist_media_tip1") %}</p>
|
2021-05-14 09:05:07 +00:00
|
|
|
<form action="/upload-binary/{%s h.Name %}"
|
|
|
|
method="post" enctype="multipart/form-data"
|
|
|
|
class="upload-binary">
|
|
|
|
<label for="upload-binary__input"></label>
|
|
|
|
<input type="file" id="upload-binary__input" name="binary">
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
<button type="submit" class="btn stick-to-bottom" value="Upload">{%s lc.Get("ui.attach_upload")%}</button>
|
2021-05-14 09:05:07 +00:00
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
</section>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2021-02-20 15:48:51 +00:00
|
|
|
{% 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 %}
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
{% func AttachmentHTMLRaw(h *hyphae.Hypha) %}{%= AttachmentHTML(h, l18n.New("en", "en")) %}{% endfunc %}
|
|
|
|
|
|
|
|
{% func AttachmentHTML(h *hyphae.Hypha, lc *l18n.Localizer) %}
|
2021-02-20 15:48:51 +00:00
|
|
|
{% 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 %}"/>
|
2021-09-06 17:46:34 +00:00
|
|
|
<p>{%s lc.Get("ui.media_novideo") %} <a href="/binary/{%s= h.Name %}">{%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>
|
|
|
|
<source src="/binary/{%s= h.Name %}"/>
|
2021-09-06 17:46:34 +00:00
|
|
|
<p>{%s lc.Get("ui.media_noaudio") %} <a href="/binary/{%s= h.Name %}">{%s lc.Get("ui.media_noaudio_link") %}</a></p>
|
2021-02-20 15:48:51 +00:00
|
|
|
</audio>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% default %}
|
|
|
|
<div class="binary-container binary-container_with-nothing">
|
2021-09-06 17:46:34 +00:00
|
|
|
<p><a href="/binary/{%s= h.Name %}">{%s lc.Get("ui.media_download") %}</a></p>
|
2021-02-20 15:48:51 +00:00
|
|
|
</div>
|
|
|
|
{% endswitch %}
|
|
|
|
{% endfunc %}
|