1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 19:56:16 +00:00
mycorrhiza/templates/common.qtpl

79 lines
2.2 KiB
Plaintext
Raw Normal View History

{% import "net/http" %}
2021-02-19 18:12:36 +00:00
{% import "strings" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/util" %}
2020-10-02 15:31:59 +00:00
This is the <nav> seen on top of many pages.
{% code
type navEntry struct {
path string
title string
}
var navEntries = []navEntry{
{"page", "Hypha"},
{"edit", "Edit"},
{"history", "History"},
{"revision", "NOT REACHED"},
{"rename-ask", "Rename"},
{"delete-ask", "Delete"},
2021-01-26 05:41:57 +00:00
{"text", "Raw text"},
2020-10-02 15:31:59 +00:00
}
%}
{% func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) %}
{% code
u := user.FromRequest(rq)
%}
2021-01-25 18:37:21 +00:00
<nav class="hypha-tabs main-width">
2021-01-20 13:53:30 +00:00
<ul class="hypha-tabs__flex">
2020-10-02 15:31:59 +00:00
{%- for _, entry := range navEntries -%}
{%- if navType == "revision" && entry.path == "revision" -%}
2021-01-20 13:53:30 +00:00
<li class="hypha-tabs__tab hypha-tabs__tab_active">
2021-01-25 18:37:21 +00:00
<span class="hypha-tabs__selection">{%s revisionHash[0] %}</span>
2021-01-20 13:53:30 +00:00
</li>
2020-10-02 15:31:59 +00:00
{%- elseif navType == entry.path -%}
2021-01-20 13:53:30 +00:00
<li class="hypha-tabs__tab hypha-tabs__tab_active">
2021-01-25 18:37:21 +00:00
<span class="hypha-tabs__selection">{%s entry.title %}</span>
2021-01-20 13:53:30 +00:00
</li>
{%- elseif entry.path != "revision" && u.CanProceed(entry.path) -%}
2021-01-20 13:53:30 +00:00
<li class="hypha-tabs__tab">
2021-01-25 18:37:21 +00:00
<a class="hypha-tabs__link" href="/{%s entry.path %}/{%s hyphaName %}">{%s entry.title %}</a>
2021-01-20 13:53:30 +00:00
</li>
2020-10-02 15:31:59 +00:00
{%- endif -%}
{%- endfor -%}
</ul>
</nav>
{% endfunc %}
{% func userMenuHTML(u *user.User) %}
2021-01-24 07:30:14 +00:00
{% if user.AuthUsed %}
<li class="header-links__entry header-links__entry_user">
{% if u.Group == "anon" %}
<a href="/login" class="header-links__link">Login</a>
{% else %}
<a href="/page/{%s util.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s u.Name %}</a>
{% endif %}
2021-01-24 07:30:14 +00:00
</li>
{% endif %}
{% endfunc %}
2021-01-26 05:41:57 +00:00
{% func relativeHyphae(relatives string) %}
<aside class="relative-hyphae layout-card">
2021-02-19 09:23:57 +00:00
<h2 class="relative-hyphae__title layout-card__title">Relative hyphae</h2>
2021-01-26 05:41:57 +00:00
{%s= relatives %}
</aside>
{% endfunc %}
2021-02-19 09:23:57 +00:00
2021-02-19 18:12:36 +00:00
{% func subhyphaeMatrix(subhyphae string) %}
{% if strings.TrimSpace(subhyphae) != "" %}
<section class="subhyphae">
<h2 class="subhyphae__title">Subhyphae</h2>
<nav class="subhyphae__nav">
<ul class="subhyphae__list">
{%s= subhyphae %}
</ul>
</nav>
</section>
{% endif %}
{% endfunc %}