mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 05:20:26 +00:00
b87583ef28
Important changes: - UseFixedAuth is now UseAuth and toggles all kinds of authorization and registration - UseRegistration is now AllowRegistration to better reflect the meaning - LimitRegistration is now RegistrationLimit because it's not a boolean, it's a value (not "limit registration?", but "registration limit is ...") - registered-users.json is now users.json, because all users are stored there - user.AuthUsed is dropped in favor of new cfg.UseAuth which has the same meaning I hope I have not forgotten anything.
86 lines
2.5 KiB
Plaintext
86 lines
2.5 KiB
Plaintext
{% import "net/http" %}
|
|
{% import "strings" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% 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{
|
|
{"hypha", "Hypha"},
|
|
{"edit", "Edit"},
|
|
{"attachment", "Attachment"},
|
|
{"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 %}
|
|
|
|
{% func UserMenuHTML(u *user.User) %}
|
|
{% if cfg.UseAuth %}
|
|
<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="/hypha/{%s cfg.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s util.BeautifulName(u.Name) %}</a>
|
|
{% endif %}
|
|
</li>
|
|
{% endif %}
|
|
{% if cfg.UseAuth && cfg.AllowRegistration && u.Group == "anon" %}
|
|
<li class="header-links__entry header-links__entry_register">
|
|
<a href="/register" class="header-links__link">Register</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfunc %}
|
|
|
|
{% func RelativeHyphaeHTML(relatives string) %}
|
|
<aside class="relative-hyphae layout-card">
|
|
<h2 class="relative-hyphae__title layout-card__title">Relative hyphae</h2>
|
|
{%s= relatives %}
|
|
</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 %}
|