2020-11-16 15:26:03 +00:00
|
|
|
{% import "net/http" %}
|
|
|
|
{% 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"},
|
|
|
|
{"text", "Raw text"},
|
|
|
|
{"history", "History"},
|
|
|
|
{"revision", "NOT REACHED"},
|
|
|
|
{"rename-ask", "Rename"},
|
2020-11-16 15:26:03 +00:00
|
|
|
{"delete-ask", "Delete"},
|
2020-10-02 15:31:59 +00:00
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2020-11-16 15:26:03 +00:00
|
|
|
{% func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) %}
|
2021-01-09 20:49:48 +00:00
|
|
|
{% code
|
|
|
|
u := user.FromRequest(rq)
|
2020-11-16 15:26:03 +00:00
|
|
|
%}
|
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>
|
2021-01-09 20:49:48 +00:00
|
|
|
{%- 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 %}
|
2020-11-16 15:26:03 +00:00
|
|
|
|
|
|
|
{% 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>
|
2020-11-29 17:09:02 +00:00
|
|
|
{% endif %}
|
2021-01-24 07:30:14 +00:00
|
|
|
</li>
|
|
|
|
{% endif %}
|
2020-11-16 15:26:03 +00:00
|
|
|
{% endfunc %}
|
|
|
|
|