diff options
Diffstat (limited to 'internal/web/handlers_layout.go')
| -rw-r--r-- | internal/web/handlers_layout.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/web/handlers_layout.go b/internal/web/handlers_layout.go index 94bf32f..64d8ff4 100644 --- a/internal/web/handlers_layout.go +++ b/internal/web/handlers_layout.go @@ -121,6 +121,11 @@ func (s *Server) handleModuleAdd(w http.ResponseWriter, r *http.Request) { m.Title = i18n.T(blogLang, "Recent posts") case "sitemap": m.Title = i18n.T(blogLang, "Pages") + case "tags": + m.Title = i18n.T(blogLang, "Tags") + m.Count = 10 + case "tagcloud": + m.Title = i18n.T(blogLang, "Tag cloud") } m, err := blogStore(r).CreateModule(r.Context(), m) if err != nil { @@ -169,7 +174,7 @@ func (s *Server) handleModuleForm(w http.ResponseWriter, r *http.Request) { } func (s *Server) moduleFormData(r *http.Request, m *store.Module, errMsg string) map[string]any { - d := map[string]any{"module": m, "name": s.tr(r, moduleNames[m.Kind]), "area": s.tr(r, areaNames[m.Area]), "counts": []int{3, 5, 8, 10, 15, 20}} + d := map[string]any{"module": m, "name": s.tr(r, moduleNames[m.Kind]), "area": s.tr(r, areaNames[m.Area]), "counts": []int{3, 5, 8, 10, 15, 20}, "tagCounts": []int{5, 10, 20, 30, 50}} if errMsg != "" { d["error"] = errMsg } @@ -184,7 +189,11 @@ func (s *Server) handleModuleSave(w http.ResponseWriter, r *http.Request) { m.Title = strings.TrimSpace(r.FormValue("title")) m.Body = strings.ReplaceAll(r.FormValue("body"), "\r\n", "\n") if n, err := strconv.Atoi(r.FormValue("count")); err == nil { - m.Count = clampInt(n, 1, maxRecentCount) + if m.Kind == "tags" { // 0 = all of them + m.Count = clampInt(n, 0, maxTagListCount) + } else { + m.Count = clampInt(n, 1, maxRecentCount) + } } fail := func(msg string) { s.renderStatus(w, r, http.StatusBadRequest, "dashboard/module_form.html", s.moduleFormData(r, m, msg)) |
