1
0
Fork 0
miniflux/ui/form/integration.go

91 lines
3.5 KiB
Go
Raw Normal View History

2017-12-02 22:32:14 -05:00
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
2018-08-25 00:51:50 -04:00
package form // import "miniflux.app/ui/form"
2017-12-02 22:32:14 -05:00
import (
"net/http"
2018-08-25 00:51:50 -04:00
"miniflux.app/model"
2017-12-02 22:32:14 -05:00
)
// IntegrationForm represents user integration settings form.
type IntegrationForm struct {
PinboardEnabled bool
PinboardToken string
PinboardTags string
PinboardMarkAsUnread bool
2017-12-03 00:12:03 -05:00
InstapaperEnabled bool
InstapaperUsername string
InstapaperPassword string
2017-12-03 20:44:27 -05:00
FeverEnabled bool
FeverUsername string
FeverPassword string
2017-12-18 23:52:46 -05:00
WallabagEnabled bool
WallabagURL string
WallabagClientID string
WallabagClientSecret string
WallabagUsername string
WallabagPassword string
2018-02-25 14:49:08 -05:00
NunuxKeeperEnabled bool
NunuxKeeperURL string
NunuxKeeperAPIKey string
2018-05-20 16:31:56 -04:00
PocketEnabled bool
PocketAccessToken string
PocketConsumerKey string
2017-12-02 22:32:14 -05:00
}
// Merge copy form values to the model.
func (i IntegrationForm) Merge(integration *model.Integration) {
integration.PinboardEnabled = i.PinboardEnabled
integration.PinboardToken = i.PinboardToken
integration.PinboardTags = i.PinboardTags
integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
2017-12-03 00:12:03 -05:00
integration.InstapaperEnabled = i.InstapaperEnabled
integration.InstapaperUsername = i.InstapaperUsername
integration.InstapaperPassword = i.InstapaperPassword
2017-12-03 20:44:27 -05:00
integration.FeverEnabled = i.FeverEnabled
integration.FeverUsername = i.FeverUsername
2017-12-18 23:52:46 -05:00
integration.WallabagEnabled = i.WallabagEnabled
integration.WallabagURL = i.WallabagURL
integration.WallabagClientID = i.WallabagClientID
integration.WallabagClientSecret = i.WallabagClientSecret
integration.WallabagUsername = i.WallabagUsername
integration.WallabagPassword = i.WallabagPassword
2018-02-25 14:49:08 -05:00
integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
integration.NunuxKeeperURL = i.NunuxKeeperURL
integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
2018-05-20 16:31:56 -04:00
integration.PocketEnabled = i.PocketEnabled
integration.PocketAccessToken = i.PocketAccessToken
integration.PocketConsumerKey = i.PocketConsumerKey
2017-12-02 22:32:14 -05:00
}
// NewIntegrationForm returns a new AuthForm.
func NewIntegrationForm(r *http.Request) *IntegrationForm {
return &IntegrationForm{
PinboardEnabled: r.FormValue("pinboard_enabled") == "1",
PinboardToken: r.FormValue("pinboard_token"),
PinboardTags: r.FormValue("pinboard_tags"),
PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
2017-12-03 00:12:03 -05:00
InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
InstapaperUsername: r.FormValue("instapaper_username"),
InstapaperPassword: r.FormValue("instapaper_password"),
2017-12-03 20:44:27 -05:00
FeverEnabled: r.FormValue("fever_enabled") == "1",
FeverUsername: r.FormValue("fever_username"),
FeverPassword: r.FormValue("fever_password"),
2017-12-18 23:52:46 -05:00
WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
WallabagURL: r.FormValue("wallabag_url"),
WallabagClientID: r.FormValue("wallabag_client_id"),
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
WallabagUsername: r.FormValue("wallabag_username"),
WallabagPassword: r.FormValue("wallabag_password"),
2018-02-25 14:49:08 -05:00
NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
2018-05-20 16:31:56 -04:00
PocketEnabled: r.FormValue("pocket_enabled") == "1",
PocketAccessToken: r.FormValue("pocket_access_token"),
PocketConsumerKey: r.FormValue("pocket_consumer_key"),
2017-12-02 22:32:14 -05:00
}
}