category_create.go 882 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/http/context"
  8. "github.com/miniflux/miniflux/http/response/html"
  9. "github.com/miniflux/miniflux/ui/session"
  10. "github.com/miniflux/miniflux/ui/view"
  11. )
  12. // CreateCategory shows the form to create a new category.
  13. func (c *Controller) CreateCategory(w http.ResponseWriter, r *http.Request) {
  14. ctx := context.New(r)
  15. user, err := c.store.UserByID(ctx.UserID())
  16. if err != nil {
  17. html.ServerError(w, err)
  18. return
  19. }
  20. sess := session.New(c.store, ctx)
  21. view := view.New(c.tpl, ctx, sess)
  22. view.Set("menu", "categories")
  23. view.Set("user", user)
  24. view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
  25. html.OK(w, view.Render("create_category"))
  26. }