1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00
mycorrhiza/views/user_list.qtpl
2022-03-21 00:24:40 +03:00

64 lines
1.8 KiB
Plaintext

{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "sort" %}
{% code
var hyphaListL10n = map[string]l10nEntry{
"heading": en("List of users").ru("Список пользователей"),
"administrators": en("Administrators").ru("Администраторы"),
"moderators": en("Moderators").ru("Модераторы"),
"editors": en("Editors").ru("Редакторы"),
}
%}
{% func UserList(lc *l18n.Localizer) %}
<div class="layout">
<main class="main-width user-list">
{% code
var get = func(key string) string {
return hyphaListL10n[key].get(lc.Locale)
}
var (
admins = make([]string, 0)
moderators = make([]string, 0)
editors = make([]string, 0)
)
for u := range user.YieldUsers() {
switch u.Group {
// What if we place the users into sorted slices?
case "admin":
admins = append(admins, u.Name)
case "moderator":
moderators = append(moderators, u.Name)
case "editor", "trusted":
editors = append(editors, u.Name)
}
}
sort.Strings(admins)
sort.Strings(moderators)
sort.Strings(editors)
%}
<h1>{%s get("heading") %}</h1>
<section>
<h2>{%s get("administrators") %}</h2>
<ol>{% for _, name := range admins %}
<li><a href="/hypha/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
<section>
<h2>{%s get("moderators") %}</h2>
<ol>{% for _, name := range moderators %}
<li><a href="/hypha/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
<section>
<h2>{%s get("editors") %}</h2>
<ol>{% for _, name := range editors %}
<li><a href="/hypha/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
</main>
</div>
{% endfunc %}