1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-21 07:46:52 +00:00

Link the user panel from the admin panel

This commit is contained in:
Timur Ismagilov 2021-06-29 23:43:04 +05:00
parent 86020d6d97
commit b8420c81a8
7 changed files with 199 additions and 197 deletions

4
go.mod
View File

@ -3,7 +3,7 @@ module github.com/bouncepaw/mycorrhiza
go 1.16
require (
github.com/bouncepaw/mycomarkup v0.5.5
github.com/bouncepaw/mycomarkup v0.5.6
github.com/go-ini/ini v1.62.0
github.com/gorilla/feeds v1.1.1
github.com/kr/pretty v0.2.1 // indirect
@ -14,4 +14,4 @@ require (
)
// Use this trick for testing of mycomarkup:
// replace github.com/bouncepaw/mycomarkup v0.5.5 => "/Users/bouncepaw/GolandProjects/mycomarkup"
// replace github.com/bouncepaw/mycomarkup v0.5.6 => "/Users/bouncepaw/GolandProjects/mycomarkup"

4
go.sum
View File

@ -1,6 +1,6 @@
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/bouncepaw/mycomarkup v0.5.5 h1:dEZcNDUQKxwOITkhvE8Zf5HDuYJ4C8c1K8mxSY0UNE8=
github.com/bouncepaw/mycomarkup v0.5.5/go.mod h1:0n6thlGGgrx2Y/2NaaUH4qHW4v1xJ+EpW7yMFUxNRIg=
github.com/bouncepaw/mycomarkup v0.5.6 h1:uTHuVbQI00SVdlD2SjiXpXX9E/qUEXTIObNvJFEIfV0=
github.com/bouncepaw/mycomarkup v0.5.6/go.mod h1:0n6thlGGgrx2Y/2NaaUH4qHW4v1xJ+EpW7yMFUxNRIg=
github.com/go-ini/ini v1.62.0 h1:7VJT/ZXjzqSrvtraFp4ONq80hTcRQth1c9ZnQ3uNQvU=
github.com/go-ini/ini v1.62.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=

View File

@ -1,5 +1,43 @@
{% import "github.com/bouncepaw/mycorrhiza/user" %}
{% func AdminPanelHTML() %}
<div class="layout">
<main class="main-width">
<h1>Administrative 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>
<li><a href="/admin/users">Manage users</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" class="btn">
</fieldset>
</form>
<form action="/reindex" method="GET" style="float:left">
<fieldset>
<legend>Reindex hyphae</legend>
<input type="submit" class="btn">
</fieldset>
</form>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit" class="btn">
</fieldset>
</form>
</section>
</main>
</div>
{% endfunc %}
{% func AdminUsersPanelHTML(userList []*user.User) %}
<div class="layout">
<main class="main-width">

View File

@ -21,10 +21,79 @@ var (
)
//line views/admin.qtpl:3
func StreamAdminUsersPanelHTML(qw422016 *qt422016.Writer, userList []*user.User) {
func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
//line views/admin.qtpl:3
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>Administrative 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>
<li><a href="/admin/users">Manage users</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" class="btn">
</fieldset>
</form>
<form action="/reindex" method="GET" style="float:left">
<fieldset>
<legend>Reindex hyphae</legend>
<input type="submit" class="btn">
</fieldset>
</form>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit" class="btn">
</fieldset>
</form>
</section>
</main>
</div>
`)
//line views/admin.qtpl:39
}
//line views/admin.qtpl:39
func WriteAdminPanelHTML(qq422016 qtio422016.Writer) {
//line views/admin.qtpl:39
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:39
StreamAdminPanelHTML(qw422016)
//line views/admin.qtpl:39
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:39
}
//line views/admin.qtpl:39
func AdminPanelHTML() string {
//line views/admin.qtpl:39
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:39
WriteAdminPanelHTML(qb422016)
//line views/admin.qtpl:39
qs422016 := string(qb422016.B)
//line views/admin.qtpl:39
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:39
return qs422016
//line views/admin.qtpl:39
}
//line views/admin.qtpl:41
func StreamAdminUsersPanelHTML(qw422016 *qt422016.Writer, userList []*user.User) {
//line views/admin.qtpl:41
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>Manage users</h1>
@ -45,132 +114,132 @@ func StreamAdminUsersPanelHTML(qw422016 *qt422016.Writer, userList []*user.User)
</thead>
<tbody>
`)
//line views/admin.qtpl:24
//line views/admin.qtpl:62
for _, u := range userList {
//line views/admin.qtpl:24
//line views/admin.qtpl:62
qw422016.N().S(`
<tr>
<td>`)
//line views/admin.qtpl:26
//line views/admin.qtpl:64
qw422016.E().S(u.Name)
//line views/admin.qtpl:26
//line views/admin.qtpl:64
qw422016.N().S(`</td>
<td>`)
//line views/admin.qtpl:27
//line views/admin.qtpl:65
qw422016.E().S(u.Group)
//line views/admin.qtpl:27
//line views/admin.qtpl:65
qw422016.N().S(`</td>
<td>`)
//line views/admin.qtpl:28
//line views/admin.qtpl:66
qw422016.E().S(u.RegisteredAt.Format("2006-01-02 15:04:05-0700"))
//line views/admin.qtpl:28
//line views/admin.qtpl:66
qw422016.N().S(`</td>
<td>
<a href="/admin/users/`)
//line views/admin.qtpl:30
//line views/admin.qtpl:68
qw422016.N().U(u.Name)
//line views/admin.qtpl:30
//line views/admin.qtpl:68
qw422016.N().S(`/edit">Edit</a>
</td>
</tr>
`)
//line views/admin.qtpl:33
//line views/admin.qtpl:71
}
//line views/admin.qtpl:33
//line views/admin.qtpl:71
qw422016.N().S(`
</tbody>
</table>
</main>
</div>
`)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
}
//line views/admin.qtpl:38
//line views/admin.qtpl:76
func WriteAdminUsersPanelHTML(qq422016 qtio422016.Writer, userList []*user.User) {
//line views/admin.qtpl:38
//line views/admin.qtpl:76
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
StreamAdminUsersPanelHTML(qw422016, userList)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
}
//line views/admin.qtpl:38
//line views/admin.qtpl:76
func AdminUsersPanelHTML(userList []*user.User) string {
//line views/admin.qtpl:38
//line views/admin.qtpl:76
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:38
//line views/admin.qtpl:76
WriteAdminUsersPanelHTML(qb422016, userList)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
qs422016 := string(qb422016.B)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:38
//line views/admin.qtpl:76
return qs422016
//line views/admin.qtpl:38
//line views/admin.qtpl:76
}
//line views/admin.qtpl:40
//line views/admin.qtpl:78
func StreamAdminUsersUserHTML(qw422016 *qt422016.Writer, u *user.User) {
//line views/admin.qtpl:40
//line views/admin.qtpl:78
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>`)
//line views/admin.qtpl:43
//line views/admin.qtpl:81
qw422016.E().S(u.Name)
//line views/admin.qtpl:43
//line views/admin.qtpl:81
qw422016.N().S(`</h1>
<form action="" method="post">
<label for="group">Group:</label>
<select id="group" name="group">
<option`)
//line views/admin.qtpl:48
//line views/admin.qtpl:86
if u.Group == "anon" {
//line views/admin.qtpl:48
//line views/admin.qtpl:86
qw422016.N().S(` selected`)
//line views/admin.qtpl:48
//line views/admin.qtpl:86
}
//line views/admin.qtpl:48
//line views/admin.qtpl:86
qw422016.N().S(`>anon</option>
<option`)
//line views/admin.qtpl:49
//line views/admin.qtpl:87
if u.Group == "editor" {
//line views/admin.qtpl:49
//line views/admin.qtpl:87
qw422016.N().S(` selected`)
//line views/admin.qtpl:49
//line views/admin.qtpl:87
}
//line views/admin.qtpl:49
//line views/admin.qtpl:87
qw422016.N().S(`>editor</option>
<option`)
//line views/admin.qtpl:50
//line views/admin.qtpl:88
if u.Group == "trusted" {
//line views/admin.qtpl:50
//line views/admin.qtpl:88
qw422016.N().S(` selected`)
//line views/admin.qtpl:50
//line views/admin.qtpl:88
}
//line views/admin.qtpl:50
//line views/admin.qtpl:88
qw422016.N().S(`>trusted</option>
<option`)
//line views/admin.qtpl:51
//line views/admin.qtpl:89
if u.Group == "moderator" {
//line views/admin.qtpl:51
//line views/admin.qtpl:89
qw422016.N().S(` selected`)
//line views/admin.qtpl:51
//line views/admin.qtpl:89
}
//line views/admin.qtpl:51
//line views/admin.qtpl:89
qw422016.N().S(`>moderator</option>
<option`)
//line views/admin.qtpl:52
//line views/admin.qtpl:90
if u.Group == "admin" {
//line views/admin.qtpl:52
//line views/admin.qtpl:90
qw422016.N().S(` selected`)
//line views/admin.qtpl:52
//line views/admin.qtpl:90
}
//line views/admin.qtpl:52
//line views/admin.qtpl:90
qw422016.N().S(`>admin</option>
</select>
<br>
@ -181,31 +250,31 @@ func StreamAdminUsersUserHTML(qw422016 *qt422016.Writer, u *user.User) {
</main>
</div>
`)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
}
//line views/admin.qtpl:61
//line views/admin.qtpl:99
func WriteAdminUsersUserHTML(qq422016 qtio422016.Writer, u *user.User) {
//line views/admin.qtpl:61
//line views/admin.qtpl:99
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
StreamAdminUsersUserHTML(qw422016, u)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
}
//line views/admin.qtpl:61
//line views/admin.qtpl:99
func AdminUsersUserHTML(u *user.User) string {
//line views/admin.qtpl:61
//line views/admin.qtpl:99
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:61
//line views/admin.qtpl:99
WriteAdminUsersUserHTML(qb422016, u)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
qs422016 := string(qb422016.B)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:61
//line views/admin.qtpl:99
return qs422016
//line views/admin.qtpl:61
//line views/admin.qtpl:99
}

View File

@ -130,43 +130,6 @@ for u := range user.YieldUsers() {
</div>
{% endfunc %}
{% func AdminPanelHTML() %}
<div class="layout">
<main class="main-width">
<h1>Administrative 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>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit">
</fieldset>
</form>
</section>
</main>
</div>
{% endfunc %}
{% func omnipresentScripts() %}
{% for _, scriptPath := range cfg.OmnipresentScripts %}
<script src="{%s scriptPath %}"></script>

View File

@ -461,118 +461,50 @@ func AboutHTML() string {
}
//line views/stuff.qtpl:133
func StreamAdminPanelHTML(qw422016 *qt422016.Writer) {
func streamomnipresentScripts(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:133
qw422016.N().S(`
<div class="layout">
<main class="main-width">
<h1>Administrative 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>
<form action="/admin/reindex-users" method="POST" style="float:left">
<fieldset>
<legend>Reindex users</legend>
<input type="submit">
</fieldset>
</form>
</section>
</main>
</div>
`)
//line views/stuff.qtpl:168
}
//line views/stuff.qtpl:168
func WriteAdminPanelHTML(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:168
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:168
StreamAdminPanelHTML(qw422016)
//line views/stuff.qtpl:168
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:168
}
//line views/stuff.qtpl:168
func AdminPanelHTML() string {
//line views/stuff.qtpl:168
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:168
WriteAdminPanelHTML(qb422016)
//line views/stuff.qtpl:168
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:168
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:168
return qs422016
//line views/stuff.qtpl:168
}
//line views/stuff.qtpl:170
func streamomnipresentScripts(qw422016 *qt422016.Writer) {
//line views/stuff.qtpl:170
qw422016.N().S(`
`)
//line views/stuff.qtpl:171
//line views/stuff.qtpl:134
for _, scriptPath := range cfg.OmnipresentScripts {
//line views/stuff.qtpl:171
//line views/stuff.qtpl:134
qw422016.N().S(`
<script src="`)
//line views/stuff.qtpl:172
//line views/stuff.qtpl:135
qw422016.E().S(scriptPath)
//line views/stuff.qtpl:172
//line views/stuff.qtpl:135
qw422016.N().S(`"></script>
`)
//line views/stuff.qtpl:173
//line views/stuff.qtpl:136
}
//line views/stuff.qtpl:173
//line views/stuff.qtpl:136
qw422016.N().S(`
`)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
}
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
func writeomnipresentScripts(qq422016 qtio422016.Writer) {
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
streamomnipresentScripts(qw422016)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
qt422016.ReleaseWriter(qw422016)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
}
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
func omnipresentScripts() string {
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
qb422016 := qt422016.AcquireByteBuffer()
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
writeomnipresentScripts(qb422016)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
qs422016 := string(qb422016.B)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
qt422016.ReleaseByteBuffer(qb422016)
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
return qs422016
//line views/stuff.qtpl:174
//line views/stuff.qtpl:137
}

