mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 19:56:16 +00:00
938a9e832d
Basically, it looks if the query is a substring of hypha names
187 lines
5.2 KiB
Plaintext
187 lines
5.2 KiB
Plaintext
{% import "path/filepath" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
|
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
|
|
|
{% func BaseHTML(title, body string, u *user.User, headElements ...string) %}
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>{%s title %}</title>
|
|
<link rel="shortcut icon" href="/static/favicon.ico">
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
<script src="/static/shortcuts.js"></script>
|
|
{% for _, el := range headElements %}{%s= el %}{% endfor %}
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<nav class="header-links main-width">
|
|
<ul class="header-links__list">
|
|
{%- for _, link := range cfg.HeaderLinks -%}
|
|
<li class="header-links__entry"><a class="header-links__link" href="{%s link.Href %}">{%s link.Display %}</a></li>
|
|
{%- endfor -%}
|
|
{%s= UserMenuHTML(u) %}
|
|
</ul>
|
|
</nav>
|
|
</header>
|
|
{%s= body %}
|
|
<template id="dialog-template">
|
|
<div class="dialog-backdrop"></div>
|
|
<div class="dialog" tabindex="0">
|
|
<div class="dialog__header">
|
|
<h1 class="dialog__title"></h1>
|
|
<button class="dialog__close-button" aria-label="Close this dialog"></button>
|
|
</div>
|
|
|
|
<div class="dialog__content"></div>
|
|
</div>
|
|
</template>
|
|
{%= CommonScripts() %}
|
|
</body>
|
|
</html>
|
|
{% endfunc %}
|
|
|
|
{% func PrimitiveSearchHTML(query string, generator func(string) <-chan string) %}
|
|
<div class="layout">
|
|
<main class="main-width primitive-search">
|
|
<ul class="primitive-search__results">
|
|
{% for hyphaName := range generator(query) %}
|
|
<li class="primitive-search__entry">
|
|
<a class="primitive-search__link wikilink" href="/hypha/{%s hyphaName %}">{%s hyphaName %}</a>
|
|
</li>
|
|
{% endfor %}
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func HelpHTML(content string) %}
|
|
<div class="layout">
|
|
<main class="main-width help">
|
|
<article>
|
|
{%s= content %}
|
|
</article>
|
|
</main>
|
|
{%s= helpTopicsHTML() %}
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func HelpEmptyErrorHTML() %}
|
|
<h1>This entry does not exist!</h1>
|
|
<p>Try finding a different entry that would help you.</p>
|
|
<p>If you want to write this entry by yourself, consider <a class="wikilink wikilink_external wikilink_https" href="https://github.com/bouncepaw/mycorrhiza">contributing</a> to Mycorrhiza Wiki directly.</p>
|
|
{% endfunc %}
|
|
|
|
{% func helpTopicsHTML() %}
|
|
<aside class="help-topics layout-card">
|
|
<h2 class="layout-card__title">Help topics</h2>
|
|
<ul class="help-topics__list">
|
|
<li>
|
|
<a href="/help/en">Main</a>
|
|
</li>
|
|
<li>
|
|
<a href="/help/en/hypha">Hypha</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/help/en/attachment">Attachment</a>
|
|
</li>
|
|
</ul
|
|
</li>
|
|
</ul>
|
|
</aside>
|
|
{% endfunc %}
|
|
|
|
{% 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 %}
|
|
<li><a href="/hypha/{%s cfg.UserHypha %}/{%s name %}">{%s name %}</a></li>
|
|
{% endfor %}</ol>
|
|
</section>
|
|
<section>
|
|
<h2>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>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 %}
|
|
|
|
{% func HyphaListHTML() %}
|
|
<div class="layout">
|
|
<main class="main-width">
|
|
<h1>List of hyphae</h1>
|
|
<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>
|
|
</main>
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func AboutHTML() %}
|
|
<div class="layout">
|
|
<main class="main-width">
|
|
<section>
|
|
<h1>About {%s cfg.WikiName %}</h1>
|
|
<ul>
|
|
<li><b><a href="https://mycorrhiza.wiki">Mycorrhiza Wiki</a> version:</b> 1.3.0</li>
|
|
{%- if cfg.UseAuth -%}
|
|
<li><b>User count:</b> {%dul user.Count() %}</li>
|
|
<li><b>Home page:</b> <a href="/">{%s cfg.HomeHypha %}</a></li>
|
|
<li><b>Administrators:</b> {%- for i, username := range user.ListUsersWithGroup("admin") -%}
|
|
{%- if i > 0 -%}<span aria-hidden="true">, </span>
|
|
{%- endif -%}
|
|
<a href="/hypha/{%s cfg.UserHypha %}/{%s username %}">{%s username %}</a>{%- endfor -%}</li>
|
|
{%- 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>
|
|
</div>
|
|
{% endfunc %}
|
|
|
|
{% func CommonScripts() %}
|
|
{% for _, scriptPath := range cfg.CommonScripts %}
|
|
<script src="{%s scriptPath %}"></script>
|
|
{% endfor %}
|
|
{% endfunc %}
|