integration.go 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.FeverPassword = i.FeverPassword
  46. integration.WallabagEnabled = i.WallabagEnabled
  47. integration.WallabagURL = i.WallabagURL
  48. integration.WallabagClientID = i.WallabagClientID
  49. integration.WallabagClientSecret = i.WallabagClientSecret
  50. integration.WallabagUsername = i.WallabagUsername
  51. integration.WallabagPassword = i.WallabagPassword
  52. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  53. integration.NunuxKeeperURL = i.NunuxKeeperURL
  54. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  55. integration.PocketEnabled = i.PocketEnabled
  56. integration.PocketAccessToken = i.PocketAccessToken
  57. integration.PocketConsumerKey = i.PocketConsumerKey
  58. }
  59. // NewIntegrationForm returns a new AuthForm.
  60. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  61. return &IntegrationForm{
  62. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  63. PinboardToken: r.FormValue("pinboard_token"),
  64. PinboardTags: r.FormValue("pinboard_tags"),
  65. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  66. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  67. InstapaperUsername: r.FormValue("instapaper_username"),
  68. InstapaperPassword: r.FormValue("instapaper_password"),
  69. FeverEnabled: r.FormValue("fever_enabled") == "1",
  70. FeverUsername: r.FormValue("fever_username"),
  71. FeverPassword: r.FormValue("fever_password"),
  72. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  73. WallabagURL: r.FormValue("wallabag_url"),
  74. WallabagClientID: r.FormValue("wallabag_client_id"),
  75. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  76. WallabagUsername: r.FormValue("wallabag_username"),
  77. WallabagPassword: r.FormValue("wallabag_password"),
  78. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  79. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  80. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  81. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  82. PocketAccessToken: r.FormValue("pocket_access_token"),
  83. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  84. }
  85. }