mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 11:46:16 +00:00
51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
{% import "github.com/bouncepaw/mycorrhiza/backlinks" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/viewutil" %}
|
|
|
|
{% func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) %}
|
|
{% code flag := true %}
|
|
{% switch h.(type) %}
|
|
{% case *hyphae.EmptyHypha %}
|
|
{% code flag = !hasToExist %}
|
|
{% endswitch %}
|
|
{% if u.CanProceed(action) && flag %}
|
|
<li class="hypha-info__entry hypha-info__entry_{%s action %}">
|
|
<a class="hypha-info__link" href="/{%s action %}/{%s h.CanonicalName() %}">{%s displayText %}</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfunc %}
|
|
|
|
{% func hyphaInfo(meta viewutil.Meta, h hyphae.Hypha) %}
|
|
{% code
|
|
u := meta.U
|
|
lc := meta.Lc
|
|
backs := backlinks.BacklinksCount(h.CanonicalName())
|
|
%}
|
|
<nav class="hypha-info">
|
|
<ul class="hypha-info__list">
|
|
{%= hyphaInfoEntry(h, u, "history", false, lc.Get("ui.history_link")) %}
|
|
{%= hyphaInfoEntry(h, u, "rename", true, lc.Get("ui.rename_link")) %}
|
|
{%= hyphaInfoEntry(h, u, "delete", true, lc.Get("ui.delete_link")) %}
|
|
{%= hyphaInfoEntry(h, u, "text", true, lc.Get("ui.text_link")) %}
|
|
{% switch h := h.(type) %}
|
|
{% case *hyphae.TextualHypha %}
|
|
{%= hyphaInfoEntry(h, u, "media", true, lc.Get("ui.media_link_for_textual")) %}
|
|
{% default %}
|
|
{%= hyphaInfoEntry(h, u, "media", true, lc.Get("ui.media_link")) %}
|
|
{% endswitch %}
|
|
{%= hyphaInfoEntry(h, u, "backlinks", false, lc.GetPlural("ui.backlinks_link", backs)) %}
|
|
</ul>
|
|
</nav>
|
|
{% endfunc %}
|
|
|
|
{% func commonScripts() %}
|
|
{% for _, scriptPath := range cfg.CommonScripts %}
|
|
<script src="{%s scriptPath %}"></script>
|
|
{% endfor %}
|
|
{% endfunc %}
|
|
|
|
{% func beautifulLink(hyphaName string) %}<a href="/hypha/{%s= hyphaName %}">{%s util.BeautifulName(hyphaName) %}</a>{% endfunc %}
|