integration.go 2.7 KB

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