feed_list.go 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // ShowFeedsPage shows the page with all subscriptions.
  13. func (c *Controller) ShowFeedsPage(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. feeds, err := c.store.Feeds(user.ID)
  21. if err != nil {
  22. html.ServerError(w, err)
  23. return
  24. }
  25. sess := session.New(c.store, ctx)
  26. view := view.New(c.tpl, ctx, sess)
  27. view.Set("feeds", feeds)
  28. view.Set("total", len(feeds))
  29. view.Set("menu", "feeds")
  30. view.Set("user", user)
  31. view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
  32. html.OK(w, r, view.Render("feeds"))
  33. }