1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 13:30:26 +00:00
mycorrhiza/views/nav.qtpl

67 lines
1.8 KiB
Plaintext
Raw Normal View History

2021-02-20 16:14:33 +00:00
{% import "net/http" %}
{% import "strings" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
This is the <nav> seen on top of many pages.
{% code
type navEntry struct {
path string
title string
}
var navEntries = []navEntry{
2021-06-14 07:13:29 +00:00
{"hypha", "Hypha"},
2021-02-20 16:14:33 +00:00
{"edit", "Edit"},
2021-02-24 17:34:42 +00:00
{"attachment", "Attachment"},
2021-02-20 16:14:33 +00:00
{"history", "History"},
{"revision", "NOT REACHED"},
{"rename-ask", "Rename"},
{"delete-ask", "Delete"},
{"text", "Raw text"},
}
%}
{% func NavHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) %}
{% code
u := user.FromRequest(rq)
%}
<nav class="hypha-tabs main-width">
<ul class="hypha-tabs__flex">
{%- for _, entry := range navEntries -%}
{%- if navType == "revision" && entry.path == "revision" -%}
<li class="hypha-tabs__tab hypha-tabs__tab_active">
<span class="hypha-tabs__selection">{%s revisionHash[0] %}</span>
</li>
{%- elseif navType == entry.path -%}
<li class="hypha-tabs__tab hypha-tabs__tab_active">
<span class="hypha-tabs__selection">{%s entry.title %}</span>
</li>
{%- elseif entry.path != "revision" && u.CanProceed(entry.path) -%}
<li class="hypha-tabs__tab">
<a class="hypha-tabs__link" href="/{%s entry.path %}/{%s hyphaName %}">{%s entry.title %}</a>
</li>
{%- endif -%}
{%- endfor -%}
</ul>
</nav>
{% endfunc %}
2021-07-12 15:23:25 +00:00
{% func siblingHyphaeHTML(siblings string) %}
<aside class="sibling-hyphae layout-card">
<h2 class="sibling-hyphae__title layout-card__title">Sibling hyphae</h2>
{%s= siblings %}
2021-02-20 16:14:33 +00:00
</aside>
{% endfunc %}
{% func SubhyphaeHTML(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 %}