1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-12-07 08:58:07 +00:00

Move stuff.qtpl and admin.qtpl to views/stuff.qtpl

This commit is contained in:
bouncepaw
2021-02-22 23:19:28 +05:00
parent e72752a484
commit ecbd23b3a5
7 changed files with 278 additions and 293 deletions

157
views/stuff.qtpl Normal file
View File

@@ -0,0 +1,157 @@
{% import "github.com/bouncepaw/mycorrhiza/util" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% func BaseHTML(title, body string, u *user.User, headElements ...string) %}
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/static/common.css">
<title>{%s title %}</title>
{% for _, el := range headElements %}{%s= el %}{% endfor %}
</head>
<body>
<header>
<nav class="header-links main-width">
<ul class="header-links__list">
{%- for _, link := range util.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 %}
</body>
</html>
{% 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="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
<section>
<h2>Moderators</h2>
<ol>{% for _, name := range moderators %}
<li><a href="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
<section>
<h2>Editors</h2>
<ol>{% for _, name := range editors %}
<li><a href="/page/{%s util.UserHypha %}/{%s name %}">{%s name %}</a></li>
{% endfor %}</ol>
</section>
</main>
</div>
{% endfunc %}
{% func HyphaListHTML(tbody string, pageCount int) %}
<div class="layout">
<main class="main-width">
<h1>List of hyphae</h1>
<p>This wiki has {%d pageCount %} hyphae.</p>
<table>
<thead>
<tr>
<th>Full name</th>
<th>Binary part type</th>
</tr>
</thead>
<tbody>
{%s= tbody %}
</tbody>
</table>
</main>
</div>
{% endfunc %}
{% func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) %}
<tr>
<td><a href="/page/{%s hyphaName %}">{%s hyphaName %}</a></td>
{% if binaryPresent %}
<td>{%s binaryMime %}</td>
{% else %}
<td></td>
{% endif %}
</tr>
{% endfunc %}
{% func AboutHTML() %}
<div class="layout">
<main class="main-width">
<section>
<h1>About {%s util.SiteName %}</h1>
<ul>
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> β 0.13 indev</li>
{%- if user.AuthUsed -%}
<li><b>User count:</b> {%d user.Count() %}</li>
<li><b>Home page:</b> <a href="/">{%s util.HomePage %}</a></li>
<li><b>Administrators:</b> {%- for i, username := range user.ListUsersWithGroup("admin") -%}
{%- if i > 0 -%}<span aria-hidden="true">, </span>
{%- endif -%}
<a href="/page/{%s util.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 AdminPanelHTML() %}
<div class="layout">
<main class="main-width">
<h1>Admininstrative functions</h1>
<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>
</section>
</main>
</div>
{% endfunc %}

539
views/stuff.qtpl.go Normal file
View File

