diff --git a/l18n/en/admin.json b/l18n/en/admin.json index 76e2679..afa173c 100644 --- a/l18n/en/admin.json +++ b/l18n/en/admin.json @@ -1,14 +1,4 @@ { - "panel_title": "Administrative functions", - "panel_safe": "Safe things", - "panel_unsafe": "Dangerous things", - "panel_about": "About this wiki", - "panel_userlist": "User list", - "panel_updateheader": "Update header links", - "panel_users": "Manage users", - "panel_shutdown": "Shutdown wiki", - "panel_reindex": "Reindex hyphae", - "users_title": "Manage users", "users_create": "Create a new user", "users_reindex": "Reindex users", diff --git a/l18n/ru/admin.json b/l18n/ru/admin.json index 612a1e6..aacd0f3 100644 --- a/l18n/ru/admin.json +++ b/l18n/ru/admin.json @@ -1,14 +1,4 @@ { - "panel_title": "Панель администратора", - "panel_safe": "Безопасные действия", - "panel_unsafe": "Опасные действия", - "panel_about": "Об этой вики", - "panel_userlist": "Список пользователей", - "panel_updateheader": "Обновить ссылки верхней панели", - "panel_users": "Менеджер пользователей", - "panel_shutdown": "Отключить вики", - "panel_reindex": "Переиндексировать гифы", - "users_title": "Менеджер пользователей", "users_create": "Создать пользователя", "users_reindex": "Переиндексировать пользователей", diff --git a/views/admin.go b/views/admin.go new file mode 100644 index 0000000..dd89e2b --- /dev/null +++ b/views/admin.go @@ -0,0 +1,74 @@ +package views + +import ( + "github.com/bouncepaw/mycorrhiza/util" + "html/template" + "io" + "log" + "strings" +) + +const adminTranslationRu = ` +{{define "panel title"}}Панель админстратора{{end}} +{{define "panel safe section title"}}Безопасная секция{{end}} +{{define "panel link about"}}Об этой вики{{end}} +{{define "panel update header"}}Обновить ссылки в верхней панели{{end}} +{{define "panel link user list"}}Список пользователей{{end}} +{{define "panel users"}}Управление пользователями{{end}} +{{define "panel unsafe section title"}}Опасная секция{{end}} +{{define "panel shutdown"}}Выключить вики{{end}} +{{define "panel reindex hyphae"}}Переиндексировать гифы{{end}} +` + +var ( + adminTemplatesEn *template.Template + adminTemplatesRu *template.Template +) + +func localizedAdminTemplates(meta Meta) *template.Template { + if meta.Lc.Locale == "ru" { + return adminTemplatesRu + } + return adminTemplatesEn +} + +func templateAsString(temp *template.Template, name string, datum ...interface{}) string { + var buf strings.Builder + var err error + if len(datum) == 1 { + err = temp.ExecuteTemplate(&buf, name, datum[0]) + } else { + err = temp.ExecuteTemplate(&buf, name, nil) + } + if err != nil { + log.Println(err) + return "" + } + return buf.String() +} + +func init() { + adminTemplatesEn = template.Must( + template. + New("admin"). + Funcs(template.FuncMap{ + "beautifulName": util.BeautifulName, + }). + ParseFS(fs, "admin.html")) + adminTemplatesRu = template.Must( + template.Must(adminTemplatesEn.Clone()).Parse(adminTranslationRu)) +} + +func AdminPanel(meta Meta) { + var buf strings.Builder + err := localizedAdminTemplates(meta).ExecuteTemplate(&buf, "panel", nil) + if err != nil { + log.Println(err) + } + _, err = io.WriteString(meta.W, Base( + templateAsString(localizedAdminTemplates(meta), "panel title"), + buf.String(), + meta.Lc, + meta.U, + )) +} diff --git a/views/admin.html b/views/admin.html new file mode 100644 index 0000000..2445d96 --- /dev/null +++ b/views/admin.html @@ -0,0 +1,34 @@ +{{define "panel title"}}Administrative functions{{end}} +{{define "panel"}} +
+
+

{{template "panel title"}}

+
+

{{block "panel safe section title" .}}Safe section{{end}}

+ +
+
+

{{block "panel unsafe section title" .}}Unsafe section{{end}}

+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+
+
+{{end}} diff --git a/views/admin.qtpl b/views/admin.qtpl index 25156b5..f27a6d7 100644 --- a/views/admin.qtpl +++ b/views/admin.qtpl @@ -4,38 +4,6 @@ {% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} -{% func AdminPanel(lc *l18n.Localizer) %} -
-
-

{%s lc.Get("admin.panel_title") %}

-
-

{%s lc.Get("admin.panel_safe") %}

- -
-
-

{%s lc.Get("admin.panel_unsafe") %}

-
-
- {%s lc.Get("admin.panel_shutdown") %} - -
-
-
-
- {%s lc.Get("admin.panel_reindex") %} - -
-
-
-
-
-{% endfunc %} - {% func AdminUsersPanel(userList []*user.User, lc *l18n.Localizer) %}
diff --git a/views/admin.qtpl.go b/views/admin.qtpl.go index 783ad1d..b24b452 100644 --- a/views/admin.qtpl.go +++ b/views/admin.qtpl.go @@ -33,126 +33,27 @@ var ( ) //line views/admin.qtpl:7 -func StreamAdminPanel(qw422016 *qt422016.Writer, lc *l18n.Localizer) { +func StreamAdminUsersPanel(qw422016 *qt422016.Writer, userList []*user.User, lc *l18n.Localizer) { //line views/admin.qtpl:7 qw422016.N().S(`

`) //line views/admin.qtpl:10 - qw422016.E().S(lc.Get("admin.panel_title")) -//line views/admin.qtpl:10 - qw422016.N().S(`

-
-

`) -//line views/admin.qtpl:12 - qw422016.E().S(lc.Get("admin.panel_safe")) -//line views/admin.qtpl:12 - qw422016.N().S(`

- -
-
-

`) -//line views/admin.qtpl:21 - qw422016.E().S(lc.Get("admin.panel_unsafe")) -//line views/admin.qtpl:21 - qw422016.N().S(`

-
-
- `) -//line views/admin.qtpl:24 - qw422016.E().S(lc.Get("admin.panel_shutdown")) -//line views/admin.qtpl:24 - qw422016.N().S(` - -
-
-
-
- `) -//line views/admin.qtpl:30 - qw422016.E().S(lc.Get("admin.panel_reindex")) -//line views/admin.qtpl:30 - qw422016.N().S(` - -
-
-
-
-
-`) -//line views/admin.qtpl:37 -} - -//line views/admin.qtpl:37 -func WriteAdminPanel(qq422016 qtio422016.Writer, lc *l18n.Localizer) { -//line views/admin.qtpl:37 - qw422016 := qt422016.AcquireWriter(qq422016) -//line views/admin.qtpl:37 - StreamAdminPanel(qw422016, lc) -//line views/admin.qtpl:37 - qt422016.ReleaseWriter(qw422016) -//line views/admin.qtpl:37 -} - -//line views/admin.qtpl:37 -func AdminPanel(lc *l18n.Localizer) string { -//line views/admin.qtpl:37 - qb422016 := qt422016.AcquireByteBuffer() -//line views/admin.qtpl:37 - WriteAdminPanel(qb422016, lc) -//line views/admin.qtpl:37 - qs422016 := string(qb422016.B) -//line views/admin.qtpl:37 - qt422016.ReleaseByteBuffer(qb422016) -//line views/admin.qtpl:37 - return qs422016 -//line views/admin.qtpl:37 -} - -//line views/admin.qtpl:39 -func StreamAdminUsersPanel(qw422016 *qt422016.Writer, userList []*user.User, lc *l18n.Localizer) { -//line views/admin.qtpl:39 - qw422016.N().S(` -
-
-

`) -//line views/admin.qtpl:42 qw422016.E().S(lc.Get("admin.users_title")) -//line views/admin.qtpl:42 +//line views/admin.qtpl:10 qw422016.N().S(`

`) -//line views/admin.qtpl:45 +//line views/admin.qtpl:13 qw422016.E().S(lc.Get("admin.users_create")) -//line views/admin.qtpl:45 +//line views/admin.qtpl:13 qw422016.N().S(`
@@ -162,245 +63,245 @@ func StreamAdminUsersPanel(qw422016 *qt422016.Writer, userList []*user.User, lc `) -//line views/admin.qtpl:54 +//line views/admin.qtpl:22 qw422016.E().S(lc.Get("admin.users_name")) -//line views/admin.qtpl:54 +//line views/admin.qtpl:22 qw422016.N().S(` `) -//line views/admin.qtpl:55 +//line views/admin.qtpl:23 qw422016.E().S(lc.Get("admin.users_group")) -//line views/admin.qtpl:55 +//line views/admin.qtpl:23 qw422016.N().S(` `) -//line views/admin.qtpl:56 +//line views/admin.qtpl:24 qw422016.E().S(lc.Get("admin.users_registered")) -//line views/admin.qtpl:56 +//line views/admin.qtpl:24 qw422016.N().S(` `) -//line views/admin.qtpl:61 +//line views/admin.qtpl:29 for _, u := range userList { -//line views/admin.qtpl:61 +//line views/admin.qtpl:29 qw422016.N().S(` `) -//line views/admin.qtpl:64 +//line views/admin.qtpl:32 qw422016.E().S(u.Name) -//line views/admin.qtpl:64 +//line views/admin.qtpl:32 qw422016.N().S(` `) -//line views/admin.qtpl:66 +//line views/admin.qtpl:34 qw422016.E().S(u.Group) -//line views/admin.qtpl:66 +//line views/admin.qtpl:34 qw422016.N().S(` `) -//line views/admin.qtpl:68 +//line views/admin.qtpl:36 if u.RegisteredAt.IsZero() { -//line views/admin.qtpl:68 +//line views/admin.qtpl:36 qw422016.N().S(` `) -//line views/admin.qtpl:69 +//line views/admin.qtpl:37 qw422016.E().S(lc.Get("admin.users_notime")) -//line views/admin.qtpl:69 +//line views/admin.qtpl:37 qw422016.N().S(` `) -//line views/admin.qtpl:70 +//line views/admin.qtpl:38 } else { -//line views/admin.qtpl:70 +//line views/admin.qtpl:38 qw422016.N().S(` `) -//line views/admin.qtpl:71 +//line views/admin.qtpl:39 qw422016.E().S(u.RegisteredAt.UTC().Format("2006-01-02 15:04")) -//line views/admin.qtpl:71 +//line views/admin.qtpl:39 qw422016.N().S(` `) -//line views/admin.qtpl:72 +//line views/admin.qtpl:40 } -//line views/admin.qtpl:72 +//line views/admin.qtpl:40 qw422016.N().S(` `) -//line views/admin.qtpl:75 +//line views/admin.qtpl:43 qw422016.E().S(lc.Get("admin.users_edit")) -//line views/admin.qtpl:75 +//line views/admin.qtpl:43 qw422016.N().S(` `) -//line views/admin.qtpl:78 +//line views/admin.qtpl:46 } -//line views/admin.qtpl:78 +//line views/admin.qtpl:46 qw422016.N().S(`
`) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 } -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 func WriteAdminUsersPanel(qq422016 qtio422016.Writer, userList []*user.User, lc *l18n.Localizer) { -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 StreamAdminUsersPanel(qw422016, userList, lc) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 qt422016.ReleaseWriter(qw422016) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 } -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 func AdminUsersPanel(userList []*user.User, lc *l18n.Localizer) string { -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 qb422016 := qt422016.AcquireByteBuffer() -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 WriteAdminUsersPanel(qb422016, userList, lc) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 qs422016 := string(qb422016.B) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 qt422016.ReleaseByteBuffer(qb422016) -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 return qs422016 -//line views/admin.qtpl:83 +//line views/admin.qtpl:51 } -//line views/admin.qtpl:85 +//line views/admin.qtpl:53 func StreamAdminUserNew(qw422016 *qt422016.Writer, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:85 +//line views/admin.qtpl:53 qw422016.N().S(`

`) -//line views/admin.qtpl:88 +//line views/admin.qtpl:56 qw422016.E().S(lc.Get("admin.newuser_title")) -//line views/admin.qtpl:88 +//line views/admin.qtpl:56 qw422016.N().S(`

`) -//line views/admin.qtpl:90 +//line views/admin.qtpl:58 if f.HasError() { -//line views/admin.qtpl:90 +//line views/admin.qtpl:58 qw422016.N().S(`
`) -//line views/admin.qtpl:92 +//line views/admin.qtpl:60 qw422016.E().S(lc.Get("ui.error")) -//line views/admin.qtpl:92 +//line views/admin.qtpl:60 qw422016.N().S(`: `) -//line views/admin.qtpl:93 +//line views/admin.qtpl:61 qw422016.E().S(f.Error()) -//line views/admin.qtpl:93 +//line views/admin.qtpl:61 qw422016.N().S(`
`) -//line views/admin.qtpl:95 +//line views/admin.qtpl:63 } -//line views/admin.qtpl:95 +//line views/admin.qtpl:63 qw422016.N().S(`
@@ -408,14 +309,14 @@ func StreamAdminUserNew(qw422016 *qt422016.Writer, f util.FormData, lc *l18n.Loc
`) -//line views/admin.qtpl:122 +//line views/admin.qtpl:90 qw422016.E().S(lc.Get("ui.cancel")) -//line views/admin.qtpl:122 +//line views/admin.qtpl:90 qw422016.N().S(`
@@ -423,279 +324,279 @@ func StreamAdminUserNew(qw422016 *qt422016.Writer, f util.FormData, lc *l18n.Loc
`) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 } -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 func WriteAdminUserNew(qq422016 qtio422016.Writer, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 StreamAdminUserNew(qw422016, f, lc) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 qt422016.ReleaseWriter(qw422016) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 } -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 func AdminUserNew(f util.FormData, lc *l18n.Localizer) string { -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 qb422016 := qt422016.AcquireByteBuffer() -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 WriteAdminUserNew(qb422016, f, lc) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 qs422016 := string(qb422016.B) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 qt422016.ReleaseByteBuffer(qb422016) -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 return qs422016 -//line views/admin.qtpl:128 +//line views/admin.qtpl:96 } -//line views/admin.qtpl:130 +//line views/admin.qtpl:98 func StreamAdminUserEdit(qw422016 *qt422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:130 +//line views/admin.qtpl:98 qw422016.N().S(`

`) -//line views/admin.qtpl:135 +//line views/admin.qtpl:103 qw422016.E().S(u.Name) -//line views/admin.qtpl:135 +//line views/admin.qtpl:103 qw422016.N().S(`

`) -//line views/admin.qtpl:138 +//line views/admin.qtpl:106 qw422016.E().S(lc.Get("admin.user_group_heading")) -//line views/admin.qtpl:138 +//line views/admin.qtpl:106 qw422016.N().S(`

`) -//line views/admin.qtpl:140 +//line views/admin.qtpl:108 if f.HasError() { -//line views/admin.qtpl:140 +//line views/admin.qtpl:108 qw422016.N().S(`
`) -//line views/admin.qtpl:142 +//line views/admin.qtpl:110 qw422016.E().S(lc.Get("ui.error")) -//line views/admin.qtpl:142 +//line views/admin.qtpl:110 qw422016.N().S(`: `) -//line views/admin.qtpl:143 +//line views/admin.qtpl:111 qw422016.E().S(f.Error()) -//line views/admin.qtpl:143 +//line views/admin.qtpl:111 qw422016.N().S(`
`) -//line views/admin.qtpl:145 +//line views/admin.qtpl:113 } -//line views/admin.qtpl:145 +//line views/admin.qtpl:113 qw422016.N().S(`

`) -//line views/admin.qtpl:163 +//line views/admin.qtpl:131 qw422016.E().S(lc.Get("admin.user_delete_heading")) -//line views/admin.qtpl:163 +//line views/admin.qtpl:131 qw422016.N().S(`

`) -//line views/admin.qtpl:164 +//line views/admin.qtpl:132 qw422016.E().S(lc.Get("admin.user_delete_tip")) -//line views/admin.qtpl:164 +//line views/admin.qtpl:132 qw422016.N().S(`

`) -//line views/admin.qtpl:165 +//line views/admin.qtpl:133 qw422016.E().S(lc.Get("admin.user_delete")) -//line views/admin.qtpl:165 +//line views/admin.qtpl:133 qw422016.N().S(`
`) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 } -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 func WriteAdminUserEdit(qq422016 qtio422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 StreamAdminUserEdit(qw422016, u, f, lc) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 qt422016.ReleaseWriter(qw422016) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 } -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 func AdminUserEdit(u *user.User, f util.FormData, lc *l18n.Localizer) string { -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 qb422016 := qt422016.AcquireByteBuffer() -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 WriteAdminUserEdit(qb422016, u, f, lc) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 qs422016 := string(qb422016.B) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 qt422016.ReleaseByteBuffer(qb422016) -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 return qs422016 -//line views/admin.qtpl:168 +//line views/admin.qtpl:136 } -//line views/admin.qtpl:170 +//line views/admin.qtpl:138 func StreamAdminUserDelete(qw422016 *qt422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:170 +//line views/admin.qtpl:138 qw422016.N().S(`

`) -//line views/admin.qtpl:173 +//line views/admin.qtpl:141 qw422016.E().S(lc.Get("admin.user_delete_heading")) -//line views/admin.qtpl:173 +//line views/admin.qtpl:141 qw422016.N().S(`

`) -//line views/admin.qtpl:175 +//line views/admin.qtpl:143 if f.HasError() { -//line views/admin.qtpl:175 +//line views/admin.qtpl:143 qw422016.N().S(`
`) -//line views/admin.qtpl:177 +//line views/admin.qtpl:145 qw422016.E().S(lc.Get("ui.error")) -//line views/admin.qtpl:177 +//line views/admin.qtpl:145 qw422016.N().S(`: `) -//line views/admin.qtpl:178 +//line views/admin.qtpl:146 qw422016.E().S(f.Error()) -//line views/admin.qtpl:178 +//line views/admin.qtpl:146 qw422016.N().S(`
`) -//line views/admin.qtpl:180 +//line views/admin.qtpl:148 } -//line views/admin.qtpl:180 +//line views/admin.qtpl:148 qw422016.N().S(`

`) -//line views/admin.qtpl:182 +//line views/admin.qtpl:150 qw422016.N().S(lc.Get("admin.user_delete_warn", &l18n.Replacements{"name": fmt.Sprintf("%s", u.Name)})) -//line views/admin.qtpl:182 +//line views/admin.qtpl:150 qw422016.N().S(`

`) -//line views/admin.qtpl:186 +//line views/admin.qtpl:154 qw422016.E().S(lc.Get("ui.cancel")) -//line views/admin.qtpl:186 +//line views/admin.qtpl:154 qw422016.N().S(`
`) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 } -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 func WriteAdminUserDelete(qq422016 qtio422016.Writer, u *user.User, f util.FormData, lc *l18n.Localizer) { -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 StreamAdminUserDelete(qw422016, u, f, lc) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 qt422016.ReleaseWriter(qw422016) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 } -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 func AdminUserDelete(u *user.User, f util.FormData, lc *l18n.Localizer) string { -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 qb422016 := qt422016.AcquireByteBuffer() -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 WriteAdminUserDelete(qb422016, u, f, lc) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 qs422016 := string(qb422016.B) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 qt422016.ReleaseByteBuffer(qb422016) -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 return qs422016 -//line views/admin.qtpl:190 +//line views/admin.qtpl:158 } diff --git a/views/categories.go b/views/categories.go index ad2bd92..3207822 100644 --- a/views/categories.go +++ b/views/categories.go @@ -39,20 +39,20 @@ func init() { categoryTemplatesRu = template.Must(template.Must(categoryTemplatesEn.Clone()).Parse(categoriesRu)) } -func localizedTemplates(meta Meta) *template.Template { +func localizedCatTemplates(meta Meta) *template.Template { if meta.Lc.Locale == "ru" { return categoryTemplatesRu } return categoryTemplatesEn } -func localizedTemplateAsString(meta Meta, name string, datum ...interface{}) string { +func localizedCatTemplateAsString(meta Meta, name string, datum ...interface{}) string { var buf strings.Builder var err error if len(datum) == 1 { - err = localizedTemplates(meta).ExecuteTemplate(&buf, name, datum[0]) + err = localizedCatTemplates(meta).ExecuteTemplate(&buf, name, datum[0]) } else { - err = localizedTemplates(meta).ExecuteTemplate(&buf, name, nil) + err = localizedCatTemplates(meta).ExecuteTemplate(&buf, name, nil) } if err != nil { log.Println(err) @@ -63,7 +63,7 @@ func localizedTemplateAsString(meta Meta, name string, datum ...interface{}) str func categoryCard(meta Meta, hyphaName string) string { var buf strings.Builder - err := localizedTemplates(meta).ExecuteTemplate(&buf, "category card", struct { + err := localizedCatTemplates(meta).ExecuteTemplate(&buf, "category card", struct { HyphaName string Categories []string }{ @@ -78,7 +78,7 @@ func categoryCard(meta Meta, hyphaName string) string { func CategoryPage(meta Meta, catName string) { var buf strings.Builder - err := localizedTemplates(meta).ExecuteTemplate(&buf, "category page", struct { + err := localizedCatTemplates(meta).ExecuteTemplate(&buf, "category page", struct { CatName string Hyphae []string }{ @@ -89,7 +89,7 @@ func CategoryPage(meta Meta, catName string) { log.Println(err) } _, err = io.WriteString(meta.W, Base( - localizedTemplateAsString(meta, "category x", catName), + localizedCatTemplateAsString(meta, "category x", catName), buf.String(), meta.Lc, meta.U, @@ -101,7 +101,7 @@ func CategoryPage(meta Meta, catName string) { func CategoryList(meta Meta) { var buf strings.Builder - err := localizedTemplates(meta).ExecuteTemplate(&buf, "category list", struct { + err := localizedCatTemplates(meta).ExecuteTemplate(&buf, "category list", struct { Categories []string }{ categories.List(), @@ -110,7 +110,7 @@ func CategoryList(meta Meta) { log.Println(err) } _, err = io.WriteString(meta.W, Base( - localizedTemplateAsString(meta, "category list heading"), + localizedCatTemplateAsString(meta, "category list heading"), buf.String(), meta.Lc, meta.U, diff --git a/web/admin.go b/web/admin.go index d808514..a463f9a 100644 --- a/web/admin.go +++ b/web/admin.go @@ -33,10 +33,9 @@ func initAdmin(r *mux.Router) { // handlerAdmin provides the admin panel. func handlerAdmin(w http.ResponseWriter, rq *http.Request) { - var lc = l18n.FromRequest(rq) w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(http.StatusOK) - io.WriteString(w, views.Base(lc.Get("admin.panel_title"), views.AdminPanel(lc), lc, user.FromRequest(rq))) + views.AdminPanel(views.MetaFrom(w, rq)) } // handlerAdminShutdown kills the wiki.