integration.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/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. }
  31. // Merge copy form values to the model.
  32. func (i IntegrationForm) Merge(integration *model.Integration) {
  33. integration.PinboardEnabled = i.PinboardEnabled
  34. integration.PinboardToken = i.PinboardToken
  35. integration.PinboardTags = i.PinboardTags
  36. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  37. integration.InstapaperEnabled = i.InstapaperEnabled
  38. integration.InstapaperUsername = i.InstapaperUsername
  39. integration.InstapaperPassword = i.InstapaperPassword
  40. integration.FeverEnabled = i.FeverEnabled
  41. integration.FeverUsername = i.FeverUsername
  42. integration.FeverPassword = i.FeverPassword
  43. integration.WallabagEnabled = i.WallabagEnabled
  44. integration.WallabagURL = i.WallabagURL
  45. integration.WallabagClientID = i.WallabagClientID
  46. integration.WallabagClientSecret = i.WallabagClientSecret
  47. integration.WallabagUsername = i.WallabagUsername
  48. integration.WallabagPassword = i.WallabagPassword
  49. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  50. integration.NunuxKeeperURL = i.NunuxKeeperURL
  51. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  52. }
  53. // NewIntegrationForm returns a new AuthForm.
  54. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  55. return &IntegrationForm{
  56. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  57. PinboardToken: r.FormValue("pinboard_token"),
  58. PinboardTags: r.FormValue("pinboard_tags"),
  59. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  60. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  61. InstapaperUsername: r.FormValue("instapaper_username"),
  62. InstapaperPassword: r.FormValue("instapaper_password"),
  63. FeverEnabled: r.FormValue("fever_enabled") == "1",
  64. FeverUsername: r.FormValue("fever_username"),
  65. FeverPassword: r.FormValue("fever_password"),
  66. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  67. WallabagURL: r.FormValue("wallabag_url"),
  68. WallabagClientID: r.FormValue("wallabag_client_id"),
  69. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  70. WallabagUsername: r.FormValue("wallabag_username"),
  71. WallabagPassword: r.FormValue("wallabag_password"),
  72. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  73. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  74. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  75. }
  76. }