@@ -0,0 +1,539 @@
// Code generated by qtc from "stuff.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/stuff.qtpl:1
package views
//line views/stuff.qtpl:1
import "github.com/bouncepaw/mycorrhiza/util"
//line views/stuff.qtpl:2
import "github.com/bouncepaw/mycorrhiza/user"
//line views/stuff.qtpl:4
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/stuff.qtpl:4
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/stuff.qtpl:4
func StreamBaseHTML(qw422016 *qt422016.Writer, title, body string, u *user.User, headElements ...string) {
//line views/stuff.qtpl:4
qw422016.N().S(`
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/static/common.css">
<title>`)
//line views/stuff.qtpl:11
qw422016.E().S(title)
//line views/stuff.qtpl:11
qw422016.N().S(`</title>
`)
//line views/stuff.qtpl:12
for _, el := range headElements {
//line views/stuff.qtpl:12
qw422016.N().S(el)
//line views/stuff.qtpl:12
}
//line views/stuff.qtpl:12
qw422016.N().S(`
</head>
<body>
<header>
<nav class="header-links main-width">
<ul class="header-links__list">
`)
//line views/stuff.qtpl:18
for _, link := range util.HeaderLinks {
//line views/stuff.qtpl:18
qw422016.N().S(` <li class="header-links__entry"><a class="header-links__link" href="`)
//line views/stuff.qtpl:19
qw422016.E().S(link.Href)
//line views/stuff.qtpl:19
qw422016.N().S(`">`)
//line views/stuff.qtpl:19
qw422016.E().S(link.Display)
//line views/stuff.qtpl:19
qw422016.N().S(`</a></li>
`)
//line views/stuff.qtpl:20
}
//line views/stuff.qtpl:20
qw422016.N().S(` `)
//line views/stuff.qtpl:21
qw422016.N().S(UserMenuHTML(u))
//line views/stuff.qtpl:21
qw422016.N().S(`
</ul>
</nav>
</header>
`)
//line views/stuff.qtpl:25
qw422016.N().S(body)
//line views/stuff.qtpl:25
qw422016.N().S(`
</body>
</html>
`)
//line views/stuff.qtpl:28
}
//line views/stuff.qtpl:28
func WriteBaseHTML(qq422016 qtio422016.Writer, title, body string, u *user.User, headElements ...string) {
//line views/stuff.qtpl:28
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:28
StreamBaseHTML(qw422016, title, body, u, headElements...)
//line views/stuff.qtpl:28
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:28
}
//line views/stuff.qtpl:28
func BaseHTML(title, body string, u *user.User, headElements ...string) string {
//line views/stuff.qtpl:28
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:28
WriteBaseHTML(qb422016, title, body, u, headElements...)
//line views/stuff.qtpl:28
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:28
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:28
return qs422016
//line views/stuff.qtpl:28
}
//line views/stuff.qtpl:30
func StreamUserListHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:30
qw422016.N().S(`
<div class="layout">
<main class="main-width user-list">
<h1>List of users</h1>
`)
//line views/stuff.qtpl:35
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)
}
}
//line views/stuff.qtpl:50
qw422016.N().S(`
<section>
<h2>Admins</h2>
<ol>`)
//line views/stuff.qtpl:53
for _, name := range admins {
//line views/stuff.qtpl:53
qw422016.N().S(`
<li><a href="/page/`)
//line views/stuff.qtpl:54
qw422016.E().S(util.UserHypha)
//line views/stuff.qtpl:54
qw422016.N().S(`/`)
//line views/stuff.qtpl:54
qw422016.E().S(name)
//line views/stuff.qtpl:54
qw422016.N().S(`">`)
//line views/stuff.qtpl:54
qw422016.E().S(name)
//line views/stuff.qtpl:54
qw422016.N().S(`</a></li>
`)
//line views/stuff.qtpl:55
}
//line views/stuff.qtpl:55
qw422016.N().S(`</ol>
</section>
<section>
<h2>Moderators</h2>
<ol>`)
//line views/stuff.qtpl:59
for _, name := range moderators {
//line views/stuff.qtpl:59
qw422016.N().S(`
<li><a href="/page/`)
//line views/stuff.qtpl:60
qw422016.E().S(util.UserHypha)
//line views/stuff.qtpl:60
qw422016.N().S(`/`)
//line views/stuff.qtpl:60
qw422016.E().S(name)
//line views/stuff.qtpl:60
qw422016.N().S(`">`)
//line views/stuff.qtpl:60
qw422016.E().S(name)
//line views/stuff.qtpl:60
qw422016.N().S(`</a></li>
`)
//line views/stuff.qtpl:61
}
//line views/stuff.qtpl:61
qw422016.N().S(`</ol>
</section>
<section>
<h2>Editors</h2>
<ol>`)
//line views/stuff.qtpl:65
for _, name := range editors {
//line views/stuff.qtpl:65
qw422016.N().S(`
<li><a href="/page/`)
//line views/stuff.qtpl:66
qw422016.E().S(util.UserHypha)
//line views/stuff.qtpl:66
qw422016.N().S(`/`)
//line views/stuff.qtpl:66
qw422016.E().S(name)
//line views/stuff.qtpl:66
qw422016.N().S(`">`)
//line views/stuff.qtpl:66
qw422016.E().S(name)
//line views/stuff.qtpl:66
qw422016.N().S(`</a></li>
`)
//line views/stuff.qtpl:67
}
//line views/stuff.qtpl:67
qw422016.N().S(`</ol>
</section>
</main>
</div>
`)
//line views/stuff.qtpl:71
}
//line views/stuff.qtpl:71
func WriteUserListHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:71
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:71
StreamUserListHTML(qw422016)
//line views/stuff.qtpl:71
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:71
}
//line views/stuff.qtpl:71
func UserListHTML() string {
//line views/stuff.qtpl:71
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:71
WriteUserListHTML(qb422016)
//line views/stuff.qtpl:71
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:71
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:71
return qs422016
//line views/stuff.qtpl:71
}
//line views/stuff.qtpl:73
func StreamHyphaListHTML(qw422016 *qt422016.Writer, tbody string, pageCount int) {
//line views/stuff.qtpl:73
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>List of hyphae</h1>
<p>This wiki has `)
//line views/stuff.qtpl:77
qw422016.N().D(pageCount)
//line views/stuff.qtpl:77
qw422016.N().S(` hyphae.</p>
<table>
<thead>
<tr>
<th>Full name</th>
<th>Binary part type</th>
</tr>
</thead>
<tbody>
`)
//line views/stuff.qtpl:86
qw422016.N().S(tbody)
//line views/stuff.qtpl:86
qw422016.N().S(`
</tbody>
</table>
</main>
</div>
`)
//line views/stuff.qtpl:91
}
//line views/stuff.qtpl:91
func WriteHyphaListHTML(qq422016 qtio422016.Writer, tbody string, pageCount int) {
//line views/stuff.qtpl:91
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:91
StreamHyphaListHTML(qw422016, tbody, pageCount)
//line views/stuff.qtpl:91
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:91
}
//line views/stuff.qtpl:91
func HyphaListHTML(tbody string, pageCount int) string {
//line views/stuff.qtpl:91
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:91
WriteHyphaListHTML(qb422016, tbody, pageCount)
//line views/stuff.qtpl:91
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:91
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:91
return qs422016
//line views/stuff.qtpl:91
}
//line views/stuff.qtpl:93
func StreamHyphaListRowHTML(qw422016 *qt422016.Writer, hyphaName, binaryMime string, binaryPresent bool) {
//line views/stuff.qtpl:93
qw422016.N().S(`
<tr>
<td><a href="/page/`)
//line views/stuff.qtpl:95
qw422016.E().S(hyphaName)
//line views/stuff.qtpl:95
qw422016.N().S(`">`)
//line views/stuff.qtpl:95
qw422016.E().S(hyphaName)
//line views/stuff.qtpl:95
qw422016.N().S(`</a></td>
`)
//line views/stuff.qtpl:96
if binaryPresent {
//line views/stuff.qtpl:96
qw422016.N().S(`
<td>`)
//line views/stuff.qtpl:97
qw422016.E().S(binaryMime)
//line views/stuff.qtpl:97
qw422016.N().S(`</td>
`)
//line views/stuff.qtpl:98
} else {
//line views/stuff.qtpl:98
qw422016.N().S(`
<td></td>
`)
//line views/stuff.qtpl:100
}
//line views/stuff.qtpl:100
qw422016.N().S(`
</tr>
`)
//line views/stuff.qtpl:102
}
//line views/stuff.qtpl:102
func WriteHyphaListRowHTML(qq422016 qtio422016.Writer, hyphaName, binaryMime string, binaryPresent bool) {
//line views/stuff.qtpl:102
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:102
StreamHyphaListRowHTML(qw422016, hyphaName, binaryMime, binaryPresent)
//line views/stuff.qtpl:102
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:102
}
//line views/stuff.qtpl:102
func HyphaListRowHTML(hyphaName, binaryMime string, binaryPresent bool) string {
//line views/stuff.qtpl:102
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:102
WriteHyphaListRowHTML(qb422016, hyphaName, binaryMime, binaryPresent)
//line views/stuff.qtpl:102
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:102
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:102
return qs422016
//line views/stuff.qtpl:102
}
//line views/stuff.qtpl:104
func StreamAboutHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:104
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<section>
<h1>About `)
//line views/stuff.qtpl:108
qw422016.E().S(util.SiteName)
//line views/stuff.qtpl:108
qw422016.N().S(`</h1>
<ul>
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> β 0.13 indev</li>
`)
//line views/stuff.qtpl:111
if user.AuthUsed {
//line views/stuff.qtpl:111
qw422016.N().S(` <li><b>User count:</b> `)
//line views/stuff.qtpl:112
qw422016.N().D(user.Count())
//line views/stuff.qtpl:112
qw422016.N().S(`</li>
<li><b>Home page:</b> <a href="/">`)
//line views/stuff.qtpl:113
qw422016.E().S(util.HomePage)
//line views/stuff.qtpl:113
qw422016.N().S(`</a></li>
<li><b>Administrators:</b>`)
//line views/stuff.qtpl:114
for i, username := range user.ListUsersWithGroup("admin") {
//line views/stuff.qtpl:115
if i > 0 {
//line views/stuff.qtpl:115
qw422016.N().S(`<span aria-hidden="true">, </span>
`)
//line views/stuff.qtpl:116
}
//line views/stuff.qtpl:116
qw422016.N().S(` <a href="/page/`)
//line views/stuff.qtpl:117
qw422016.E().S(util.UserHypha)
//line views/stuff.qtpl:117
qw422016.N().S(`/`)
//line views/stuff.qtpl:117
qw422016.E().S(username)
//line views/stuff.qtpl:117
qw422016.N().S(`">`)
//line views/stuff.qtpl:117
qw422016.E().S(username)
//line views/stuff.qtpl:117
qw422016.N().S(`</a>`)
//line views/stuff.qtpl:117
}
//line views/stuff.qtpl:117
qw422016.N().S(`</li>
`)
//line views/stuff.qtpl:118
} else {
//line views/stuff.qtpl:118
qw422016.N().S(` <li>This wiki does not use authorization</li>
`)
//line views/stuff.qtpl:120
}
//line views/stuff.qtpl:120
qw422016.N().S(` </ul>
<p>See <a href="/list">/list</a> for information about hyphae on this wiki.</p>
</section>
</main>
</div>
`)
//line views/stuff.qtpl:126
}
//line views/stuff.qtpl:126
func WriteAboutHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:126
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:126
StreamAboutHTML(qw422016)
//line views/stuff.qtpl:126
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:126
}
//line views/stuff.qtpl:126
func AboutHTML() string {
//line views/stuff.qtpl:126
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:126
WriteAboutHTML(qb422016)
//line views/stuff.qtpl:126
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:126
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:126
return qs422016
//line views/stuff.qtpl:126
}
//line views/stuff.qtpl:128
func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:128
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>Admininstrative functions</h1>
<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>
</section>
</main>
</div>
`)
//line views/stuff.qtpl:157
}
//line views/stuff.qtpl:157
func WriteAdminPanelHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:157
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:157
StreamAdminPanelHTML(qw422016)
//line views/stuff.qtpl:157
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:157
}
//line views/stuff.qtpl:157
func AdminPanelHTML() string {
//line views/stuff.qtpl:157
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:157
WriteAdminPanelHTML(qb422016)
//line views/stuff.qtpl:157
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:157
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:157
return qs422016
//line views/stuff.qtpl:157
}