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/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) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
  15. user, err := h.store.UserByID(request.UserID(r))
  16. if err != nil {
  17. html.ServerError(w, r, err)
  18. return
  19. }
  20. integration, err := h.store.Integration(user.ID)
  21. if err != nil {
  22. html.ServerError(w, r, 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. 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.CountUserFeedsWithErrors(user.ID))
  55. view.Set("hasPocketConsumerKeyConfigured", config.Opts.PocketConsumerKey("") != "")
  56. html.OK(w, r, view.Render("integrations"))
  57. }