mirror of
https://github.com/miniflux/v2.git
synced 2025-08-31 18:31:01 +00:00
Add Instapaper integration
This commit is contained in:
parent
6f5350a497
commit
ae62e543d3
19 changed files with 191 additions and 51 deletions
|
@ -6,9 +6,8 @@ package controller
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/miniflux/miniflux2/integration/pinboard"
|
||||
"github.com/miniflux/miniflux2/integration"
|
||||
"github.com/miniflux/miniflux2/model"
|
||||
"github.com/miniflux/miniflux2/server/core"
|
||||
"github.com/miniflux/miniflux2/server/ui/form"
|
||||
|
@ -36,6 +35,9 @@ func (c *Controller) ShowIntegrations(ctx *core.Context, request *core.Request,
|
|||
PinboardToken: integration.PinboardToken,
|
||||
PinboardTags: integration.PinboardTags,
|
||||
PinboardMarkAsUnread: integration.PinboardMarkAsUnread,
|
||||
InstapaperEnabled: integration.InstapaperEnabled,
|
||||
InstapaperUsername: integration.InstapaperUsername,
|
||||
InstapaperPassword: integration.InstapaperPassword,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
@ -85,20 +87,14 @@ func (c *Controller) SaveEntry(ctx *core.Context, request *core.Request, respons
|
|||
return
|
||||
}
|
||||
|
||||
integration, err := c.store.Integration(user.ID)
|
||||
settings, err := c.store.Integration(user.ID)
|
||||
if err != nil {
|
||||
response.JSON().ServerError(err)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
if integration.PinboardEnabled {
|
||||
client := pinboard.NewClient(integration.PinboardToken)
|
||||
err := client.AddBookmark(entry.URL, entry.Title, integration.PinboardTags, integration.PinboardMarkAsUnread)
|
||||
if err != nil {
|
||||
log.Println("[Pinboard]", err)
|
||||
}
|
||||
}
|
||||
integration.SendEntry(entry, settings)
|
||||
}()
|
||||
|
||||
response.JSON().Created(map[string]string{"message": "saved"})
|
||||
|
|
|
@ -16,6 +16,9 @@ type IntegrationForm struct {
|
|||
PinboardToken string
|
||||
PinboardTags string
|
||||
PinboardMarkAsUnread bool
|
||||
InstapaperEnabled bool
|
||||
InstapaperUsername string
|
||||
InstapaperPassword string
|
||||
}
|
||||
|
||||
// Merge copy form values to the model.
|
||||
|
@ -24,6 +27,9 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
|
|||
integration.PinboardToken = i.PinboardToken
|
||||
integration.PinboardTags = i.PinboardTags
|
||||
integration.PinboardMarkAsUnread = i.PinboardMarkAsUnread
|
||||
integration.InstapaperEnabled = i.InstapaperEnabled
|
||||
integration.InstapaperUsername = i.InstapaperUsername
|
||||
integration.InstapaperPassword = i.InstapaperPassword
|
||||
}
|
||||
|
||||
// NewIntegrationForm returns a new AuthForm.
|
||||
|
@ -33,5 +39,8 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
|||
PinboardToken: r.FormValue("pinboard_token"),
|
||||
PinboardTags: r.FormValue("pinboard_tags"),
|
||||
PinboardMarkAsUnread: r.FormValue("pinboard_mark_as_unread") == "1",
|
||||
InstapaperEnabled: r.FormValue("instapaper_enabled") == "1",
|
||||
InstapaperUsername: r.FormValue("instapaper_username"),
|
||||
InstapaperPassword: r.FormValue("instapaper_password"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue