integration.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 form // import "miniflux.app/ui/form"
  5. import (
  6. "net/http"
  7. "miniflux.app/model"
  8. )
  9. // IntegrationForm represents user integration settings form.
  10. type IntegrationForm struct {
  11. PinboardEnabled bool
  12. PinboardToken string
  13. PinboardTags string
  14. PinboardMarkAsUnread bool
  15. InstapaperEnabled bool
  16. InstapaperUsername string
  17. InstapaperPassword string
  18. FeverEnabled bool
  19. FeverUsername string
  20. FeverPassword string
  21. WallabagEnabled bool
  22. WallabagURL string
  23. WallabagClientID string
  24. WallabagClientSecret string
  25. WallabagUsername string
  26. WallabagPassword string
  27. NunuxKeeperEnabled bool
  28. NunuxKeeperURL string
  29. NunuxKeeperAPIKey string
  30. PocketEnabled bool
  31. PocketAccessToken string
  32. PocketConsumerKey string
  33. }
  34. // Merge copy form values to the model.
  35. func (i IntegrationForm) Merge(integration *model.Integration) {
  36. integration.PinboardEnabled = i.PinboardEnabled
  37. integration.PinboardToken = i.PinboardToken
  38. integration.PinboardTags = i.PinboardTags
  39. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  40. integration.InstapaperEnabled = i.InstapaperEnabled
  41. integration.InstapaperUsername = i.InstapaperUsername
  42. integration.InstapaperPassword = i.InstapaperPassword
  43. integration.FeverEnabled = i.FeverEnabled
  44. integration.FeverUsername = i.FeverUsername
  45. integration.WallabagEnabled = i.WallabagEnabled
  46. integration.WallabagURL = i.WallabagURL
  47. integration.WallabagClientID = i.WallabagClientID
  48. integration.WallabagClientSecret = i.WallabagClientSecret
  49. integration.WallabagUsername = i.WallabagUsername
  50. integration.WallabagPassword = i.WallabagPassword
  51. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  52. integration.NunuxKeeperURL = i.NunuxKeeperURL
  53. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  54. integration.PocketEnabled = i.PocketEnabled
  55. integration.PocketAccessToken = i.PocketAccessToken
  56. integration.PocketConsumerKey = i.PocketConsumerKey
  57. }
  58. // NewIntegrationForm returns a new AuthForm.
  59. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  60. return &IntegrationForm{
  61. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  62. PinboardToken: r.FormValue("pinboard_token"),
  63. PinboardTags: r.FormValue("pinboard_tags"),
  64. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  65. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  66. InstapaperUsername: r.FormValue("instapaper_username"),
  67. InstapaperPassword: r.FormValue("instapaper_password"),
  68. FeverEnabled: r.FormValue("fever_enabled") == "1",
  69. FeverUsername: r.FormValue("fever_username"),
  70. FeverPassword: r.FormValue("fever_password"),
  71. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  72. WallabagURL: r.FormValue("wallabag_url"),
  73. WallabagClientID: r.FormValue("wallabag_client_id"),
  74. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  75. WallabagUsername: r.FormValue("wallabag_username"),
  76. WallabagPassword: r.FormValue("wallabag_password"),
  77. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  78. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  79. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  80. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  81. PocketAccessToken: r.FormValue("pocket_access_token"),
  82. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  83. }
  84. }