1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-05 02:29:54 +00:00

Delete package views

All the remaining QTPL files were spread across the codebase. The plan is to get rid of them step by step and migrate to the new l10n approach, all based on Go std templates.
This commit is contained in:
Timur Ismagilov 2022-08-06 16:35:17 +05:00
parent 4a9cbfd1eb
commit b1cdb1e279
22 changed files with 1094 additions and 1087 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/bouncepaw/mycorrhiza/l18n"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
)
// handlerAdmin provides the admin panel.
@ -89,8 +88,8 @@ func handlerAdminUserEdit(w http.ResponseWriter, rq *http.Request) {
f.Put("group", u.Group)
var lc = l18n.FromRequest(rq)
html := views.AdminUserEdit(u, f, lc)
html = views.Base(viewutil.MetaFrom(w, rq), fmt.Sprintf(lc.Get("admin.user_title"), u.Name), html)
html := AdminUserEdit(u, f, lc)
html = viewutil.Base(viewutil.MetaFrom(w, rq), fmt.Sprintf(lc.Get("admin.user_title"), u.Name), html)
if f.HasError() {
w.WriteHeader(http.StatusBadRequest)
@ -119,8 +118,8 @@ func handlerAdminUserDelete(w http.ResponseWriter, rq *http.Request) {
}
var lc = l18n.FromRequest(rq)
html := views.AdminUserDelete(u, util.NewFormData(), lc)
html = views.Base(viewutil.MetaFrom(w, rq), fmt.Sprintf(lc.Get("admin.user_title"), u.Name), html)
html := AdminUserDelete(u, util.NewFormData(), lc)
html = viewutil.Base(viewutil.MetaFrom(w, rq), fmt.Sprintf(lc.Get("admin.user_title"), u.Name), html)
if f.HasError() {
w.WriteHeader(http.StatusBadRequest)
@ -133,8 +132,8 @@ func handlerAdminUserNew(w http.ResponseWriter, rq *http.Request) {
var lc = l18n.FromRequest(rq)
if rq.Method == http.MethodGet {
// New user form
html := views.AdminUserNew(util.NewFormData(), lc)
html = views.Base(viewutil.MetaFrom(w, rq), lc.Get("admin.newuser_title"), html)
html := AdminUserNew(util.NewFormData(), lc)
html = viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("admin.newuser_title"), html)
w.Header().Set("Content-Type", mime.TypeByExtension(".html"))
io.WriteString(w, html)
@ -145,8 +144,8 @@ func handlerAdminUserNew(w http.ResponseWriter, rq *http.Request) {
err := user.Register(f.Get("name"), f.Get("password"), f.Get("group"), "local", true)
if err != nil {
html := views.AdminUserNew(f.WithError(err), lc)
html = views.Base(viewutil.MetaFrom(w, rq), lc.Get("admin.newuser_title"), html)
html := AdminUserNew(f.WithError(err), lc)
html = viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("admin.newuser_title"), html)
w.WriteHeader(http.StatusBadRequest)
w.Header().Set("Content-Type", mime.TypeByExtension(".html"))

View File

@ -1,146 +1,146 @@
// Code generated by qtc from "admin.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/admin.qtpl:1
package views
//line admin/admin.qtpl:1
package admin
//line views/admin.qtpl:1
//line admin/admin.qtpl:1
import "fmt"
//line views/admin.qtpl:2
//line admin/admin.qtpl:2
import "github.com/bouncepaw/mycorrhiza/l18n"
//line views/admin.qtpl:3
//line admin/admin.qtpl:3
import "github.com/bouncepaw/mycorrhiza/user"
//line views/admin.qtpl:4
//line admin/admin.qtpl:4
import "github.com/bouncepaw/mycorrhiza/util"
//line views/admin.qtpl:6
//line admin/admin.qtpl:6
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/admin.qtpl:6
//line admin/admin.qtpl:6
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/admin.qtpl:6
//line admin/admin.qtpl:6
func StreamAdminUserNew(qw422016 *qt422016.Writer, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:6
//line admin/admin.qtpl:6
qw422016.N().S(`
<main class="main-width form-wrap">
<h1>`)
//line views/admin.qtpl:8
//line admin/admin.qtpl:8
qw422016.E().S(lc.Get("admin.newuser_title"))
//line views/admin.qtpl:8
//line admin/admin.qtpl:8
qw422016.N().S(`</h1>
`)
//line views/admin.qtpl:10
//line admin/admin.qtpl:10
if f.HasError() {
//line views/admin.qtpl:10
//line admin/admin.qtpl:10
qw422016.N().S(`
<div class="notice notice--error">
<strong>`)
//line views/admin.qtpl:12
//line admin/admin.qtpl:12
qw422016.E().S(lc.Get("ui.error"))
//line views/admin.qtpl:12
//line admin/admin.qtpl:12
qw422016.N().S(`:</strong>
`)
//line views/admin.qtpl:13
//line admin/admin.qtpl:13
qw422016.E().S(f.Error())
//line views/admin.qtpl:13
//line admin/admin.qtpl:13
qw422016.N().S(`
</div>
`)
//line views/admin.qtpl:15
//line admin/admin.qtpl:15
}
//line views/admin.qtpl:15
//line admin/admin.qtpl:15
qw422016.N().S(`
<form class="form--double" action="" method="post">
<div class="form-field">
<label for="name">`)
//line views/admin.qtpl:19
//line admin/admin.qtpl:19
qw422016.E().S(lc.Get("admin.users_name"))
//line views/admin.qtpl:19
//line admin/admin.qtpl:19
qw422016.N().S(`:</label>
<input type="text" name="name" id="name" value="`)
//line views/admin.qtpl:20
//line admin/admin.qtpl:20
qw422016.E().S(f.Get("name"))
//line views/admin.qtpl:20
//line admin/admin.qtpl:20
qw422016.N().S(`" autofocus>
</div>
<div class="form-field">
<label for="password">`)
//line views/admin.qtpl:24
//line admin/admin.qtpl:24
qw422016.E().S(lc.Get("admin.users_password"))
//line views/admin.qtpl:24
//line admin/admin.qtpl:24
qw422016.N().S(`:</label>
<input type="password" name="password" id="password" value="`)
//line views/admin.qtpl:25
//line admin/admin.qtpl:25
qw422016.E().S(f.Get("password"))
//line views/admin.qtpl:25
//line admin/admin.qtpl:25
qw422016.N().S(`">
</div>
<div class="form-field">
<label for="group">`)
//line views/admin.qtpl:29
//line admin/admin.qtpl:29
qw422016.E().S(lc.Get("admin.users_group"))
//line views/admin.qtpl:29
//line admin/admin.qtpl:29
qw422016.N().S(`:</label>
<select id="group" name="group">
<option`)
//line views/admin.qtpl:31
//line admin/admin.qtpl:31
if f.Get("group") == "anon" {
//line views/admin.qtpl:31
//line admin/admin.qtpl:31
qw422016.N().S(` selected`)
//line views/admin.qtpl:31
//line admin/admin.qtpl:31
}
//line views/admin.qtpl:31
//line admin/admin.qtpl:31
qw422016.N().S(`>anon</option>
<option`)
//line views/admin.qtpl:32
//line admin/admin.qtpl:32
if f.Get("group") == "editor" {
//line views/admin.qtpl:32
//line admin/admin.qtpl:32
qw422016.N().S(` selected`)
//line views/admin.qtpl:32
//line admin/admin.qtpl:32
}
//line views/admin.qtpl:32
//line admin/admin.qtpl:32
qw422016.N().S(`>editor</option>
<option`)
//line views/admin.qtpl:33
//line admin/admin.qtpl:33
if f.Get("group") == "trusted" {
//line views/admin.qtpl:33
//line admin/admin.qtpl:33
qw422016.N().S(` selected`)
//line views/admin.qtpl:33
//line admin/admin.qtpl:33
}
//line views/admin.qtpl:33
//line admin/admin.qtpl:33
qw422016.N().S(`>trusted</option>
<option`)
//line views/admin.qtpl:34
//line admin/admin.qtpl:34
if f.Get("group") == "moderator" {
//line views/admin.qtpl:34
//line admin/admin.qtpl:34
qw422016.N().S(` selected`)
//line views/admin.qtpl:34
//line admin/admin.qtpl:34
}
//line views/admin.qtpl:34
//line admin/admin.qtpl:34
qw422016.N().S(`>moderator</option>
<option`)
//line views/admin.qtpl:35
//line admin/admin.qtpl:35
if f.Get("group") == "admin" {
//line views/admin.qtpl:35
//line admin/admin.qtpl:35
qw422016.N().S(` selected`)
//line views/admin.qtpl:35
//line admin/admin.qtpl:35
}
//line views/admin.qtpl:35
//line admin/admin.qtpl:35
qw422016.N().S(`>admin</option>
</select>
</div>
@ -148,289 +148,289 @@ func StreamAdminUserNew(qw422016 *qt422016.Writer, f util.FormData, lc *l18n.Loc
<div class="form-field">
<div class="form-field__input">
<button class="btn" type="submit">`)
//line views/admin.qtpl:41
//line admin/admin.qtpl:41
qw422016.E().S(lc.Get("admin.newuser_create"))
//line views/admin.qtpl:41
//line admin/admin.qtpl:41
qw422016.N().S(`</button>
<a class="btn btn_weak" href="/admin/users/">`)
//line views/admin.qtpl:42
//line admin/admin.qtpl:42
qw422016.E().S(lc.Get("ui.cancel"))
//line views/admin.qtpl:42
//line admin/admin.qtpl:42
qw422016.N().S(`</a>
</div>
</div>
</form>
</main>
`)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
}
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
func WriteAdminUserNew(qq422016 qtio422016.Writer, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
StreamAdminUserNew(qw422016, f, lc)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
}
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
func AdminUserNew(f util.FormData, lc *l18n.Localizer) string {
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
WriteAdminUserNew(qb422016, f, lc)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
qs422016 := string(qb422016.B)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
return qs422016
//line views/admin.qtpl:47
//line admin/admin.qtpl:47
}
//line views/admin.qtpl:49
//line admin/admin.qtpl:49
func StreamAdminUserEdit(qw422016 *qt422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:49
//line admin/admin.qtpl:49
qw422016.N().S(`
<main class="main-width form-wrap">
<h1>
<a href="/admin/users/">&larr;</a>
`)
//line views/admin.qtpl:53
//line admin/admin.qtpl:53
qw422016.E().S(u.Name)
//line views/admin.qtpl:53
//line admin/admin.qtpl:53
qw422016.N().S(`
</h1>
<h2>`)
//line views/admin.qtpl:56
//line admin/admin.qtpl:56
qw422016.E().S(lc.Get("admin.user_group_heading"))
//line views/admin.qtpl:56
//line admin/admin.qtpl:56
qw422016.N().S(`</h2>
`)
//line views/admin.qtpl:58
//line admin/admin.qtpl:58
if f.HasError() {
//line views/admin.qtpl:58
//line admin/admin.qtpl:58
qw422016.N().S(`
<div class="notice notice--error">
<strong>`)
//line views/admin.qtpl:60
//line admin/admin.qtpl:60
qw422016.E().S(lc.Get("ui.error"))
//line views/admin.qtpl:60
//line admin/admin.qtpl:60
qw422016.N().S(`:</strong>
`)
//line views/admin.qtpl:61
//line admin/admin.qtpl:61
qw422016.E().S(f.Error())
//line views/admin.qtpl:61
//line admin/admin.qtpl:61
qw422016.N().S(`
</div>
`)
//line views/admin.qtpl:63
//line admin/admin.qtpl:63
}
//line views/admin.qtpl:63
//line admin/admin.qtpl:63
qw422016.N().S(`
<form action="" method="post">
<div class="form-field">
<select id="group" name="group" aria-label="`)
//line views/admin.qtpl:67
//line admin/admin.qtpl:67
qw422016.E().S(lc.Get("admin.users_group"))
//line views/admin.qtpl:67
//line admin/admin.qtpl:67
qw422016.N().S(`">
<option`)
//line views/admin.qtpl:68
//line admin/admin.qtpl:68
if f.Get("group") == "anon" {
//line views/admin.qtpl:68
//line admin/admin.qtpl:68
qw422016.N().S(` selected`)
//line views/admin.qtpl:68
//line admin/admin.qtpl:68
}
//line views/admin.qtpl:68
//line admin/admin.qtpl:68
qw422016.N().S(`>anon</option>
<option`)
//line views/admin.qtpl:69
//line admin/admin.qtpl:69
if f.Get("group") == "editor" {
//line views/admin.qtpl:69
//line admin/admin.qtpl:69
qw422016.N().S(` selected`)
//line views/admin.qtpl:69
//line admin/admin.qtpl:69
}
//line views/admin.qtpl:69
//line admin/admin.qtpl:69
qw422016.N().S(`>editor</option>
<option`)
//line views/admin.qtpl:70
//line admin/admin.qtpl:70
if f.Get("group") == "trusted" {
//line views/admin.qtpl:70
//line admin/admin.qtpl:70
qw422016.N().S(` selected`)
//line views/admin.qtpl:70
//line admin/admin.qtpl:70
}
//line views/admin.qtpl:70
//line admin/admin.qtpl:70
qw422016.N().S(`>trusted</option>
<option`)
//line views/admin.qtpl:71
//line admin/admin.qtpl:71
if f.Get("group") == "moderator" {
//line views/admin.qtpl:71
//line admin/admin.qtpl:71
qw422016.N().S(` selected`)
//line views/admin.qtpl:71
//line admin/admin.qtpl:71
}
//line views/admin.qtpl:71
//line admin/admin.qtpl:71
qw422016.N().S(`>moderator</option>
<option`)
//line views/admin.qtpl:72
//line admin/admin.qtpl:72
if f.Get("group") == "admin" {
//line views/admin.qtpl:72
//line admin/admin.qtpl:72
qw422016.N().S(` selected`)
//line views/admin.qtpl:72
//line admin/admin.qtpl:72
}
//line views/admin.qtpl:72
//line admin/admin.qtpl:72
qw422016.N().S(`>admin</option>
</select>
</div>
<div class="form-field">
<button class="btn" type="submit">`)
//line views/admin.qtpl:77
//line admin/admin.qtpl:77
qw422016.E().S(lc.Get("admin.user_update"))
//line views/admin.qtpl:77
//line admin/admin.qtpl:77
qw422016.N().S(`</button>
</div>
</form>
<h2>`)
//line views/admin.qtpl:81
//line admin/admin.qtpl:81
qw422016.E().S(lc.Get("admin.user_delete_heading"))
//line views/admin.qtpl:81
//line admin/admin.qtpl:81
qw422016.N().S(`</h2>
<p>`)
//line views/admin.qtpl:82
//line admin/admin.qtpl:82
qw422016.E().S(lc.Get("admin.user_delete_tip"))
//line views/admin.qtpl:82
//line admin/admin.qtpl:82
qw422016.N().S(`</p>
<a class="btn btn_destructive" href="/admin/users/`)
//line views/admin.qtpl:83
//line admin/admin.qtpl:83
qw422016.N().U(u.Name)
//line views/admin.qtpl:83
//line admin/admin.qtpl:83
qw422016.N().S(`/delete">`)
//line views/admin.qtpl:83
//line admin/admin.qtpl:83
qw422016.E().S(lc.Get("admin.user_delete"))
//line views/admin.qtpl:83
//line admin/admin.qtpl:83
qw422016.N().S(`</a>
</main>
`)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
}
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
func WriteAdminUserEdit(qq422016 qtio422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
StreamAdminUserEdit(qw422016, u, f, lc)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
}
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
func AdminUserEdit(u *user.User, f util.FormData, lc *l18n.Localizer) string {
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
WriteAdminUserEdit(qb422016, u, f, lc)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
qs422016 := string(qb422016.B)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
return qs422016
//line views/admin.qtpl:85
//line admin/admin.qtpl:85
}
//line views/admin.qtpl:87
//line admin/admin.qtpl:87
func StreamAdminUserDelete(qw422016 *qt422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:87
//line admin/admin.qtpl:87
qw422016.N().S(`
<main class="main-width form-wrap">
<h1>`)
//line views/admin.qtpl:89
//line admin/admin.qtpl:89
qw422016.E().S(lc.Get("admin.user_delete_heading"))
//line views/admin.qtpl:89
//line admin/admin.qtpl:89
qw422016.N().S(`</h1>
`)
//line views/admin.qtpl:91
//line admin/admin.qtpl:91
if f.HasError() {
//line views/admin.qtpl:91
//line admin/admin.qtpl:91
qw422016.N().S(`
<div class="notice notice--error">
<strong>`)
//line views/admin.qtpl:93
//line admin/admin.qtpl:93
qw422016.E().S(lc.Get("ui.error"))
//line views/admin.qtpl:93
//line admin/admin.qtpl:93
qw422016.N().S(`:</strong>
`)
//line views/admin.qtpl:94
//line admin/admin.qtpl:94
qw422016.E().S(f.Error())
//line views/admin.qtpl:94
//line admin/admin.qtpl:94
qw422016.N().S(`
</div>
`)
//line views/admin.qtpl:96
//line admin/admin.qtpl:96
}
//line views/admin.qtpl:96
//line admin/admin.qtpl:96
qw422016.N().S(`
<p>`)
//line views/admin.qtpl:98
//line admin/admin.qtpl:98
qw422016.N().S(lc.Get("admin.user_delete_warn", &l18n.Replacements{"name": fmt.Sprintf("<strong>%s</strong>", u.Name)}))
//line views/admin.qtpl:98
//line admin/admin.qtpl:98
qw422016.N().S(`</p>
<form action="" method="post">
<button class="btn btn_destructive" type="submit">`)
//line views/admin.qtpl:101
//line admin/admin.qtpl:101
qw422016.E().S(lc.Get("admin.user_delete"))
//line views/admin.qtpl:101
//line admin/admin.qtpl:101
qw422016.N().S(`</button>
<a class="btn btn_weak" href="/admin/users/`)
//line views/admin.qtpl:102
//line admin/admin.qtpl:102
qw422016.N().U(u.Name)
//line views/admin.qtpl:102
//line admin/admin.qtpl:102
qw422016.N().S(`/edit">`)
//line views/admin.qtpl:102
//line admin/admin.qtpl:102
qw422016.E().S(lc.Get("ui.cancel"))
//line views/admin.qtpl:102
//line admin/admin.qtpl:102
qw422016.N().S(`</a>
</form>
</main>
`)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
}
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
func WriteAdminUserDelete(qq422016 qtio422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) {
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
StreamAdminUserDelete(qw422016, u, f, lc)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
qt422016.ReleaseWriter(qw422016)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
}
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
func AdminUserDelete(u *user.User, f util.FormData, lc *l18n.Localizer) string {
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
qb422016 := qt422016.AcquireByteBuffer()
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
WriteAdminUserDelete(qb422016, u, f, lc)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
qs422016 := string(qb422016.B)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
qt422016.ReleaseByteBuffer(qb422016)
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
return qs422016
//line views/admin.qtpl:105
//line admin/admin.qtpl:105
}

View File

@ -144,11 +144,11 @@ Telegram auth widget was requested by Yogurt. As you can see, we don't offer use
{% endfunc %}
{% code
var userListL10n = map[string]l10nEntry{
"heading": en("List of users").ru("Список пользователей"),
"administrators": en("Administrators").ru("Администраторы"),
"moderators": en("Moderators").ru("Модераторы"),
"editors": en("Editors").ru("Редакторы"),
var userListL10n = map[string]L10nEntry{
"heading": En("List of users").Ru("Список пользователей"),
"administrators": En("Administrators").Ru("Администраторы"),
"moderators": En("Moderators").Ru("Модераторы"),
"editors": En("Editors").Ru("Редакторы"),
}
%}
@ -156,7 +156,7 @@ var userListL10n = map[string]l10nEntry{
<main class="main-width user-list">
{% code
var get = func(key string) string {
return userListL10n[key].get(lc.Locale)
return userListL10n[key].Get(lc.Locale)
}
var (

File diff suppressed because it is too large Load Diff

22
auth/get_rid_of_it.go Normal file
View File

@ -0,0 +1,22 @@
package auth
type L10nEntry struct {
_en string
_ru string
}
func En(v string) L10nEntry {
return L10nEntry{_en: v}
}
func (e L10nEntry) Ru(v string) L10nEntry {
e._ru = v
return e
}
func (e L10nEntry) Get(lang string) string {
if lang == "ru" && e._ru != "" {
return e._ru
}
return e._en
}

View File

@ -1,4 +1,4 @@
package web
package auth
import (
"errors"
@ -16,10 +16,9 @@ import (
"github.com/bouncepaw/mycorrhiza/l18n"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
)
func initAuth(r *mux.Router) {
func InitAuth(r *mux.Router) {
r.HandleFunc("/user-list", handlerUserList)
r.HandleFunc("/lock", handlerLock)
// The check below saves a lot of extra checks and lines of codes in other places in this file.
@ -40,11 +39,11 @@ func handlerUserList(w http.ResponseWriter, rq *http.Request) {
lc := l18n.FromRequest(rq)
w.Header().Set("Content-Type", mime.TypeByExtension(".html"))
w.WriteHeader(http.StatusOK)
w.Write([]byte(views.Base(viewutil.MetaFrom(w, rq), lc.Get("ui.users_title"), views.UserList(lc))))
w.Write([]byte(viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("ui.users_title"), UserList(lc))))
}
func handlerLock(w http.ResponseWriter, rq *http.Request) {
_, _ = io.WriteString(w, views.Lock(l18n.FromRequest(rq)))
_, _ = io.WriteString(w, Lock(l18n.FromRequest(rq)))
}
// handlerRegister displays the register form (GET) or registers the user (POST).
@ -54,10 +53,10 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) {
if rq.Method == http.MethodGet {
_, _ = io.WriteString(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("auth.register_title"),
views.Register(rq),
Register(rq),
),
)
return
@ -74,7 +73,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusBadRequest)
_, _ = io.WriteString(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("auth.register_title"),
fmt.Sprintf(
@ -112,7 +111,7 @@ func handlerLogout(w http.ResponseWriter, rq *http.Request) {
}
_, _ = io.WriteString(
w,
views.Base(viewutil.MetaFrom(w, rq), lc.Get("auth.logout_title"), views.Logout(can, lc)),
viewutil.Base(viewutil.MetaFrom(w, rq), lc.Get("auth.logout_title"), Logout(can, lc)),
)
} else if rq.Method == http.MethodPost {
user.LogoutFromRequest(w, rq)
@ -128,10 +127,10 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = io.WriteString(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("auth.login_title"),
views.Login(lc),
Login(lc),
),
)
} else if rq.Method == http.MethodPost {
@ -143,7 +142,7 @@ func handlerLogin(w http.ResponseWriter, rq *http.Request) {
if err != nil {
w.Header().Set("Content-Type", "text/html;charset=utf-8")
w.WriteHeader(http.StatusInternalServerError)
_, _ = io.WriteString(w, views.Base(viewutil.MetaFrom(w, rq), err.Error(), views.LoginError(err.Error(), lc)))
_, _ = io.WriteString(w, viewutil.Base(viewutil.MetaFrom(w, rq), err.Error(), LoginError(err.Error(), lc)))
return
}
http.Redirect(w, rq, "/", http.StatusSeeOther)
@ -181,7 +180,7 @@ func handlerTelegramLogin(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusBadRequest)
_, _ = io.WriteString(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("ui.error"),
fmt.Sprintf(
@ -201,7 +200,7 @@ func handlerTelegramLogin(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusBadRequest)
_, _ = io.WriteString(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
"Error",
fmt.Sprintf(

View File

@ -1,50 +1,50 @@
// Code generated by qtc from "mutators.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/mutators.qtpl:1
package views
//line hypview/mutators.qtpl:1
package hypview
//line views/mutators.qtpl:1
//line hypview/mutators.qtpl:1
import "fmt"
//line views/mutators.qtpl:2
//line hypview/mutators.qtpl:2
import "net/http"
//line views/mutators.qtpl:4
//line hypview/mutators.qtpl:4
import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/mutators.qtpl:5
//line hypview/mutators.qtpl:5
import "github.com/bouncepaw/mycorrhiza/l18n"
//line views/mutators.qtpl:6
//line hypview/mutators.qtpl:6
import "github.com/bouncepaw/mycorrhiza/user"
//line views/mutators.qtpl:8
//line hypview/mutators.qtpl:8
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/mutators.qtpl:8
//line hypview/mutators.qtpl:8
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/mutators.qtpl:8
//line hypview/mutators.qtpl:8
func StreamToolbar(qw422016 *qt422016.Writer, u *user.User, lc *l18n.Localizer) {
//line views/mutators.qtpl:8
//line hypview/mutators.qtpl:8
qw422016.N().S(`
<aside class="edit-toolbar markup-toolbar layout-card">
<h2 class="edit-toolbar__title layout-card__title">`)
//line views/mutators.qtpl:10
//line hypview/mutators.qtpl:10
qw422016.E().S(lc.Get("edit.markup"))
//line views/mutators.qtpl:10
//line hypview/mutators.qtpl:10
qw422016.N().S(`</h2>
<section class="edit-toolbar__buttons">
`)
//line views/mutators.qtpl:12
//line hypview/mutators.qtpl:12
for _, el := range []struct {
class string
display string
@ -70,40 +70,40 @@ func StreamToolbar(qw422016 *qt422016.Writer, u *user.User, lc *l18n.Localizer)
{"bulletedlist", "* " + lc.Get("edit.bullets")},
{"numberedlist", "*. " + lc.Get("edit.numbers")},
} {
//line views/mutators.qtpl:36
//line hypview/mutators.qtpl:36
qw422016.N().S(`
<button class="btn edit-toolbar__btn edit-toolbar__`)
//line views/mutators.qtpl:37
//line hypview/mutators.qtpl:37
qw422016.E().S(el.class)
//line views/mutators.qtpl:37
//line hypview/mutators.qtpl:37
qw422016.N().S(`">
`)
//line views/mutators.qtpl:38
//line hypview/mutators.qtpl:38
qw422016.N().S(el.display)
//line views/mutators.qtpl:38
//line hypview/mutators.qtpl:38
qw422016.N().S(`
</button>
`)
//line views/mutators.qtpl:40
//line hypview/mutators.qtpl:40
}
//line views/mutators.qtpl:40
//line hypview/mutators.qtpl:40
qw422016.N().S(`
</section>
<p class="edit-toolbar__ad">`)
//line views/mutators.qtpl:42
//line hypview/mutators.qtpl:42
qw422016.N().S(lc.Get("edit.help", &l18n.Replacements{"link": fmt.Sprintf("<a href=\"/help/en/mycomarkup\" target=\"_blank\" class=\"shy-link\">%s</a>", lc.Get("edit.help_link"))}))
//line views/mutators.qtpl:42
//line hypview/mutators.qtpl:42
qw422016.N().S(`</p>
</aside>
<aside class="edit-toolbar action-toolbar layout-card">
<h2 class="edit-toolbar__title layout-card__title">`)
//line views/mutators.qtpl:45
//line hypview/mutators.qtpl:45
qw422016.E().S(lc.Get("edit.actions"))
//line views/mutators.qtpl:45
//line hypview/mutators.qtpl:45
qw422016.N().S(`</h2>
<section class="edit-toolbar__buttons">
`)
//line views/mutators.qtpl:47
//line hypview/mutators.qtpl:47
for _, el := range []struct {
class string
display string
@ -111,342 +111,342 @@ func StreamToolbar(qw422016 *qt422016.Writer, u *user.User, lc *l18n.Localizer)
{"date", lc.Get("edit.date")},
{"time", lc.Get("edit.time")},
} {
//line views/mutators.qtpl:53
//line hypview/mutators.qtpl:53
qw422016.N().S(`
<button class="btn edit-toolbar__btn edit-toolbar__`)
//line views/mutators.qtpl:54
//line hypview/mutators.qtpl:54
qw422016.E().S(el.class)
//line views/mutators.qtpl:54
//line hypview/mutators.qtpl:54
qw422016.N().S(`">
`)
//line views/mutators.qtpl:55
//line hypview/mutators.qtpl:55
qw422016.N().S(el.display)
//line views/mutators.qtpl:55
//line hypview/mutators.qtpl:55
qw422016.N().S(`
</button>
`)
//line views/mutators.qtpl:57
//line hypview/mutators.qtpl:57
}
//line views/mutators.qtpl:57
//line hypview/mutators.qtpl:57
qw422016.N().S(`
`)
//line views/mutators.qtpl:58
//line hypview/mutators.qtpl:58
if u.Group != "anon" {
//line views/mutators.qtpl:58
//line hypview/mutators.qtpl:58
qw422016.N().S(`
<button class="btn edit-toolbar__btn edit-toolbar__user-link">
`)
//line views/mutators.qtpl:60
//line hypview/mutators.qtpl:60
qw422016.E().S(lc.Get("edit.selflink"))
//line views/mutators.qtpl:60
//line hypview/mutators.qtpl:60
qw422016.N().S(`
</button>
`)
//line views/mutators.qtpl:62
//line hypview/mutators.qtpl:62
}
//line views/mutators.qtpl:62
//line hypview/mutators.qtpl:62
qw422016.N().S(`
</section>
</aside>
<script src="/static/toolbar.js"></script>
`)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
}
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
func WriteToolbar(qq422016 qtio422016.Writer, u *user.User, lc *l18n.Localizer) {
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
StreamToolbar(qw422016, u, lc)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
qt422016.ReleaseWriter(qw422016)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
}
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
func Toolbar(u *user.User, lc *l18n.Localizer) string {
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
qb422016 := qt422016.AcquireByteBuffer()
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
WriteToolbar(qb422016, u, lc)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
qs422016 := string(qb422016.B)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
qt422016.ReleaseByteBuffer(qb422016)
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
return qs422016
//line views/mutators.qtpl:66
//line hypview/mutators.qtpl:66
}
//line views/mutators.qtpl:68
//line hypview/mutators.qtpl:68
func StreamEditor(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) {
//line views/mutators.qtpl:68
//line hypview/mutators.qtpl:68
qw422016.N().S(`
`)
//line views/mutators.qtpl:70
//line hypview/mutators.qtpl:70
lc := l18n.FromRequest(rq)
//line views/mutators.qtpl:71
//line hypview/mutators.qtpl:71
qw422016.N().S(`
<main class="main-width edit edit_no-preview">
<form method="post" class="edit-form"
action="/upload-text/`)
//line views/mutators.qtpl:74
//line hypview/mutators.qtpl:74
qw422016.E().S(hyphaName)
//line views/mutators.qtpl:74
//line hypview/mutators.qtpl:74
qw422016.N().S(`">
<h1 class="edit__title">`)
//line views/mutators.qtpl:75
//line hypview/mutators.qtpl:75
qw422016.N().S(fmt.Sprintf(lc.Get("edit.title"), beautifulLink(hyphaName)))
//line views/mutators.qtpl:75
//line hypview/mutators.qtpl:75
qw422016.N().S(`</h1>
`)
//line views/mutators.qtpl:76
//line hypview/mutators.qtpl:76
qw422016.N().S(warning)
//line views/mutators.qtpl:76
//line hypview/mutators.qtpl:76
qw422016.N().S(`
<textarea name="text" class="edit-form__textarea" autofocus>`)
//line views/mutators.qtpl:77
//line hypview/mutators.qtpl:77
qw422016.E().S(textAreaFill)
//line views/mutators.qtpl:77
//line hypview/mutators.qtpl:77
qw422016.N().S(`</textarea>
<p class="edit-form__message-zone">
<input id="text" type="text" name="message" class="edit-form__message" placeholder="`)
//line views/mutators.qtpl:79
//line hypview/mutators.qtpl:79
qw422016.E().S(lc.Get("edit.tag"))
//line views/mutators.qtpl:79
//line hypview/mutators.qtpl:79
qw422016.N().S(`" aria-label="`)
//line views/mutators.qtpl:79
//line hypview/mutators.qtpl:79
qw422016.E().S(lc.Get("edit.tag"))
//line views/mutators.qtpl:79
//line hypview/mutators.qtpl:79
qw422016.N().S(`">
</p>
<p class="edit-form__buttons">
<button type="submit" name="action" class="btn btn_accent edit-form__save" value="Save">`)
//line views/mutators.qtpl:82
//line hypview/mutators.qtpl:82
qw422016.E().S(lc.Get("edit.save"))
//line views/mutators.qtpl:82
//line hypview/mutators.qtpl:82
qw422016.N().S(`</button>
<button type="submit" name="action" class="btn edit-form__preview" value="Preview">`)
//line views/mutators.qtpl:83
//line hypview/mutators.qtpl:83
qw422016.E().S(lc.Get("edit.preview"))
//line views/mutators.qtpl:83
//line hypview/mutators.qtpl:83
qw422016.N().S(`</button>
<a href="/hypha/`)
//line views/mutators.qtpl:84
//line hypview/mutators.qtpl:84
qw422016.E().S(hyphaName)
//line views/mutators.qtpl:84
//line hypview/mutators.qtpl:84
qw422016.N().S(`" class="btn btn_weak">`)
//line views/mutators.qtpl:84
//line hypview/mutators.qtpl:84
qw422016.E().S(lc.Get("ui.cancel"))
//line views/mutators.qtpl:84
//line hypview/mutators.qtpl:84
qw422016.N().S(`</a>
</p>
</form>
</main>
`)
//line views/mutators.qtpl:88
//line hypview/mutators.qtpl:88
qw422016.N().S(Toolbar(user.FromRequest(rq), lc))
//line views/mutators.qtpl:88
//line hypview/mutators.qtpl:88
qw422016.N().S(`
`)
//line views/mutators.qtpl:89
//line hypview/mutators.qtpl:89
streameditScripts(qw422016)
//line views/mutators.qtpl:89
//line hypview/mutators.qtpl:89
qw422016.N().S(`
`)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
}
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
func WriteEditor(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) {
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
StreamEditor(qw422016, rq, hyphaName, textAreaFill, warning)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
qt422016.ReleaseWriter(qw422016)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
}
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
func Editor(rq *http.Request, hyphaName, textAreaFill, warning string) string {
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
qb422016 := qt422016.AcquireByteBuffer()
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
WriteEditor(qb422016, rq, hyphaName, textAreaFill, warning)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
qs422016 := string(qb422016.B)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
qt422016.ReleaseByteBuffer(qb422016)
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
return qs422016
//line views/mutators.qtpl:90
//line hypview/mutators.qtpl:90
}
//line views/mutators.qtpl:92
//line hypview/mutators.qtpl:92
func StreamPreview(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) {
//line views/mutators.qtpl:92
//line hypview/mutators.qtpl:92
qw422016.N().S(`
`)
//line views/mutators.qtpl:94
//line hypview/mutators.qtpl:94
lc := l18n.FromRequest(rq)
//line views/mutators.qtpl:95
//line hypview/mutators.qtpl:95
qw422016.N().S(`
<main class="main-width edit edit_with-preview">
<form method="post" class="edit-form"
action="/upload-text/`)
//line views/mutators.qtpl:98
//line hypview/mutators.qtpl:98
qw422016.E().S(hyphaName)
//line views/mutators.qtpl:98
//line hypview/mutators.qtpl:98
qw422016.N().S(`">
<h1 class="edit__title">`)
//line views/mutators.qtpl:99
//line hypview/mutators.qtpl:99
qw422016.N().S(fmt.Sprintf(lc.Get("edit.title"), beautifulLink(hyphaName)))
//line views/mutators.qtpl:99
//line hypview/mutators.qtpl:99
qw422016.N().S(`</h1>
`)
//line views/mutators.qtpl:100
//line hypview/mutators.qtpl:100
qw422016.N().S(warning)
//line views/mutators.qtpl:100
//line hypview/mutators.qtpl:100
qw422016.N().S(`
<textarea name="text" class="edit-form__textarea" autofocus>`)
//line views/mutators.qtpl:101
//line hypview/mutators.qtpl:101
qw422016.E().S(textAreaFill)
//line views/mutators.qtpl:101
//line hypview/mutators.qtpl:101
qw422016.N().S(`</textarea>
<p class="edit-form__message-zone">
<input id="text" type="text" name="message" class="edit-form__message" placeholder="`)
//line views/mutators.qtpl:103
//line hypview/mutators.qtpl:103
qw422016.E().S(lc.Get("edit.tag"))
//line views/mutators.qtpl:103
//line hypview/mutators.qtpl:103
qw422016.N().S(`" aria-label="`)
//line views/mutators.qtpl:103
//line hypview/mutators.qtpl:103
qw422016.E().S(lc.Get("edit.tag"))
//line views/mutators.qtpl:103
//line hypview/mutators.qtpl:103
qw422016.N().S(`">
</p>
<p class="edit-form__buttons">
<button type="submit" name="action" class="btn btn_accent edit-form__save" value="Save">`)
//line views/mutators.qtpl:106
//line hypview/mutators.qtpl:106
qw422016.E().S(lc.Get("edit.save"))
//line views/mutators.qtpl:106
//line hypview/mutators.qtpl:106
qw422016.N().S(`</button>
<button type="submit" name="action" class="btn edit-form__preview" value="Preview">`)
//line views/mutators.qtpl:107
//line hypview/mutators.qtpl:107
qw422016.E().S(lc.Get("edit.preview"))
//line views/mutators.qtpl:107
//line hypview/mutators.qtpl:107
qw422016.N().S(`</button>
<a href="/hypha/`)
//line views/mutators.qtpl:108
//line hypview/mutators.qtpl:108
qw422016.E().S(hyphaName)
//line views/mutators.qtpl:108
//line hypview/mutators.qtpl:108
qw422016.N().S(`" class="btn btn_weak">`)
//line views/mutators.qtpl:108
//line hypview/mutators.qtpl:108
qw422016.E().S(lc.Get("ui.cancel"))
//line views/mutators.qtpl:108
//line hypview/mutators.qtpl:108
qw422016.N().S(`</a>
</p>
</form>
<p class="warning">`)
//line views/mutators.qtpl:111
//line hypview/mutators.qtpl:111
qw422016.E().S(lc.Get("edit.preview_tip"))
//line views/mutators.qtpl:111
//line hypview/mutators.qtpl:111
qw422016.N().S(`</p>
<article class="edit__preview">`)
//line views/mutators.qtpl:112
//line hypview/mutators.qtpl:112
qw422016.N().S(renderedPage)
//line views/mutators.qtpl:112
//line hypview/mutators.qtpl:112
qw422016.N().S(`</article>
</main>
`)
//line views/mutators.qtpl:114
//line hypview/mutators.qtpl:114
qw422016.N().S(Toolbar(user.FromRequest(rq), lc))
//line views/mutators.qtpl:114
//line hypview/mutators.qtpl:114
qw422016.N().S(`
`)
//line views/mutators.qtpl:115
//line hypview/mutators.qtpl:115
streameditScripts(qw422016)
//line views/mutators.qtpl:115
//line hypview/mutators.qtpl:115
qw422016.N().S(`
`)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
}
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
func WritePreview(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) {
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
StreamPreview(qw422016, rq, hyphaName, textAreaFill, message, warning, renderedPage)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
qt422016.ReleaseWriter(qw422016)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
}
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
func Preview(rq *http.Request, hyphaName, textAreaFill, message, warning string, renderedPage string) string {
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
qb422016 := qt422016.AcquireByteBuffer()
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
WritePreview(qb422016, rq, hyphaName, textAreaFill, message, warning, renderedPage)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
qs422016 := string(qb422016.B)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
qt422016.ReleaseByteBuffer(qb422016)
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
return qs422016
//line views/mutators.qtpl:116
//line hypview/mutators.qtpl:116
}
//line views/mutators.qtpl:118
//line hypview/mutators.qtpl:118
func streameditScripts(qw422016 *qt422016.Writer) {
//line views/mutators.qtpl:118
//line hypview/mutators.qtpl:118
qw422016.N().S(`
<script src="/static/editor.js"></script>
`)
//line views/mutators.qtpl:120
//line hypview/mutators.qtpl:120
for _, scriptPath := range cfg.EditScripts {
//line views/mutators.qtpl:120
//line hypview/mutators.qtpl:120
qw422016.N().S(`
<script src="`)
//line views/mutators.qtpl:121
//line hypview/mutators.qtpl:121
qw422016.E().S(scriptPath)
//line views/mutators.qtpl:121
//line hypview/mutators.qtpl:121
qw422016.N().S(`"></script>
`)
//line views/mutators.qtpl:122
//line hypview/mutators.qtpl:122
}
//line views/mutators.qtpl:122
//line hypview/mutators.qtpl:122
qw422016.N().S(`
`)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
}
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
func writeeditScripts(qq422016 qtio422016.Writer) {
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
streameditScripts(qw422016)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
qt422016.ReleaseWriter(qw422016)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
}
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
func editScripts() string {
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
qb422016 := qt422016.AcquireByteBuffer()
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
writeeditScripts(qb422016)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
qs422016 := string(qb422016.B)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
qt422016.ReleaseByteBuffer(qb422016)
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
return qs422016
//line views/mutators.qtpl:123
//line hypview/mutators.qtpl:123
}

View File

@ -1,289 +1,289 @@
// Code generated by qtc from "nav.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/nav.qtpl:1
package views
//line hypview/nav.qtpl:1
package hypview
//line views/nav.qtpl:1
//line hypview/nav.qtpl:1
import "github.com/bouncepaw/mycorrhiza/backlinks"
//line views/nav.qtpl:2
//line hypview/nav.qtpl:2
import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/nav.qtpl:3
//line hypview/nav.qtpl:3
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/nav.qtpl:4
//line hypview/nav.qtpl:4
import "github.com/bouncepaw/mycorrhiza/user"
//line views/nav.qtpl:5
//line hypview/nav.qtpl:5
import "github.com/bouncepaw/mycorrhiza/util"
//line views/nav.qtpl:6
//line hypview/nav.qtpl:6
import "github.com/bouncepaw/mycorrhiza/viewutil"
//line views/nav.qtpl:8
//line hypview/nav.qtpl:8
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/nav.qtpl:8
//line hypview/nav.qtpl:8
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/nav.qtpl:8
//line hypview/nav.qtpl:8
func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) {
//line views/nav.qtpl:8
//line hypview/nav.qtpl:8
qw422016.N().S(`
`)
//line views/nav.qtpl:9
//line hypview/nav.qtpl:9
flag := true
//line views/nav.qtpl:9
//line hypview/nav.qtpl:9
qw422016.N().S(`
`)
//line views/nav.qtpl:10
//line hypview/nav.qtpl:10
switch h.(type) {
//line views/nav.qtpl:11
//line hypview/nav.qtpl:11
case *hyphae.EmptyHypha:
//line views/nav.qtpl:11
//line hypview/nav.qtpl:11
qw422016.N().S(`
`)
//line views/nav.qtpl:12
//line hypview/nav.qtpl:12
flag = !hasToExist
//line views/nav.qtpl:12
//line hypview/nav.qtpl:12
qw422016.N().S(`
`)
//line views/nav.qtpl:13
//line hypview/nav.qtpl:13
}
//line views/nav.qtpl:13
//line hypview/nav.qtpl:13
qw422016.N().S(`
`)
//line views/nav.qtpl:14
//line hypview/nav.qtpl:14
if u.CanProceed(action) && flag {
//line views/nav.qtpl:14
//line hypview/nav.qtpl:14
qw422016.N().S(`
<li class="hypha-info__entry hypha-info__entry_`)
//line views/nav.qtpl:15
//line hypview/nav.qtpl:15
qw422016.E().S(action)
//line views/nav.qtpl:15
//line hypview/nav.qtpl:15
qw422016.N().S(`">
<a class="hypha-info__link" href="/`)
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.E().S(action)
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.N().S(`/`)
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.E().S(h.CanonicalName())
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.N().S(`">`)
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.E().S(displayText)
//line views/nav.qtpl:16
//line hypview/nav.qtpl:16
qw422016.N().S(`</a>
</li>
`)
//line views/nav.qtpl:18
//line hypview/nav.qtpl:18
}
//line views/nav.qtpl:18
//line hypview/nav.qtpl:18
qw422016.N().S(`
`)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
}
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
func writehyphaInfoEntry(qq422016 qtio422016.Writer, h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) {
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
streamhyphaInfoEntry(qw422016, h, u, action, hasToExist, displayText)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
}
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) string {
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
writehyphaInfoEntry(qb422016, h, u, action, hasToExist, displayText)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
qs422016 := string(qb422016.B)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
return qs422016
//line views/nav.qtpl:19
//line hypview/nav.qtpl:19
}
//line views/nav.qtpl:21
//line hypview/nav.qtpl:21
func streamhyphaInfo(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha) {
//line views/nav.qtpl:21
//line hypview/nav.qtpl:21
qw422016.N().S(`
`)
//line views/nav.qtpl:23
//line hypview/nav.qtpl:23
u := meta.U
lc := meta.Lc
backs := backlinks.BacklinksCount(h)
//line views/nav.qtpl:26
//line hypview/nav.qtpl:26
qw422016.N().S(`
<nav class="hypha-info">
<ul class="hypha-info__list">
`)
//line views/nav.qtpl:29
//line hypview/nav.qtpl:29
streamhyphaInfoEntry(qw422016, h, u, "history", false, lc.Get("ui.history_link"))
//line views/nav.qtpl:29
//line hypview/nav.qtpl:29
qw422016.N().S(`
`)
//line views/nav.qtpl:30
//line hypview/nav.qtpl:30
streamhyphaInfoEntry(qw422016, h, u, "rename", true, lc.Get("ui.rename_link"))
//line views/nav.qtpl:30
//line hypview/nav.qtpl:30
qw422016.N().S(`
`)
//line views/nav.qtpl:31
//line hypview/nav.qtpl:31
streamhyphaInfoEntry(qw422016, h, u, "delete", true, lc.Get("ui.delete_link"))
//line views/nav.qtpl:31
//line hypview/nav.qtpl:31
qw422016.N().S(`
`)
//line views/nav.qtpl:32
//line hypview/nav.qtpl:32
streamhyphaInfoEntry(qw422016, h, u, "text", true, lc.Get("ui.text_link"))
//line views/nav.qtpl:32
//line hypview/nav.qtpl:32
qw422016.N().S(`
`)
//line views/nav.qtpl:33
//line hypview/nav.qtpl:33
streamhyphaInfoEntry(qw422016, h, u, "media", true, lc.Get("ui.media_link"))
//line views/nav.qtpl:33
//line hypview/nav.qtpl:33
qw422016.N().S(`
`)
//line views/nav.qtpl:34
//line hypview/nav.qtpl:34
streamhyphaInfoEntry(qw422016, h, u, "backlinks", false, lc.GetPlural("ui.backlinks_link", backs))
//line views/nav.qtpl:34
//line hypview/nav.qtpl:34
qw422016.N().S(`
</ul>
</nav>
`)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
}
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
func writehyphaInfo(qq422016 qtio422016.Writer, meta viewutil.Meta, h hyphae.Hypha) {
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
streamhyphaInfo(qw422016, meta, h)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
}
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
func hyphaInfo(meta viewutil.Meta, h hyphae.Hypha) string {
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
writehyphaInfo(qb422016, meta, h)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
qs422016 := string(qb422016.B)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
return qs422016
//line views/nav.qtpl:37
//line hypview/nav.qtpl:37
}
//line views/nav.qtpl:39
//line hypview/nav.qtpl:39
func streamcommonScripts(qw422016 *qt422016.Writer) {
//line views/nav.qtpl:39
//line hypview/nav.qtpl:39
qw422016.N().S(`
`)
//line views/nav.qtpl:40
//line hypview/nav.qtpl:40
for _, scriptPath := range cfg.CommonScripts {
//line views/nav.qtpl:40
//line hypview/nav.qtpl:40
qw422016.N().S(`
<script src="`)
//line views/nav.qtpl:41
//line hypview/nav.qtpl:41
qw422016.E().S(scriptPath)
//line views/nav.qtpl:41
//line hypview/nav.qtpl:41
qw422016.N().S(`"></script>
`)
//line views/nav.qtpl:42
//line hypview/nav.qtpl:42
}
//line views/nav.qtpl:42
//line hypview/nav.qtpl:42
qw422016.N().S(`
`)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
}
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
func writecommonScripts(qq422016 qtio422016.Writer) {
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
streamcommonScripts(qw422016)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
}
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
func commonScripts() string {
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
writecommonScripts(qb422016)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
qs422016 := string(qb422016.B)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
return qs422016
//line views/nav.qtpl:43
//line hypview/nav.qtpl:43
}
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
func streambeautifulLink(qw422016 *qt422016.Writer, hyphaName string) {
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016.N().S(`<a href="/hypha/`)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016.N().S(hyphaName)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016.N().S(`">`)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016.E().S(util.BeautifulName(hyphaName))
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016.N().S(`</a>`)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
}
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
func writebeautifulLink(qq422016 qtio422016.Writer, hyphaName string) {
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
streambeautifulLink(qw422016, hyphaName)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
}
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
func beautifulLink(hyphaName string) string {
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
writebeautifulLink(qb422016, hyphaName)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qs422016 := string(qb422016.B)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
return qs422016
//line views/nav.qtpl:45
//line hypview/nav.qtpl:45
}

View File

@ -5,7 +5,6 @@
{% import "github.com/bouncepaw/mycorrhiza/cfg" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
{% import "github.com/bouncepaw/mycorrhiza/hypview" %}
{% import "github.com/bouncepaw/mycorrhiza/categories" %}
{% import "github.com/bouncepaw/mycorrhiza/l18n" %}
{% import "github.com/bouncepaw/mycorrhiza/mimetype" %}
@ -110,10 +109,10 @@ If you rename .prevnext, change the docs too.
{% endif %}
{% endif %}
{%s= hypview.NaviTitle(meta, h.CanonicalName()) %}
{%s= NaviTitle(meta, h.CanonicalName()) %}
{% switch h.(type) %}
{% case *hyphae.EmptyHypha %}
{%s= hypview.EmptyHypha(meta, h.CanonicalName()) %}
{%s= EmptyHypha(meta, h.CanonicalName()) %}
{% default %}
{%s= contents %}
{% endswitch %}
@ -148,7 +147,7 @@ If you rename .prevnext, change the docs too.
<main class="main-width">
<section>
<p>{%s meta.Lc.Get("ui.revision_warning") %} <a href="/rev-text/{%s revHash %}/{%s h.CanonicalName() %}">{%s meta.Lc.Get("ui.revision_link") %}</a></p>
{%s= hypview.NaviTitle(meta, h.CanonicalName()) %}
{%s= NaviTitle(meta, h.CanonicalName()) %}
{%s= contents %}
</section>
</main>

View File

@ -1,654 +1,651 @@
// Code generated by qtc from "readers.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/readers.qtpl:1
package views
//line hypview/readers.qtpl:1
package hypview
//line views/readers.qtpl:1
//line hypview/readers.qtpl:1
import "net/http"
//line views/readers.qtpl:2
//line hypview/readers.qtpl:2
import "strings"
//line views/readers.qtpl:3
//line hypview/readers.qtpl:3
import "path"
//line views/readers.qtpl:4
//line hypview/readers.qtpl:4
import "os"
//line views/readers.qtpl:6
//line hypview/readers.qtpl:6
import "github.com/bouncepaw/mycorrhiza/cfg"
//line views/readers.qtpl:7
//line hypview/readers.qtpl:7
import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/readers.qtpl:8
import "github.com/bouncepaw/mycorrhiza/hypview"
//line views/readers.qtpl:9
//line hypview/readers.qtpl:8
import "github.com/bouncepaw/mycorrhiza/categories"
//line views/readers.qtpl:10
//line hypview/readers.qtpl:9
import "github.com/bouncepaw/mycorrhiza/l18n"
//line views/readers.qtpl:11
//line hypview/readers.qtpl:10
import "github.com/bouncepaw/mycorrhiza/mimetype"
//line views/readers.qtpl:12
//line hypview/readers.qtpl:11
import "github.com/bouncepaw/mycorrhiza/tree"
//line views/readers.qtpl:13
//line hypview/readers.qtpl:12
import "github.com/bouncepaw/mycorrhiza/user"
//line views/readers.qtpl:14
//line hypview/readers.qtpl:13
import "github.com/bouncepaw/mycorrhiza/util"
//line views/readers.qtpl:15
//line hypview/readers.qtpl:14
import "github.com/bouncepaw/mycorrhiza/viewutil"
//line views/readers.qtpl:17
//line hypview/readers.qtpl:16
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/readers.qtpl:17
//line hypview/readers.qtpl:16
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/readers.qtpl:17
//line hypview/readers.qtpl:16
func StreamMediaMenu(qw422016 *qt422016.Writer, rq *http.Request, h hyphae.Hypha, u *user.User) {
//line views/readers.qtpl:17
//line hypview/readers.qtpl:16
qw422016.N().S(`
`)
//line views/readers.qtpl:19
//line hypview/readers.qtpl:18
lc := l18n.FromRequest(rq)
//line views/readers.qtpl:20
//line hypview/readers.qtpl:19
qw422016.N().S(`
<main class="main-width media-tab">
<h1>`)
//line views/readers.qtpl:22
//line hypview/readers.qtpl:21
qw422016.N().S(lc.Get("ui.media_title", &l18n.Replacements{"name": beautifulLink(h.CanonicalName())}))
//line views/readers.qtpl:22
//line hypview/readers.qtpl:21
qw422016.N().S(`</h1>
`)
//line views/readers.qtpl:23
//line hypview/readers.qtpl:22
switch h.(type) {
//line views/readers.qtpl:24
//line hypview/readers.qtpl:23
case *hyphae.MediaHypha:
//line views/readers.qtpl:24
//line hypview/readers.qtpl:23
qw422016.N().S(`
<p class="explanation">`)
//line views/readers.qtpl:25
//line hypview/readers.qtpl:24
qw422016.E().S(lc.Get("ui.media_tip"))
//line views/readers.qtpl:25
//line hypview/readers.qtpl:24
qw422016.N().S(` <a href="/help/en/media" class="shy-link">`)
//line views/readers.qtpl:25
//line hypview/readers.qtpl:24
qw422016.E().S(lc.Get("ui.media_what_is"))
//line views/readers.qtpl:25
//line hypview/readers.qtpl:24
qw422016.N().S(`</a></p>
`)
//line views/readers.qtpl:26
//line hypview/readers.qtpl:25
default:
//line views/readers.qtpl:26
//line hypview/readers.qtpl:25
qw422016.N().S(`
<p class="explanation">`)
//line views/readers.qtpl:27
//line hypview/readers.qtpl:26
qw422016.E().S(lc.Get("ui.media_empty"))
//line views/readers.qtpl:27
//line hypview/readers.qtpl:26
qw422016.N().S(` <a href="/help/en/media" class="shy-link">`)
//line views/readers.qtpl:27
//line hypview/readers.qtpl:26
qw422016.E().S(lc.Get("ui.media_what_is"))
//line views/readers.qtpl:27
//line hypview/readers.qtpl:26
qw422016.N().S(`</a></p>
`)
//line views/readers.qtpl:28
//line hypview/readers.qtpl:27
}
//line views/readers.qtpl:28
//line hypview/readers.qtpl:27
qw422016.N().S(`
<section class="amnt-grid">
`)
//line views/readers.qtpl:31
//line hypview/readers.qtpl:30
switch h := h.(type) {
//line views/readers.qtpl:32
//line hypview/readers.qtpl:31
case *hyphae.MediaHypha:
//line views/readers.qtpl:32
//line hypview/readers.qtpl:31
qw422016.N().S(`
`)
//line views/readers.qtpl:34
//line hypview/readers.qtpl:33
mime := mimetype.FromExtension(path.Ext(h.MediaFilePath()))
fileinfo, err := os.Stat(h.MediaFilePath())
//line views/readers.qtpl:35
//line hypview/readers.qtpl:34
qw422016.N().S(`
`)
//line views/readers.qtpl:36
//line hypview/readers.qtpl:35
if err == nil {
//line views/readers.qtpl:36
//line hypview/readers.qtpl:35
qw422016.N().S(`
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">`)
//line views/readers.qtpl:38
//line hypview/readers.qtpl:37
qw422016.E().S(lc.Get("ui.media_stat"))
//line views/readers.qtpl:38
//line hypview/readers.qtpl:37
qw422016.N().S(`</legend>
<p class="modal__confirmation-msg"><b>`)
//line views/readers.qtpl:39
//line hypview/readers.qtpl:38
qw422016.E().S(lc.Get("ui.media_stat_size"))
//line views/readers.qtpl:39
//line hypview/readers.qtpl:38
qw422016.N().S(`</b> `)
//line views/readers.qtpl:39
//line hypview/readers.qtpl:38
qw422016.E().S(lc.GetPlural64("ui.media_size_value", fileinfo.Size()))
//line views/readers.qtpl:39
//line hypview/readers.qtpl:38
qw422016.N().S(`</p>
<p><b>`)
//line views/readers.qtpl:40
//line hypview/readers.qtpl:39
qw422016.E().S(lc.Get("ui.media_stat_mime"))
//line views/readers.qtpl:40
//line hypview/readers.qtpl:39
qw422016.N().S(`</b> `)
//line views/readers.qtpl:40
//line hypview/readers.qtpl:39
qw422016.E().S(mime)
//line views/readers.qtpl:40
//line hypview/readers.qtpl:39
qw422016.N().S(`</p>
</fieldset>
`)
//line views/readers.qtpl:42
//line hypview/readers.qtpl:41
}
//line views/readers.qtpl:42
//line hypview/readers.qtpl:41
qw422016.N().S(`
`)
//line views/readers.qtpl:44
//line hypview/readers.qtpl:43
if strings.HasPrefix(mime, "image/") {
//line views/readers.qtpl:44
//line hypview/readers.qtpl:43
qw422016.N().S(`
<fieldset class="amnt-menu-block">
<legend class="modal__title modal__title_small">`)
//line views/readers.qtpl:46
//line hypview/readers.qtpl:45
qw422016.E().S(lc.Get("ui.media_include"))
//line views/readers.qtpl:46
//line hypview/readers.qtpl:45
qw422016.N().S(`</legend>
<p class="modal__confirmation-msg">`)
//line views/readers.qtpl:47
//line hypview/readers.qtpl:46
qw422016.E().S(lc.Get("ui.media_include_tip"))
//line views/readers.qtpl:47
//line hypview/readers.qtpl:46
qw422016.N().S(`</p>
<pre class="codeblock"><code>img { `)
//line views/readers.qtpl:48
//line hypview/readers.qtpl:47
qw422016.E().S(h.CanonicalName())
//line views/readers.qtpl:48
//line hypview/readers.qtpl:47
qw422016.N().S(` }</code></pre>
</fieldset>
`)
//line views/readers.qtpl:50
//line hypview/readers.qtpl:49
}
//line views/readers.qtpl:50
//line hypview/readers.qtpl:49
qw422016.N().S(`
`)
//line views/readers.qtpl:51
//line hypview/readers.qtpl:50
}
//line views/readers.qtpl:51
//line hypview/readers.qtpl:50
qw422016.N().S(`
`)
//line views/readers.qtpl:53
//line hypview/readers.qtpl:52
if u.CanProceed("upload-binary") {
//line views/readers.qtpl:53
//line hypview/readers.qtpl:52
qw422016.N().S(`
<form action="/upload-binary/`)
//line views/readers.qtpl:54
//line hypview/readers.qtpl:53
qw422016.E().S(h.CanonicalName())
//line views/readers.qtpl:54
//line hypview/readers.qtpl:53
qw422016.N().S(`"
method="post" enctype="multipart/form-data"
class="upload-binary modal amnt-menu-block">
<fieldset class="modal__fieldset">
<legend class="modal__title modal__title_small">`)
//line views/readers.qtpl:58
//line hypview/readers.qtpl:57
qw422016.E().S(lc.Get("ui.media_new"))
//line views/readers.qtpl:58
//line hypview/readers.qtpl:57
qw422016.N().S(`</legend>
<p class="modal__confirmation-msg">`)
//line views/readers.qtpl:59
//line hypview/readers.qtpl:58
qw422016.E().S(lc.Get("ui.media_new_tip"))
//line views/readers.qtpl:59
//line hypview/readers.qtpl:58
qw422016.N().S(`</p>
<label for="upload-binary__input"></label>
<input type="file" id="upload-binary__input" name="binary">
<button type="submit" class="btn stick-to-bottom" value="Upload">`)
//line views/readers.qtpl:63
//line hypview/readers.qtpl:62
qw422016.E().S(lc.Get("ui.media_upload"))
//line views/readers.qtpl:63
//line hypview/readers.qtpl:62
qw422016.N().S(`</button>
</fieldset>
</form>
`)
//line views/readers.qtpl:66
//line hypview/readers.qtpl:65
}
//line views/readers.qtpl:66
//line hypview/readers.qtpl:65
qw422016.N().S(`
`)
//line views/readers.qtpl:69
//line hypview/readers.qtpl:68
switch h := h.(type) {
//line views/readers.qtpl:70
//line hypview/readers.qtpl:69
case *hyphae.MediaHypha:
//line views/readers.qtpl:70
//line hypview/readers.qtpl:69
qw422016.N().S(`
`)
//line views/readers.qtpl:71
//line hypview/readers.qtpl:70
if u.CanProceed("remove-media") {
//line views/readers.qtpl:71
//line hypview/readers.qtpl:70
qw422016.N().S(`
<form action="/remove-media/`)
//line views/readers.qtpl:72
//line hypview/readers.qtpl:71
qw422016.E().S(h.CanonicalName())
//line views/readers.qtpl:72
//line hypview/readers.qtpl:71
qw422016.N().S(`" method="post" class="modal amnt-menu-block" method="POST">
<fieldset class="modal__fieldset">
<legend class="modal__title modal__title_small">`)
//line views/readers.qtpl:74
//line hypview/readers.qtpl:73
qw422016.E().S(lc.Get("ui.media_remove"))
//line views/readers.qtpl:74
//line hypview/readers.qtpl:73
qw422016.N().S(`</legend>
<p class="modal__confirmation-msg">`)
//line views/readers.qtpl:75
//line hypview/readers.qtpl:74
qw422016.E().S(lc.Get("ui.media_remove_tip"))
//line views/readers.qtpl:75
//line hypview/readers.qtpl:74
qw422016.N().S(`</p>
<button type="submit" class="btn" value="Remove media">`)
//line views/readers.qtpl:76
//line hypview/readers.qtpl:75
qw422016.E().S(lc.Get("ui.media_remove_button"))
//line views/readers.qtpl:76
//line hypview/readers.qtpl:75
qw422016.N().S(`</button>
</fieldset>
</form>
`)
//line views/readers.qtpl:79
//line hypview/readers.qtpl:78
}
//line views/readers.qtpl:79
//line hypview/readers.qtpl:78
qw422016.N().S(`
`)
//line views/readers.qtpl:80
//line hypview/readers.qtpl:79
}
//line views/readers.qtpl:80
//line hypview/readers.qtpl:79
qw422016.N().S(`
</section>
</main>
`)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
}
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
func WriteMediaMenu(qq422016 qtio422016.Writer, rq *http.Request, h hyphae.Hypha, u *user.User) {
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
StreamMediaMenu(qw422016, rq, h, u)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
}
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
func MediaMenu(rq *http.Request, h hyphae.Hypha, u *user.User) string {
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
WriteMediaMenu(qb422016, rq, h, u)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
qs422016 := string(qb422016.B)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
return qs422016
//line views/readers.qtpl:84
//line hypview/readers.qtpl:83
}
// If `contents` == "", a helpful message is shown instead.
//
// If you rename .prevnext, change the docs too.
//line views/readers.qtpl:89
//line hypview/readers.qtpl:88
func StreamHypha(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha, contents string) {
//line views/readers.qtpl:89
//line hypview/readers.qtpl:88
qw422016.N().S(`
`)
//line views/readers.qtpl:91
//line hypview/readers.qtpl:90
subhyphae, prevHyphaName, nextHyphaName := tree.Tree(h.CanonicalName())
lc := meta.Lc
//line views/readers.qtpl:93
//line hypview/readers.qtpl:92
qw422016.N().S(`
<main class="main-width">
<section id="hypha">
`)
//line views/readers.qtpl:96
//line hypview/readers.qtpl:95
if meta.U.CanProceed("edit") {
//line views/readers.qtpl:96
//line hypview/readers.qtpl:95
qw422016.N().S(`
<div class="btn btn_navititle">
<a class="btn__link_navititle" href="/edit/`)
//line views/readers.qtpl:98
//line hypview/readers.qtpl:97
qw422016.E().S(h.CanonicalName())
//line views/readers.qtpl:98
//line hypview/readers.qtpl:97
qw422016.N().S(`">`)
//line views/readers.qtpl:98
//line hypview/readers.qtpl:97
qw422016.E().S(lc.Get("ui.edit_link"))
//line views/readers.qtpl:98
//line hypview/readers.qtpl:97
qw422016.N().S(`</a>
</div>
`)
//line views/readers.qtpl:100
//line hypview/readers.qtpl:99
}
//line views/readers.qtpl:100
//line hypview/readers.qtpl:99
qw422016.N().S(`
`)
//line views/readers.qtpl:102
//line hypview/readers.qtpl:101
if cfg.UseAuth && util.IsProfileName(h.CanonicalName()) && meta.U.Name == strings.TrimPrefix(h.CanonicalName(), cfg.UserHypha+"/") {
//line views/readers.qtpl:102
//line hypview/readers.qtpl:101
qw422016.N().S(`
<div class="btn btn_navititle">
<a class="btn__link_navititle" href="/logout">`)
//line views/readers.qtpl:104
//line hypview/readers.qtpl:103
qw422016.E().S(lc.Get("ui.logout_link"))
//line views/readers.qtpl:104
//line hypview/readers.qtpl:103
qw422016.N().S(`</a>
</div>
`)
//line views/readers.qtpl:106
//line hypview/readers.qtpl:105
if meta.U.Group == "admin" {
//line views/readers.qtpl:106
//line hypview/readers.qtpl:105
qw422016.N().S(`
<div class="btn btn_navititle">
<a class="btn__link_navititle" href="/admin">`)
//line views/readers.qtpl:108
//line hypview/readers.qtpl:107
qw422016.E().S(lc.Get("ui.admin_panel"))
//line views/readers.qtpl:108
//line hypview/readers.qtpl:107
qw422016.N().S(`<a>
</div>
`)
//line views/readers.qtpl:110
//line hypview/readers.qtpl:109
}
//line views/readers.qtpl:110
//line hypview/readers.qtpl:109
qw422016.N().S(`
`)
//line views/readers.qtpl:111
//line hypview/readers.qtpl:110
}
//line views/readers.qtpl:111
//line hypview/readers.qtpl:110
qw422016.N().S(`
`)
//line views/readers.qtpl:113
qw422016.N().S(hypview.NaviTitle(meta, h.CanonicalName()))
//line views/readers.qtpl:113
//line hypview/readers.qtpl:112
qw422016.N().S(NaviTitle(meta, h.CanonicalName()))
//line hypview/readers.qtpl:112
qw422016.N().S(`
`)
//line views/readers.qtpl:114
//line hypview/readers.qtpl:113
switch h.(type) {
//line views/readers.qtpl:115
//line hypview/readers.qtpl:114
case *hyphae.EmptyHypha:
//line views/readers.qtpl:115
//line hypview/readers.qtpl:114
qw422016.N().S(`
`)
//line views/readers.qtpl:116
qw422016.N().S(hypview.EmptyHypha(meta, h.CanonicalName()))
//line views/readers.qtpl:116
//line hypview/readers.qtpl:115
qw422016.N().S(EmptyHypha(meta, h.CanonicalName()))
//line hypview/readers.qtpl:115
qw422016.N().S(`
`)
//line views/readers.qtpl:117
//line hypview/readers.qtpl:116
default:
//line views/readers.qtpl:117
//line hypview/readers.qtpl:116
qw422016.N().S(`
`)
//line views/readers.qtpl:118
//line hypview/readers.qtpl:117
qw422016.N().S(contents)
//line views/readers.qtpl:118
//line hypview/readers.qtpl:117
qw422016.N().S(`
`)
//line views/readers.qtpl:119
//line hypview/readers.qtpl:118
}
//line views/readers.qtpl:119
//line hypview/readers.qtpl:118
qw422016.N().S(`
</section>
<section class="prevnext">
`)
//line views/readers.qtpl:122
//line hypview/readers.qtpl:121
if prevHyphaName != "" {
//line views/readers.qtpl:122
//line hypview/readers.qtpl:121
qw422016.N().S(`
<a class="prevnext__el prevnext__prev" href="/hypha/`)
//line views/readers.qtpl:123
//line hypview/readers.qtpl:122
qw422016.E().S(prevHyphaName)
//line views/readers.qtpl:123
//line hypview/readers.qtpl:122
qw422016.N().S(`" rel="prev">← `)
//line views/readers.qtpl:123
//line hypview/readers.qtpl:122
qw422016.E().S(util.BeautifulName(path.Base(prevHyphaName)))
//line views/readers.qtpl:123
//line hypview/readers.qtpl:122
qw422016.N().S(`</a>
`)
//line views/readers.qtpl:124
//line hypview/readers.qtpl:123
}
//line views/readers.qtpl:124
//line hypview/readers.qtpl:123
qw422016.N().S(`
`)
//line views/readers.qtpl:125
//line hypview/readers.qtpl:124
if nextHyphaName != "" {
//line views/readers.qtpl:125
//line hypview/readers.qtpl:124
qw422016.N().S(`
<a class="prevnext__el prevnext__next" href="/hypha/`)
//line views/readers.qtpl:126
//line hypview/readers.qtpl:125
qw422016.E().S(nextHyphaName)
//line views/readers.qtpl:126
//line hypview/readers.qtpl:125
qw422016.N().S(`" rel="next">`)
//line views/readers.qtpl:126
//line hypview/readers.qtpl:125
qw422016.E().S(util.BeautifulName(path.Base(nextHyphaName)))
//line views/readers.qtpl:126
//line hypview/readers.qtpl:125
qw422016.N().S(` </a>
`)
//line views/readers.qtpl:127
//line hypview/readers.qtpl:126
}
//line views/readers.qtpl:127
//line hypview/readers.qtpl:126
qw422016.N().S(`
</section>
`)
//line views/readers.qtpl:129
//line hypview/readers.qtpl:128
if strings.TrimSpace(subhyphae) != "" {
//line views/readers.qtpl:129
//line hypview/readers.qtpl:128
qw422016.N().S(`
<section class="subhyphae">
<h2 class="subhyphae__title">`)
//line views/readers.qtpl:131
//line hypview/readers.qtpl:130
qw422016.E().S(lc.Get("ui.subhyphae"))
//line views/readers.qtpl:131
//line hypview/readers.qtpl:130
qw422016.N().S(`</h2>
<nav class="subhyphae__nav">
<ul class="subhyphae__list">
`)
//line views/readers.qtpl:134
//line hypview/readers.qtpl:133
qw422016.N().S(subhyphae)
//line views/readers.qtpl:134
//line hypview/readers.qtpl:133
qw422016.N().S(`
</ul>
</nav>
</section>
`)
//line views/readers.qtpl:138
//line hypview/readers.qtpl:137
}
//line views/readers.qtpl:138
//line hypview/readers.qtpl:137
qw422016.N().S(`
<section id="hypha-bottom">
`)
//line views/readers.qtpl:140
//line hypview/readers.qtpl:139
streamhyphaInfo(qw422016, meta, h)
//line views/readers.qtpl:140
//line hypview/readers.qtpl:139
qw422016.N().S(`
</section>
</main>
`)
//line views/readers.qtpl:143
//line hypview/readers.qtpl:142
qw422016.N().S(categories.CategoryCard(meta, h.CanonicalName()))
//line views/readers.qtpl:143
//line hypview/readers.qtpl:142
qw422016.N().S(`
`)
//line views/readers.qtpl:144
//line hypview/readers.qtpl:143
streamviewScripts(qw422016)
//line views/readers.qtpl:144
//line hypview/readers.qtpl:143
qw422016.N().S(`
`)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
}
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
func WriteHypha(qq422016 qtio422016.Writer, meta viewutil.Meta, h hyphae.Hypha, contents string) {
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
StreamHypha(qw422016, meta, h, contents)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
}
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
func Hypha(meta viewutil.Meta, h hyphae.Hypha, contents string) string {
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
WriteHypha(qb422016, meta, h, contents)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
qs422016 := string(qb422016.B)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
return qs422016
//line views/readers.qtpl:145
//line hypview/readers.qtpl:144
}
//line views/readers.qtpl:147
//line hypview/readers.qtpl:146
func StreamRevision(qw422016 *qt422016.Writer, meta viewutil.Meta, h hyphae.Hypha, contents, revHash string) {
//line views/readers.qtpl:147
//line hypview/readers.qtpl:146
qw422016.N().S(`
<main class="main-width">
<section>
<p>`)
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.E().S(meta.Lc.Get("ui.revision_warning"))
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.N().S(` <a href="/rev-text/`)
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.E().S(revHash)
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.N().S(`/`)
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.E().S(h.CanonicalName())
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.N().S(`">`)
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.E().S(meta.Lc.Get("ui.revision_link"))
//line views/readers.qtpl:150
//line hypview/readers.qtpl:149
qw422016.N().S(`</a></p>
`)
//line views/readers.qtpl:151
qw422016.N().S(hypview.NaviTitle(meta, h.CanonicalName()))
//line views/readers.qtpl:151
//line hypview/readers.qtpl:150
qw422016.N().S(NaviTitle(meta, h.CanonicalName()))
//line hypview/readers.qtpl:150
qw422016.N().S(`
`)
//line views/readers.qtpl:152
//line hypview/readers.qtpl:151
qw422016.N().S(contents)
//line views/readers.qtpl:152
//line hypview/readers.qtpl:151
qw422016.N().S(`
</section>
</main>
`)
//line views/readers.qtpl:155
//line hypview/readers.qtpl:154
streamviewScripts(qw422016)
//line views/readers.qtpl:155
//line hypview/readers.qtpl:154
qw422016.N().S(`
`)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
}
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
func WriteRevision(qq422016 qtio422016.Writer, meta viewutil.Meta, h hyphae.Hypha, contents, revHash string) {
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
StreamRevision(qw422016, meta, h, contents, revHash)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
}
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
func Revision(meta viewutil.Meta, h hyphae.Hypha, contents, revHash string) string {
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
WriteRevision(qb422016, meta, h, contents, revHash)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
qs422016 := string(qb422016.B)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
return qs422016
//line views/readers.qtpl:156
//line hypview/readers.qtpl:155
}
//line views/readers.qtpl:158
//line hypview/readers.qtpl:157
func streamviewScripts(qw422016 *qt422016.Writer) {
//line views/readers.qtpl:158
//line hypview/readers.qtpl:157
qw422016.N().S(`
`)
//line views/readers.qtpl:159
//line hypview/readers.qtpl:158
for _, scriptPath := range cfg.ViewScripts {
//line views/readers.qtpl:159
//line hypview/readers.qtpl:158
qw422016.N().S(`
<script src="`)
//line views/readers.qtpl:160
//line hypview/readers.qtpl:159
qw422016.E().S(scriptPath)
//line views/readers.qtpl:160
//line hypview/readers.qtpl:159
qw422016.N().S(`"></script>
`)
//line views/readers.qtpl:161
//line hypview/readers.qtpl:160
}
//line views/readers.qtpl:161
//line hypview/readers.qtpl:160
qw422016.N().S(`
`)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
}
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
func writeviewScripts(qq422016 qtio422016.Writer) {
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
streamviewScripts(qw422016)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
qt422016.ReleaseWriter(qw422016)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
}
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
func viewScripts() string {
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
qb422016 := qt422016.AcquireByteBuffer()
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
writeviewScripts(qb422016)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
qs422016 := string(qb422016.B)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
qt422016.ReleaseByteBuffer(qb422016)
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
return qs422016
//line views/readers.qtpl:162
//line hypview/readers.qtpl:161
}

View File

@ -1,109 +1,109 @@
// Code generated by qtc from "modal.qtpl". DO NOT EDIT.
// Code generated by qtc from "remove_media.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.
//line views/modal.qtpl:1
package views
//line hypview/remove_media.qtpl:1
package hypview
//line views/modal.qtpl:1
//line hypview/remove_media.qtpl:1
import "fmt"
//line views/modal.qtpl:2
//line hypview/remove_media.qtpl:2
import "net/http"
//line views/modal.qtpl:3
//line hypview/remove_media.qtpl:3
import "github.com/bouncepaw/mycorrhiza/l18n"
//line views/modal.qtpl:5
//line hypview/remove_media.qtpl:5
import (
qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate"
)
//line views/modal.qtpl:5
//line hypview/remove_media.qtpl:5
var (
_ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer
)
//line views/modal.qtpl:5
//line hypview/remove_media.qtpl:5
func StreamRemoveMediaAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:5
//line hypview/remove_media.qtpl:5
qw422016.N().S(`
`)
//line views/modal.qtpl:7
//line hypview/remove_media.qtpl:7
lc := l18n.FromRequest(rq)
//line views/modal.qtpl:8
//line hypview/remove_media.qtpl:8
qw422016.N().S(`
<main class="main-width">
<form class="modal" action="/remove-media/`)
//line views/modal.qtpl:10
//line hypview/remove_media.qtpl:10
qw422016.E().S(hyphaName)
//line views/modal.qtpl:10
//line hypview/remove_media.qtpl:10
qw422016.N().S(`" method="post">
<fieldset class="modal__fieldset">
<legend class="modal__title">
`)
//line views/modal.qtpl:13
//line hypview/remove_media.qtpl:13
qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName)))
//line views/modal.qtpl:13
//line hypview/remove_media.qtpl:13
qw422016.N().S(`
</legend>
<p class="modal__confirmation-msg">
`)
//line views/modal.qtpl:16
//line hypview/remove_media.qtpl:16
qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": lc.Get("ui.ask_remove_media_verb"), "name": fmt.Sprintf("<em>%s</em>", hyphaName)}))
//line views/modal.qtpl:16
//line hypview/remove_media.qtpl:16
qw422016.N().S(`
</p>
<button type="submit" value="Confirm" class="btn" autofocus>
`)
//line views/modal.qtpl:19
//line hypview/remove_media.qtpl:19
qw422016.E().S(lc.Get("ui.confirm"))
//line views/modal.qtpl:19
//line hypview/remove_media.qtpl:19
qw422016.N().S(`
</button>
<a href="/hypha/`)
//line views/modal.qtpl:21
//line hypview/remove_media.qtpl:21
qw422016.E().S(hyphaName)
//line views/modal.qtpl:21
//line hypview/remove_media.qtpl:21
qw422016.N().S(`" class="btn btn_weak">
`)
//line views/modal.qtpl:22
//line hypview/remove_media.qtpl:22
qw422016.E().S(lc.Get("ui.cancel"))
//line views/modal.qtpl:22
//line hypview/remove_media.qtpl:22
qw422016.N().S(`
</a>
</fieldset>
</form>
</main>
`)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
}
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
func WriteRemoveMediaAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
StreamRemoveMediaAsk(qw422016, rq, hyphaName)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
qt422016.ReleaseWriter(qw422016)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
}
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
func RemoveMediaAsk(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
qb422016 := qt422016.AcquireByteBuffer()
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
WriteRemoveMediaAsk(qb422016, rq, hyphaName)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
qs422016 := string(qb422016.B)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
qt422016.ReleaseByteBuffer(qb422016)
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
return qs422016
//line views/modal.qtpl:27
//line hypview/remove_media.qtpl:27
}

View File

@ -1,7 +1,9 @@
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=views
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=tree
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=history
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=mycoopts
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=auth
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=hypview
//go:generate go run github.com/valyala/quicktemplate/qtc -dir=admin
// Command mycorrhiza is a program that runs a mycorrhiza wiki.
package main

View File

@ -1,4 +1,4 @@
package views
package misc
import (
"github.com/bouncepaw/mycorrhiza/cfg"
@ -9,21 +9,21 @@ import (
"text/template" // sic!
)
type l10nEntry struct {
type L10nEntry struct {
_en string
_ru string
}
func en(v string) l10nEntry {
return l10nEntry{_en: v}
func En(v string) L10nEntry {
return L10nEntry{_en: v}
}
func (e l10nEntry) ru(v string) l10nEntry {
func (e L10nEntry) Ru(v string) L10nEntry {
e._ru = v
return e
}
func (e l10nEntry) get(lang string) string {
func (e L10nEntry) Get(lang string) string {
if lang == "ru" && e._ru != "" {
return e._ru
}
@ -66,30 +66,30 @@ const aboutTemplateString = `
</main>`
var aboutData = struct {
L map[string]l10nEntry
L map[string]L10nEntry
Cfg map[string]interface{}
Admins []string
UserCount uint64
RegistrationLimit uint64
}{
L: map[string]l10nEntry{
"Title": en("About %s").ru("О %s"),
"Version": en("<a href=\"https://mycorrhiza.wiki\">Mycorrhiza Wiki</a> version").ru("Версия <a href=\"https://mycorrhiza.wiki\">Микоризы</a>"),
"UserCount": en("User count").ru("Число пользователей"),
"HomeHypha": en("Home hypha").ru("Домашняя гифа"),
"RegistrationLimit": en("RegistrationLimit").ru("Максимум пользователей"),
"Admins": en("Administrators").ru("Администраторы"),
L: map[string]L10nEntry{
"Title": En("About %s").Ru("О %s"),
"Version": En("<a href=\"https://mycorrhiza.wiki\">Mycorrhiza Wiki</a> version").Ru("Версия <a href=\"https://mycorrhiza.wiki\">Микоризы</a>"),
"UserCount": En("User count").Ru("Число пользователей"),
"HomeHypha": En("Home hypha").Ru("Домашняя гифа"),
"RegistrationLimit": En("RegistrationLimit").Ru("Максимум пользователей"),
"Admins": En("Administrators").Ru("Администраторы"),
"Auth": en("Authentication").ru("Аутентификация"),
"AuthOn": en("Authentication is on").ru("Аутентификация включена"),
"AuthOff": en("Authentication is off").ru("Аутентификация не включена"),
"TelegramOn": en("Telegram authentication is on").ru("Вход через Телеграм включён"),
"Auth": En("Authentication").Ru("Аутентификация"),
"AuthOn": En("Authentication is on").Ru("Аутентификация включена"),
"AuthOff": En("Authentication is off").Ru("Аутентификация не включена"),
"TelegramOn": En("Telegram authentication is on").Ru("Вход через Телеграм включён"),
},
}
func AboutHTML(lc *l18n.Localizer) string {
get := func(e l10nEntry) string {
return e.get(lc.Locale)
get := func(e L10nEntry) string {
return e.Get(lc.Locale)
}
temp, err := template.New("about wiki").Funcs(template.FuncMap{"get": get}).Parse(aboutTemplateString)
if err != nil {

View File

@ -11,7 +11,6 @@ import (
"github.com/bouncepaw/mycorrhiza/static"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
"github.com/bouncepaw/mycorrhiza/viewutil"
"github.com/gorilla/mux"
"io"
@ -122,10 +121,10 @@ func handlerAbout(w http.ResponseWriter, rq *http.Request) {
lc = l18n.FromRequest(rq)
title = lc.Get("ui.about_title", &l18n.Replacements{"name": cfg.WikiName})
)
_, err := io.WriteString(w, views.Base(
_, err := io.WriteString(w, viewutil.Base(
viewutil.MetaFrom(w, rq),
title,
views.AboutHTML(lc),
AboutHTML(lc),
))
if err != nil {
log.Println(err)

View File

@ -1,9 +0,0 @@
package views
import (
"github.com/bouncepaw/mycorrhiza/viewutil"
)
var (
Base = viewutil.Base
)

View File

@ -18,7 +18,6 @@ import (
"github.com/bouncepaw/mycorrhiza/shroom"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
)
func initMutators(r *mux.Router) {
@ -47,10 +46,10 @@ func handlerRemoveMedia(w http.ResponseWriter, rq *http.Request) {
if rq.Method == "GET" {
util.HTTP200Page(
w,
views.Base(
viewutil.Base(
meta,
fmt.Sprintf(lc.Get("ui.ask_remove_media"), util.BeautifulName(h.CanonicalName())),
views.RemoveMediaAsk(rq, h.CanonicalName())))
hypview.RemoveMediaAsk(rq, h.CanonicalName())))
return
}
switch h := h.(type) {
@ -173,10 +172,10 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) {
}
util.HTTP200Page(
w,
views.Base(
viewutil.Base(
meta,
fmt.Sprintf(lc.Get("edit.title"), util.BeautifulName(hyphaName)),
views.Editor(rq, hyphaName, textAreaFill, warning)))
hypview.Editor(rq, hyphaName, textAreaFill, warning)))
}
// handlerUploadText uploads a new text part for the hypha.
@ -205,10 +204,10 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) {
util.HTTP200Page(
w,
views.Base(
viewutil.Base(
meta,
fmt.Sprintf(lc.Get("edit.preview_title"), util.BeautifulName(hyphaName)),
views.Preview(
hypview.Preview(
rq,
hyphaName,
textData,

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/bouncepaw/mycomarkup/v5"
"github.com/bouncepaw/mycorrhiza/files"
views2 "github.com/bouncepaw/mycorrhiza/hypview"
"github.com/bouncepaw/mycorrhiza/mycoopts"
"github.com/bouncepaw/mycorrhiza/viewutil"
"io"
@ -15,16 +16,14 @@ import (
"github.com/gorilla/mux"
"github.com/bouncepaw/mycomarkup/v5/mycocontext"
"github.com/bouncepaw/mycomarkup/v5/tools"
"github.com/bouncepaw/mycorrhiza/history"
"github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/l18n"
"github.com/bouncepaw/mycorrhiza/mimetype"
"github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/views"
"github.com/bouncepaw/mycomarkup/v5/mycocontext"
"github.com/bouncepaw/mycomarkup/v5/tools"
)
func initReaders(r *mux.Router) {
@ -46,10 +45,10 @@ func handlerMedia(w http.ResponseWriter, rq *http.Request) {
lc = l18n.FromRequest(rq)
)
util.HTTP200Page(w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("ui.media_title", &l18n.Replacements{"name": util.BeautifulName(hyphaName)}),
views.MediaMenu(rq, h, u)))
views2.MediaMenu(rq, h, u)))
}
// handlerRevisionText sends Mycomarkup text of the hypha at the given revision. See also: handlerRevision, handlerText.
@ -128,7 +127,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) {
contents = mycomarkup.BlocksToHTML(ctx, mycomarkup.BlockTree(ctx))
}
page := views.Revision(
page := views2.Revision(
viewutil.MetaFrom(w, rq),
h,
contents,
@ -138,7 +137,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprint(
w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
lc.Get("ui.revision_title", &l18n.Replacements{"name": util.BeautifulName(hyphaName), "rev": revHash}),
page,
@ -188,10 +187,10 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
switch h := h.(type) {
case *hyphae.EmptyHypha:
util.HTTP404Page(w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
util.BeautifulName(hyphaName),
views.Hypha(viewutil.MetaFrom(w, rq), h, contents),
views2.Hypha(viewutil.MetaFrom(w, rq), h, contents),
openGraph))
case hyphae.ExistingHypha:
fileContentsT, errT := os.ReadFile(h.TextFilePath())
@ -208,10 +207,10 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
}
util.HTTP200Page(w,
views.Base(
viewutil.Base(
viewutil.MetaFrom(w, rq),
util.BeautifulName(hyphaName),
views.Hypha(viewutil.MetaFrom(w, rq), h, contents),
views2.Hypha(viewutil.MetaFrom(w, rq), h, contents),
openGraph))
}
}

View File

@ -3,6 +3,7 @@ package web
import (
"github.com/bouncepaw/mycorrhiza/admin"
"github.com/bouncepaw/mycorrhiza/auth"
"github.com/bouncepaw/mycorrhiza/backlinks"
"github.com/bouncepaw/mycorrhiza/categories"
"github.com/bouncepaw/mycorrhiza/help"
@ -36,7 +37,7 @@ func Handler() http.Handler {
router.StrictSlash(true)
// Public routes. They're always accessible regardless of the user status.
initAuth(router)
auth.InitAuth(router)
// Wiki routes. They may be locked or restricted.
wikiRouter := router.PathPrefix("").Subrouter()