subscription_add.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "miniflux.app/config"
  8. "miniflux.app/http/client"
  9. "miniflux.app/http/request"
  10. "miniflux.app/http/response/html"
  11. "miniflux.app/ui/form"
  12. "miniflux.app/ui/session"
  13. "miniflux.app/ui/view"
  14. )
  15. func (h *handler) showAddSubscriptionPage(w http.ResponseWriter, r *http.Request) {
  16. sess := session.New(h.store, request.SessionID(r))
  17. view := view.New(h.tpl, r, sess)
  18. user, err := h.store.UserByID(request.UserID(r))
  19. if err != nil {
  20. html.ServerError(w, r, err)
  21. return
  22. }
  23. categories, err := h.store.Categories(user.ID)
  24. if err != nil {
  25. html.ServerError(w, r, err)
  26. return
  27. }
  28. view.Set("categories", categories)
  29. view.Set("menu", "feeds")
  30. view.Set("user", user)
  31. view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
  32. view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
  33. view.Set("defaultUserAgent", client.DefaultUserAgent)
  34. view.Set("form", &form.SubscriptionForm{CategoryID: 0})
  35. view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
  36. html.OK(w, r, view.Render("add_subscription"))
  37. }