integration_show.go 2.3 KB

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