integration.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. GoogleReaderEnabled bool
  22. GoogleReaderUsername string
  23. GoogleReaderPassword string
  24. WallabagEnabled bool
  25. WallabagURL string
  26. WallabagClientID string
  27. WallabagClientSecret string
  28. WallabagUsername string
  29. WallabagPassword string
  30. NunuxKeeperEnabled bool
  31. NunuxKeeperURL string
  32. NunuxKeeperAPIKey string
  33. EspialEnabled bool
  34. EspialURL string
  35. EspialAPIKey string
  36. EspialTags string
  37. PocketEnabled bool
  38. PocketAccessToken string
  39. PocketConsumerKey string
  40. TelegramBotEnabled bool
  41. TelegramBotToken string
  42. TelegramBotChatID string
  43. LinkdingEnabled bool
  44. LinkdingURL string
  45. LinkdingAPIKey string
  46. }
  47. // Merge copy form values to the model.
  48. func (i IntegrationForm) Merge(integration *model.Integration) {
  49. integration.PinboardEnabled = i.PinboardEnabled
  50. integration.PinboardToken = i.PinboardToken
  51. integration.PinboardTags = i.PinboardTags
  52. integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
  53. integration.InstapaperEnabled = i.InstapaperEnabled
  54. integration.InstapaperUsername = i.InstapaperUsername
  55. integration.InstapaperPassword = i.InstapaperPassword
  56. integration.FeverEnabled = i.FeverEnabled
  57. integration.FeverUsername = i.FeverUsername
  58. integration.GoogleReaderEnabled = i.GoogleReaderEnabled
  59. integration.GoogleReaderUsername = i.GoogleReaderUsername
  60. integration.WallabagEnabled = i.WallabagEnabled
  61. integration.WallabagURL = i.WallabagURL
  62. integration.WallabagClientID = i.WallabagClientID
  63. integration.WallabagClientSecret = i.WallabagClientSecret
  64. integration.WallabagUsername = i.WallabagUsername
  65. integration.WallabagPassword = i.WallabagPassword
  66. integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
  67. integration.NunuxKeeperURL = i.NunuxKeeperURL
  68. integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
  69. integration.EspialEnabled = i.EspialEnabled
  70. integration.EspialURL = i.EspialURL
  71. integration.EspialAPIKey = i.EspialAPIKey
  72. integration.EspialTags = i.EspialTags
  73. integration.PocketEnabled = i.PocketEnabled
  74. integration.PocketAccessToken = i.PocketAccessToken
  75. integration.PocketConsumerKey = i.PocketConsumerKey
  76. integration.TelegramBotEnabled = i.TelegramBotEnabled
  77. integration.TelegramBotToken = i.TelegramBotToken
  78. integration.TelegramBotChatID = i.TelegramBotChatID
  79. integration.LinkdingEnabled = i.LinkdingEnabled
  80. integration.LinkdingURL = i.LinkdingURL
  81. integration.LinkdingAPIKey = i.LinkdingAPIKey
  82. }
  83. // NewIntegrationForm returns a new IntegrationForm.
  84. func NewIntegrationForm(r *http.Request) *IntegrationForm {
  85. return &IntegrationForm{
  86. PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
  87. PinboardToken: r.FormValue("pinboard_token"),
  88. PinboardTags: r.FormValue("pinboard_tags"),
  89. PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
  90. InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
  91. InstapaperUsername: r.FormValue("instapaper_username"),
  92. InstapaperPassword: r.FormValue("instapaper_password"),
  93. FeverEnabled: r.FormValue("fever_enabled") == "1",
  94. FeverUsername: r.FormValue("fever_username"),
  95. FeverPassword: r.FormValue("fever_password"),
  96. GoogleReaderEnabled: r.FormValue("googlereader_enabled") == "1",
  97. GoogleReaderUsername: r.FormValue("googlereader_username"),
  98. GoogleReaderPassword: r.FormValue("googlereader_password"),
  99. WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
  100. WallabagURL: r.FormValue("wallabag_url"),
  101. WallabagClientID: r.FormValue("wallabag_client_id"),
  102. WallabagClientSecret: r.FormValue("wallabag_client_secret"),
  103. WallabagUsername: r.FormValue("wallabag_username"),
  104. WallabagPassword: r.FormValue("wallabag_password"),
  105. NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
  106. NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
  107. NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
  108. EspialEnabled: r.FormValue("espial_enabled") == "1",
  109. EspialURL: r.FormValue("espial_url"),
  110. EspialAPIKey: r.FormValue("espial_api_key"),
  111. EspialTags: r.FormValue("espial_tags"),
  112. PocketEnabled: r.FormValue("pocket_enabled") == "1",
  113. PocketAccessToken: r.FormValue("pocket_access_token"),
  114. PocketConsumerKey: r.FormValue("pocket_consumer_key"),
  115. TelegramBotEnabled: r.FormValue("telegram_bot_enabled") == "1",
  116. TelegramBotToken: r.FormValue("telegram_bot_token"),
  117. TelegramBotChatID: r.FormValue("telegram_bot_chat_id"),
  118. LinkdingEnabled: r.FormValue("linkding_enabled") == "1",
  119. LinkdingURL: r.FormValue("linkding_url"),
  120. LinkdingAPIKey: r.FormValue("linkding_api_key"),
  121. }
  122. }