mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 19:56:16 +00:00
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
{% import "net/http" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
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"},
|
|
{"delete-ask", "Delete"},
|
|
}
|
|
%}
|
|
|
|
{% func navHTML(rq *http.Request, hyphaName, navType string, revisionHash ...string) %}
|
|
{% code
|
|
u := user.FromRequest(rq).OrAnon()
|
|
%}
|
|
<nav class="navlinks">
|
|
<ul>
|
|
{%- for _, entry := range navEntries -%}
|
|
{%- if navType == "revision" && entry.path == "revision" -%}
|
|
<li><b>{%s revisionHash[0] %}</b></li>
|
|
{%- elseif navType == entry.path -%}
|
|
<li><b>{%s entry.title %}</b></li>
|
|
{%- elseif entry.path != "revision" && u.Group.CanAccessRoute(entry.path) -%}
|
|
<li><a href="/{%s entry.path %}/{%s hyphaName %}">{%s entry.title %}</a></li>
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%s= userMenuHTML(u) %}
|
|
</ul>
|
|
</nav>
|
|
{% endfunc %}
|
|
|
|
{% func userMenuHTML(u *user.User) %}
|
|
<li class="navlinks__user">
|
|
{% if u.Group == user.UserAnon %}
|
|
<a href="/login">Login</a>
|
|
{% else %}
|
|
<a href="/page/{%s util.UserTree %}/{%s u.Name %}">{%s u.Name %}</a>
|
|
{% endif %}
|
|
</li>
|
|
{% endfunc %}
|
|
|