integration_show.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2017 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/http/request"
  8. "miniflux.app/http/response/html"
  9. "miniflux.app/ui/form"
  10. "miniflux.app/ui/session"
  11. "miniflux.app/ui/view"
  12. )
  13. // ShowIntegrations renders the page with all external integrations.
  14. func (c *Controller) ShowIntegrations(w http.ResponseWriter, r *http.Request) {
  15. user, err := c.store.UserByID(request.UserID(r))
  16. if err != nil {
  17. html.ServerError(w, err)
  18. return
  19. }
  20. integration, err := c.store.Integration(user.ID)
  21. if err != nil {
  22. html.ServerError(w, err)
  23. return
  24. }
  25. integrationForm := form.IntegrationForm{
  26. PinboardEnabled: integration.PinboardEnabled,
  27. PinboardToken: integration.PinboardToken,
  28. PinboardTags: integration.PinboardTags,
  29. PinboardMarkAsUnread: integration.PinboardMarkAsUnread,
  30. InstapaperEnabled: integration.InstapaperEnabled,
  31. InstapaperUsername: integration.InstapaperUsername,
  32. InstapaperPassword: integration.InstapaperPassword,
  33. FeverEnabled: integration.FeverEnabled,
  34. FeverUsername: integration.FeverUsername,
  35. FeverPassword: integration.FeverPassword,
  36. WallabagEnabled: integration.WallabagEnabled,
  37. WallabagURL: integration.WallabagURL,
  38. WallabagClientID: integration.WallabagClientID,
  39. WallabagClientSecret: integration.WallabagClientSecret,
  40. WallabagUsername: integration.WallabagUsername,
  41. WallabagPassword: integration.WallabagPassword,
  42. NunuxKeeperEnabled: integration.NunuxKeeperEnabled,
  43. NunuxKeeperURL: integration.NunuxKeeperURL,
  44. NunuxKeeperAPIKey: integration.NunuxKeeperAPIKey,
  45. PocketEnabled: integration.PocketEnabled,
  46. PocketAccessToken: integration.PocketAccessToken,
  47. PocketConsumerKey: integration.PocketConsumerKey,
  48. }
  49. sess := session.New(c.store, request.SessionID(r))
  50. view := view.New(c.tpl, r, sess)
  51. view.Set("form", integrationForm)
  52. view.Set("menu", "settings")
  53. view.Set("user", user)
  54. view.Set("countUnread", c.store.CountUnreadEntries(user.ID))
  55. view.Set("countErrorFeeds", c.store.CountErrorFeeds(user.ID))
  56. view.Set("hasPocketConsumerKeyConfigured", c.cfg.PocketConsumerKey("") != "")
  57. html.OK(w, r, view.Render("integrations"))
  58. }