View File

@ -2,9 +2,9 @@ package web
import (
"fmt"
"mime"
"io"
"log"
"mime"
"net/http"
"sort"
"strings"
@ -18,9 +18,9 @@ import (
// initAdmin sets up /admin routes if auth is used. Call it after you have decided if you want to use auth.
func initAdmin() {
if user.AuthUsed {
http.HandleFunc("/admin", handlerAdmin)
http.HandleFunc("/admin/shutdown", handlerAdminShutdown)
http.HandleFunc("/admin/reindex-users", handlerAdminReindexUsers)
http.HandleFunc("/admin/", handlerAdmin)
http.HandleFunc("/admin/shutdown/", handlerAdminShutdown)
http.HandleFunc("/admin/reindex-users/", handlerAdminReindexUsers)
http.HandleFunc("/admin/users/", handlerAdminUsers)
}
@ -54,7 +54,7 @@ func handlerAdminReindexUsers(w http.ResponseWriter, rq *http.Request) {
user.ReadUsersFromFilesystem()
redirectTo := rq.Referer()
if redirectTo == "" {
redirectTo = "/hypha/"+cfg.UserHypha
redirectTo = "/hypha/" + cfg.UserHypha
}
http.Redirect(w, rq, redirectTo, http.StatusSeeOther)
}