integration_show.go 2.3 KB

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