2021-02-22 18:37:23 +00:00
|
|
|
{% import "path/filepath" %}
|
2021-05-09 09:36:39 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
2021-02-22 18:37:23 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
2021-01-23 13:45:17 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
2021-02-22 18:37:23 +00:00
|
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
2021-01-23 13:45:17 +00:00
|
|
|
|
2021-01-24 07:30:14 +00:00
|
|
|
{% func BaseHTML(title, body string, u *user.User, headElements ...string) %}
|
2020-08-31 17:52:26 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2021-02-22 18:19:28 +00:00
|
|
|
<meta charset="utf-8">
|
2020-08-31 17:52:26 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="/static/common.css">
|
|
|
|
<title>{%s title %}</title>
|
2020-12-17 12:59:59 +00:00
|
|
|
{% for _, el := range headElements %}{%s= el %}{% endfor %}
|
2020-08-31 17:52:26 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2021-01-23 19:00:58 +00:00
|
|
|
<header>
|
2021-01-25 18:37:21 +00:00
|
|
|
<nav class="header-links main-width">
|
2021-01-23 19:00:58 +00:00
|
|
|
<ul class="header-links__list">
|
2021-05-11 09:35:46 +00:00
|
|
|
{%- for _, link := range cfg.HeaderLinks -%}
|
2021-01-23 19:00:58 +00:00
|
|
|
<li class="header-links__entry"><a class="header-links__link" href="{%s link.Href %}">{%s link.Display %}</a></li>
|
|
|
|
{%- endfor -%}
|
2021-02-22 18:19:28 +00:00
|
|
|
{%s= UserMenuHTML(u) %}
|
2021-01-23 19:00:58 +00:00
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</header>
|
2020-08-31 17:52:26 +00:00
|
|
|
{%s= body %}
|
2021-05-22 18:05:14 +00:00
|
|
|
{%= omnipresentScripts() %}
|
2020-08-31 17:52:26 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2021-01-30 18:21:50 +00:00
|
|
|
{% func UserListHTML() %}
|
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width user-list">
|
|
|
|
<h1>List of users</h1>
|
|
|
|
{% code
|
|
|
|
var (
|
|
|
|
admins = make([]string, 0)
|
|
|
|
moderators = make([]string, 0)
|
|
|
|
editors = make([]string, 0)
|
|
|
|
)
|
|
|
|
for u := range user.YieldUsers() {
|
|
|
|
switch u.Group {
|
|
|
|
case "admin":
|
|
|
|
admins = append(admins, u.Name)
|
|
|
|
case "moderator":
|
|
|
|
moderators = append(moderators, u.Name)
|
|
|
|
case "editor", "trusted":
|
|
|
|
editors = append(editors, u.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
<section>
|
|
|
|
<h2>Admins</h2>
|
|
|
|
<ol>{% for _, name := range admins %}
|
2021-05-09 09:36:39 +00:00
|
|
|
<li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
|
2021-01-30 18:21:50 +00:00
|
|
|
{% endfor %}</ol>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<h2>Moderators</h2>
|
|
|
|
<ol>{% for _, name := range moderators %}
|
2021-05-09 09:36:39 +00:00
|
|
|
<li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
|
2021-01-30 18:21:50 +00:00
|
|
|
{% endfor %}</ol>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<h2>Editors</h2>
|
|
|
|
<ol>{% for _, name := range editors %}
|
2021-05-09 09:36:39 +00:00
|
|
|
<li><a href="/page/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
|
2021-01-30 18:21:50 +00:00
|
|
|
{% endfor %}</ol>
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
|
|
|
|
2021-02-22 18:37:23 +00:00
|
|
|
{% func HyphaListHTML() %}
|
2021-01-26 05:41:57 +00:00
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
2020-08-31 18:16:22 +00:00
|
|
|
<h1>List of hyphae</h1>
|
2021-02-22 18:37:23 +00:00
|
|
|
<p>This wiki has {%d hyphae.Count() %} hyphae.</p>
|
|
|
|
<ul class="hypha-list">
|
|
|
|
{% for h := range hyphae.YieldExistingHyphae() %}
|
|
|
|
<li class="hypha-list__entry">
|
|
|
|
<a class="hypha-list__link" href="/hypha/{%s h.Name %}">{%s util.BeautifulName(h.Name) %}</a>
|
|
|
|
{% if h.BinaryPath != "" %}
|
|
|
|
<span class="hypha-list__amnt-type">{%s filepath.Ext(h.BinaryPath)[1:] %}</span>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
2020-08-31 17:52:26 +00:00
|
|
|
</main>
|
2021-01-26 05:41:57 +00:00
|
|
|
</div>
|
2020-08-31 17:52:26 +00:00
|
|
|
{% endfunc %}
|
2020-08-31 18:16:22 +00:00
|
|
|
|
2021-01-23 13:45:17 +00:00
|
|
|
{% func AboutHTML() %}
|
2021-01-26 05:41:57 +00:00
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
2021-01-23 13:45:17 +00:00
|
|
|
<section>
|
2021-05-09 09:36:39 +00:00
|
|
|
<h1>About {%s cfg.WikiName %}</h1>
|
2021-01-23 13:45:17 +00:00
|
|
|
<ul>
|
2021-05-01 16:26:21 +00:00
|
|
|
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.2.0 indev</li>
|
2021-01-23 13:45:17 +00:00
|
|
|
{%- if user.AuthUsed -%}
|
|
|
|
<li><b>User count:</b> {%d user.Count() %}</li>
|
2021-05-09 09:36:39 +00:00
|
|
|
<li><b>Home page:</b> <a href="/">{%s cfg.HomeHypha %}</a></li>
|
2021-01-23 13:45:17 +00:00
|
|
|
<li><b>Administrators:</b> {%- for i, username := range user.ListUsersWithGroup("admin") -%}
|
|
|
|
{%- if i > 0 -%}<span aria-hidden="true">, </span>
|
|
|
|
{%- endif -%}
|
2021-05-09 09:36:39 +00:00
|
|
|
<a href="/page/{%s cfg.UserHypha %}/{%s username %}">{%s username %}</a>{%- endfor -%}</li>
|
2021-01-23 13:45:17 +00:00
|
|
|
{%- else -%}
|
|
|
|
<li>This wiki does not use authorization</li>
|
|
|
|
{%- endif -%}
|
|
|
|
</ul>
|
|
|
|
<p>See <a href="/list">/list</a> for information about hyphae on this wiki.</p>
|
|
|
|
</section>
|
|
|
|
</main>
|
2021-01-26 05:41:57 +00:00
|
|
|
</div>
|
2021-01-23 13:45:17 +00:00
|
|
|
{% endfunc %}
|
2021-02-22 18:19:28 +00:00
|
|
|
|
|
|
|
{% func AdminPanelHTML() %}
|
|
|
|
<div class="layout">
|
|
|
|
<main class="main-width">
|
2021-03-06 07:38:08 +00:00
|
|
|
<h1>Administrative functions</h1>
|
2021-02-22 18:19:28 +00:00
|
|
|
<section>
|
|
|
|
<h2>Safe things</h2>
|
|
|
|
<ul>
|
|
|
|
<li><a href="/about">About this wiki<a></li>
|
|
|
|
<li><a href="/user-list">User list</a></li>
|
|
|
|
<li><a href="/update-header-links">Update header links</a></li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<h2>Dangerous things</h2>
|
|
|
|
<form action="/admin/shutdown" method="POST" style="float:left">
|
|
|
|
<fieldset>
|
|
|
|
<legend>Shutdown wiki</legend>
|
|
|
|
<input type="submit">
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
<form action="/reindex" method="GET" style="float:left">
|
|
|
|
<fieldset>
|
|
|
|
<legend>Reindex hyphae</legend>
|
|
|
|
<input type="submit">
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
2021-03-14 13:29:57 +00:00
|
|
|
<form action="/admin/reindex-users" method="POST" style="float:left">
|
|
|
|
<fieldset>
|
|
|
|
<legend>Reindex users</legend>
|
|
|
|
<input type="submit">
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
2021-02-22 18:19:28 +00:00
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
{% endfunc %}
|
2021-05-22 18:05:14 +00:00
|
|
|
|
|
|
|
{% func omnipresentScripts() %}
|
|
|
|
{% for _, scriptPath := range cfg.OmnipresentScripts %}
|
|
|
|
<script src="{%s scriptPath %}"></script>
|
|
|
|
{% endfor %}
|
|
|
|
{% endfunc %}
|