4
0

subscription_add.go 1.2 KB

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