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

Auth: Fix the links appearing on anonymous wikis

This commit is contained in:
Timur Ismagilov 2022-04-29 12:52:31 +03:00
parent 797293203f
commit 758f8e876f
2 changed files with 30 additions and 28 deletions

View File

@ -26,30 +26,7 @@
</form>
</li>
<li class="top-bar__section top-bar__section_auth">
{{block "auth" .}}
<ul class="top-bar__auth auth-links">
<li class="auth-links__box auth-links__user-box">
{{if .Meta.U.Group | eq "anon" }}
<a href="/login" class="auth-links__link auth-links__login-link">
{{block "login" .}}Login{{end}}
</a>
{{else}}
<a href="/hypha/{{block "user hypha" .}}{{end}}/{{.Meta.U.Name}}" class="auth-links__link auth-links__user-link">
{{beautifulName .Meta.U.Name}}
</a>
{{end}}
</li>
{{block "registration" .}}
{{if .Meta.U.Group | eq "anon"}}
<li class="auth-links__box auth-links__register-box">
<a href="/register" class="auth-links__link auth-links__register-link">
{{block "register" .}}Register{{end}}
</a>
</li>
{{end}}
{{end}}
</ul>
{{end}}
{{block "auth" .}}{{end}}
</li>
<li class="top-bar__section top-bar__section_highlights">
<ul class="top-bar__highlights">

View File

@ -38,11 +38,36 @@ func Init() {
"inc": func(i int) int { return i + 1 },
}).ParseFS(fsys, "base.html")).
Parse(dataText))
if !cfg.UseAuth {
m(BaseEn.Parse(`{{define "auth"}}{{end}}`))
if cfg.UseAuth {
BaseEn = m(BaseEn.Parse(`
{{define "auth"}}
<ul class="top-bar__auth auth-links">
<li class="auth-links__box auth-links__user-box">
{{if .Meta.U.Group | eq "anon" }}
<a href="/login" class="auth-links__link auth-links__login-link">
{{block "login" .}}Login{{end}}
</a>
{{else}}
<a href="/hypha/{{block "user hypha" .}}{{end}}/{{.Meta.U.Name}}" class="auth-links__link auth-links__user-link">
{{beautifulName .Meta.U.Name}}
</a>
{{end}}
</li>
{{block "registration" .}}{{end}}
</ul>
{{end}}
`))
}
if !cfg.AllowRegistration {
m(BaseEn.Parse(`{{define "registration"}}{{end}}`))
if cfg.AllowRegistration {
m(BaseEn.Parse(`{{define "registration"}}
{{if .Meta.U.Group | eq "anon"}}
<li class="auth-links__box auth-links__register-box">
<a href="/register" class="auth-links__link auth-links__register-link">
{{block "register" .}}Register{{end}}
</a>
</li>
{{end}}
{{end}}`))
}
BaseRu = m(m(BaseEn.Clone()).Parse(ruText))
}