Add Nunux Keeper integration
This commit is contained in:
parent
3030145b30
commit
34ce114231
20 changed files with 170 additions and 16 deletions
|
@ -149,11 +149,12 @@ func (c *Client) buildRequest(method string, body io.Reader) (*http.Request, err
|
|||
return nil, err
|
||||
}
|
||||
|
||||
request.Header = c.buildHeaders()
|
||||
|
||||
if c.username != "" && c.password != "" {
|
||||
request.SetBasicAuth(c.username, c.password)
|
||||
}
|
||||
|
||||
request.Header = c.buildHeaders()
|
||||
return request, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ package integration
|
|||
|
||||
import (
|
||||
"github.com/miniflux/miniflux/integration/instapaper"
|
||||
"github.com/miniflux/miniflux/integration/nunuxkeeper"
|
||||
"github.com/miniflux/miniflux/integration/pinboard"
|
||||
"github.com/miniflux/miniflux/integration/wallabag"
|
||||
"github.com/miniflux/miniflux/logger"
|
||||
|
@ -48,4 +49,15 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
|
|||
logger.Error("[Integration] %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if integration.NunuxKeeperEnabled {
|
||||
client := nunuxkeeper.NewClient(
|
||||
integration.NunuxKeeperURL,
|
||||
integration.NunuxKeeperAPIKey,
|
||||
)
|
||||
|
||||
if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
|
||||
logger.Error("[Integration] %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
63
integration/nunuxkeeper/nunuxkeeper.go
Normal file
63
integration/nunuxkeeper/nunuxkeeper.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
// 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.
|
||||
|
||||
package nunuxkeeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"github.com/miniflux/miniflux/http"
|
||||
)
|
||||
|
||||
// Document structure of a Nununx Keeper document
|
||||
type Document struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Origin string `json:"origin,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
ContentType string `json:"contentType,omitempty"`
|
||||
}
|
||||
|
||||
// Client represents an Nunux Keeper client.
|
||||
type Client struct {
|
||||
baseURL string
|
||||
apiKey string
|
||||
}
|
||||
|
||||
// AddEntry sends an entry to Nunux Keeper.
|
||||
func (c *Client) AddEntry(link, title, content string) error {
|
||||
doc := &Document{
|
||||
Title: title,
|
||||
Origin: link,
|
||||
Content: content,
|
||||
ContentType: "text/html",
|
||||
}
|
||||
|
||||
apiURL, err := getAPIEndpoint(c.baseURL, "/v2/documents")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := http.NewClientWithCredentials(apiURL, "api", c.apiKey)
|
||||
response, err := client.PostJSON(doc)
|
||||
if response.HasServerFailure() {
|
||||
return fmt.Errorf("nunux-keeper: unable to send entry, status=%d", response.StatusCode)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// NewClient returns a new Nunux Keeepr client.
|
||||
func NewClient(baseURL, apiKey string) *Client {
|
||||
return &Client{baseURL: baseURL, apiKey: apiKey}
|
||||
}
|
||||
|
||||
func getAPIEndpoint(baseURL, pathURL string) (string, error) {
|
||||
u, err := url.Parse(baseURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("nunux-keeper: invalid API endpoint: %v", err)
|
||||
}
|
||||
u.Path = path.Join(u.Path, pathURL)
|
||||
return u.String(), nil
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-02-19 22:49:00.3105786 +0100 STD m=+0.012978001
|
||||
// 2018-02-24 17:47:34.999155139 +0000 GMT
|
||||
|
||||
package locale
|
||||
|
||||
|
@ -168,6 +168,9 @@ var translations = map[string]string{
|
|||
"Wallabag Client Secret": "Wallabag Client-Secret",
|
||||
"Wallabag Username": "Wallabag Benutzername",
|
||||
"Wallabag Password": "Wallabag Passwort",
|
||||
"Save articles to Nunux Keeper": "Artikel in Nunux Keeper speichern",
|
||||
"Nunux Keeper API Endpoint": "Nunux Keeper API-Endpunkt",
|
||||
"Nunux Keeper API key": "Nunux Keeper API-Schlüssel",
|
||||
"Keyboard Shortcut: %s": "Tastenkürzel: %s",
|
||||
"Favorites": "Lesezeichen",
|
||||
"Star": "Lesezeichen hinzufügen",
|
||||
|
@ -397,6 +400,9 @@ var translations = map[string]string{
|
|||
"Wallabag Client Secret": "Clé secrète du client Wallabag",
|
||||
"Wallabag Username": "Nom d'utilisateur de Wallabag",
|
||||
"Wallabag Password": "Mot de passe de Wallabag",
|
||||
"Save articles to Nunux Keeper": "Sauvegarder les articles vers Nunux Keeper",
|
||||
"Nunux Keeper API Endpoint": "URL de l'API de Nunux Keeper",
|
||||
"Nunux Keeper API key": "Clé d'API de Nunux Keeper",
|
||||
"Keyboard Shortcut: %s": "Raccourci clavier : %s",
|
||||
"Favorites": "Favoris",
|
||||
"Star": "Favoris",
|
||||
|
@ -618,6 +624,9 @@ var translations = map[string]string{
|
|||
"Wallabag Client Secret": "Wallabag Client Secret",
|
||||
"Wallabag Username": "Login do Wallabag",
|
||||
"Wallabag Password": "Hasło do Wallabag",
|
||||
"Save articles to Nunux Keeper": "Zapisz artykuly do Nunux Keeper",
|
||||
"Nunux Keeper API Endpoint": "Nunux Keeper URL",
|
||||
"Nunux Keeper API key": "Nunux Keeper API key",
|
||||
"Keyboard Shortcut: %s": "Skróty klawiszowe: %s",
|
||||
"Favorites": "Ulubione",
|
||||
"Star": "Oznacz gwiazdką",
|
||||
|
@ -676,8 +685,8 @@ var translations = map[string]string{
|
|||
}
|
||||
|
||||
var translationsChecksums = map[string]string{
|
||||
"de_DE": "53f7637318ac418ce0e3dd483923dab39ff4f4062b4909e5e03efcc3b693e5d6",
|
||||
"de_DE": "713e2d53a38253b3a4c541988aa1a917c1290ca208c7a68a131cf09eedb56319",
|
||||
"en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897",
|
||||
"fr_FR": "ae61f82ac14bc2c6c6a3c2d38cf1ad8309ac2eef19b0726b2969ac155ccddc14",
|
||||
"pl_PL": "9c10899ec62f97ebb6d5d4d88cde8c68ac584e514ce840b51ba3aeff9ea3efe3",
|
||||
"fr_FR": "d5ff2467a4a6d0bfffd7824eaaf00318d08d6ad69972497750e57617e327aa84",
|
||||
"pl_PL": "79d0d3a162c81dbb924ebdd794a52e417ce37617ea6b686a7cec1251a18581e9",
|
||||
}
|
||||
|
|
|
@ -162,6 +162,9 @@
|
|||
"Wallabag Client Secret": "Wallabag Client-Secret",
|
||||
"Wallabag Username": "Wallabag Benutzername",
|
||||
"Wallabag Password": "Wallabag Passwort",
|
||||
"Save articles to Nunux Keeper": "Artikel in Nunux Keeper speichern",
|
||||
"Nunux Keeper API Endpoint": "Nunux Keeper API-Endpunkt",
|
||||
"Nunux Keeper API key": "Nunux Keeper API-Schlüssel",
|
||||
"Keyboard Shortcut: %s": "Tastenkürzel: %s",
|
||||
"Favorites": "Lesezeichen",
|
||||
"Star": "Lesezeichen hinzufügen",
|
||||
|
|
|
@ -162,6 +162,9 @@
|
|||
"Wallabag Client Secret": "Clé secrète du client Wallabag",
|
||||
"Wallabag Username": "Nom d'utilisateur de Wallabag",
|
||||
"Wallabag Password": "Mot de passe de Wallabag",
|
||||
"Save articles to Nunux Keeper": "Sauvegarder les articles vers Nunux Keeper",
|
||||
"Nunux Keeper API Endpoint": "URL de l'API de Nunux Keeper",
|
||||
"Nunux Keeper API key": "Clé d'API de Nunux Keeper",
|
||||
"Keyboard Shortcut: %s": "Raccourci clavier : %s",
|
||||
"Favorites": "Favoris",
|
||||
"Star": "Favoris",
|
||||
|
|
|
@ -164,6 +164,9 @@
|
|||
"Wallabag Client Secret": "Wallabag Client Secret",
|
||||
"Wallabag Username": "Login do Wallabag",
|
||||
"Wallabag Password": "Hasło do Wallabag",
|
||||
"Save articles to Nunux Keeper": "Zapisz artykuly do Nunux Keeper",
|
||||
"Nunux Keeper API Endpoint": "Nunux Keeper URL",
|
||||
"Nunux Keeper API key": "Nunux Keeper API key",
|
||||
"Keyboard Shortcut: %s": "Skróty klawiszowe: %s",
|
||||
"Favorites": "Ulubione",
|
||||
"Star": "Oznacz gwiazdką",
|
||||
|
|
|
@ -24,4 +24,7 @@ type Integration struct {
|
|||
WallabagClientSecret string
|
||||
WallabagUsername string
|
||||
WallabagPassword string
|
||||
NunuxKeeperEnabled bool
|
||||
NunuxKeeperURL string
|
||||
NunuxKeeperAPIKey string
|
||||
}
|
||||
|
|
3
sql/schema_version_14.sql
Normal file
3
sql/schema_version_14.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
alter table integrations add column nunux_keeper_enabled bool default 'f';
|
||||
alter table integrations add column nunux_keeper_url text default '';
|
||||
alter table integrations add column nunux_keeper_api_key text default '';
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-02-10 22:26:57.088648586 -0800 PST m=+0.004853992
|
||||
// 2018-02-24 17:47:34.98646993 +0000 GMT
|
||||
|
||||
package sql
|
||||
|
||||
|
@ -126,6 +126,9 @@ alter table integrations add column wallabag_password text default '';`,
|
|||
"schema_version_13": `create index entries_user_status_idx on entries(user_id, status);
|
||||
create index feeds_user_category_idx on feeds(user_id, category_id);
|
||||
`,
|
||||
"schema_version_14": `alter table integrations add column nunux_keeper_enabled bool default 'f';
|
||||
alter table integrations add column nunux_keeper_url text default '';
|
||||
alter table integrations add column nunux_keeper_api_key text default '';`,
|
||||
"schema_version_2": `create extension if not exists hstore;
|
||||
alter table users add column extra hstore;
|
||||
create index users_extra_idx on users using gin(extra);
|
||||
|
@ -170,6 +173,7 @@ var SqlMapChecksums = map[string]string{
|
|||
"schema_version_11": "dc5bbc302e01e425b49c48ddcd8e29e3ab2bb8e73a6cd1858a6ba9fbec0b5243",
|
||||
"schema_version_12": "a95abab6cdf64811fc744abd37457e2928939d999c5ef00d2bdd9398e16f32fb",
|
||||
"schema_version_13": "9073fae1e796936f4a43a8120ebdb4218442fe7d346ace6387556a357c2d7edf",
|
||||
"schema_version_14": "4622e42c4a5a88b6fe1e61f3d367b295968f7260ab5b96481760775ba9f9e1fe",
|
||||
"schema_version_2": "e8e9ff32478df04fcddad10a34cba2e8bb1e67e7977b5bd6cdc4c31ec94282b4",
|
||||
"schema_version_3": "a54745dbc1c51c000f74d4e5068f1e2f43e83309f023415b1749a47d5c1e0f12",
|
||||
"schema_version_4": "216ea3a7d3e1704e40c797b5dc47456517c27dbb6ca98bf88812f4f63d74b5d9",
|
||||
|
|
|
@ -67,7 +67,10 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
|||
wallabag_client_id,
|
||||
wallabag_client_secret,
|
||||
wallabag_username,
|
||||
wallabag_password
|
||||
wallabag_password,
|
||||
nunux_keeper_enabled,
|
||||
nunux_keeper_url,
|
||||
nunux_keeper_api_key
|
||||
FROM integrations
|
||||
WHERE user_id=$1
|
||||
`
|
||||
|
@ -91,6 +94,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
|||
&integration.WallabagClientSecret,
|
||||
&integration.WallabagUsername,
|
||||
&integration.WallabagPassword,
|
||||
&integration.NunuxKeeperEnabled,
|
||||
&integration.NunuxKeeperURL,
|
||||
&integration.NunuxKeeperAPIKey,
|
||||
)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
|
@ -122,8 +128,11 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
wallabag_client_id=$14,
|
||||
wallabag_client_secret=$15,
|
||||
wallabag_username=$16,
|
||||
wallabag_password=$17
|
||||
WHERE user_id=$18
|
||||
wallabag_password=$17,
|
||||
nunux_keeper_enabled=$18,
|
||||
nunux_keeper_url=$19,
|
||||
nunux_keeper_api_key=$20
|
||||
WHERE user_id=$21
|
||||
`
|
||||
_, err := s.db.Exec(
|
||||
query,
|
||||
|
@ -144,6 +153,9 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
integration.WallabagClientSecret,
|
||||
integration.WallabagUsername,
|
||||
integration.WallabagPassword,
|
||||
integration.NunuxKeeperEnabled,
|
||||
integration.NunuxKeeperURL,
|
||||
integration.NunuxKeeperAPIKey,
|
||||
integration.UserID,
|
||||
)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/miniflux/miniflux/sql"
|
||||
)
|
||||
|
||||
const schemaVersion = 13
|
||||
const schemaVersion = 14
|
||||
|
||||
// Migrate run database migrations.
|
||||
func (s *Storage) Migrate() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-02-04 14:28:15.225458631 -0800 PST m=+0.036040293
|
||||
// 2018-02-24 17:47:34.998457627 +0000 GMT
|
||||
|
||||
package template
|
||||
|
||||
|
|
|
@ -94,6 +94,19 @@
|
|||
<label for="form-wallabag-password">{{ t "Wallabag Password" }}</label>
|
||||
<input type="password" name="wallabag_password" id="form-wallabag-password" value="{{ .form.WallabagPassword }}">
|
||||
</div>
|
||||
|
||||
<h3>Nunux Keeper</h3>
|
||||
<div class="form-section">
|
||||
<label>
|
||||
<input type="checkbox" name="nunux_keeper_enabled" value="1" {{ if .form.NunuxKeeperEnabled }}checked{{ end }}> {{ t "Save articles to Nunux Keeper" }}
|
||||
</label>
|
||||
|
||||
<label for="form-nunux-keeper-url">{{ t "Nunux Keeper API Endpoint" }}</label>
|
||||
<input type="url" name="nunux_keeper_url" id="form-nunux-keeper-url" value="{{ .form.NunuxKeeperURL }}" placeholder="https://api.nunux.org/keeper">
|
||||
|
||||
<label for="form-nunux-keeper-api-key">{{ t "Nunux Keeper API key" }}</label>
|
||||
<input type="text" name="nunux_keeper_api_key" id="form-nunux-keeper-api-key" value="{{ .form.NunuxKeeperAPIKey }}">
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<button type="submit" class="button button-primary" data-label-loading="{{ t "Loading..." }}">{{ t "Update" }}</button>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-02-23 19:56:29.533376428 -0800 PST m=+0.007159374
|
||||
// 2018-02-24 17:47:34.996504904 +0000 GMT
|
||||
|
||||
package template
|
||||
|
||||
|
@ -869,6 +869,19 @@ var templateViewsMap = map[string]string{
|
|||
<label for="form-wallabag-password">{{ t "Wallabag Password" }}</label>
|
||||
<input type="password" name="wallabag_password" id="form-wallabag-password" value="{{ .form.WallabagPassword }}">
|
||||
</div>
|
||||
|
||||
<h3>Nunux Keeper</h3>
|
||||
<div class="form-section">
|
||||
<label>
|
||||
<input type="checkbox" name="nunux_keeper_enabled" value="1" {{ if .form.NunuxKeeperEnabled }}checked{{ end }}> {{ t "Save articles to Nunux Keeper" }}
|
||||
</label>
|
||||
|
||||
<label for="form-nunux-keeper-url">{{ t "Nunux Keeper API Endpoint" }}</label>
|
||||
<input type="url" name="nunux_keeper_url" id="form-nunux-keeper-url" value="{{ .form.NunuxKeeperURL }}" placeholder="https://api.nunux.org/keeper">
|
||||
|
||||
<label for="form-nunux-keeper-api-key">{{ t "Nunux Keeper API key" }}</label>
|
||||
<input type="text" name="nunux_keeper_api_key" id="form-nunux-keeper-api-key" value="{{ .form.NunuxKeeperAPIKey }}">
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<button type="submit" class="button button-primary" data-label-loading="{{ t "Loading..." }}">{{ t "Update" }}</button>
|
||||
|
@ -1225,7 +1238,7 @@ var templateViewsMapChecksums = map[string]string{
|
|||
"feeds": "2a5abe37968ea34a0576dbef52341645cb1fc9562e351382fbf721491da6f4fa",
|
||||
"history": "967bc95236269ab3a77455910aca1939f43f93171fe1af77eb3b1b4eac579e55",
|
||||
"import": "73b5112e20bfd232bf73334544186ea419505936bc237d481517a8622901878f",
|
||||
"integrations": "958b73d632a3e2a79368bb1582efb8aabc438cef4fa6e8dc1aa4932494916aca",
|
||||
"integrations": "979193f39c2a3b43cec192aa119713cc9cbe2d5fdaedf8d2b3573c752823446c",
|
||||
"login": "7d83c3067c02f1f6aafdd8816c7f97a4eb5a5a4bdaaaa4cc1e2fbb9c17ea65e8",
|
||||
"sessions": "3fa79031dd883847eba92fbafe5f535fa3a4e1614bb610f20588b6f8fc8b3624",
|
||||
"settings": "ea2505b9d0a6d6bb594dba87a92079de19baa6d494f0651693a7685489fb7de9",
|
||||
|
|
|
@ -28,6 +28,9 @@ type IntegrationForm struct {
|
|||
WallabagClientSecret string
|
||||
WallabagUsername string
|
||||
WallabagPassword string
|
||||
NunuxKeeperEnabled bool
|
||||
NunuxKeeperURL string
|
||||
NunuxKeeperAPIKey string
|
||||
}
|
||||
|
||||
// Merge copy form values to the model.
|
||||
|
@ -48,6 +51,9 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
|
|||
integration.WallabagClientSecret = i.WallabagClientSecret
|
||||
integration.WallabagUsername = i.WallabagUsername
|
||||
integration.WallabagPassword = i.WallabagPassword
|
||||
integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
|
||||
integration.NunuxKeeperURL = i.NunuxKeeperURL
|
||||
integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
|
||||
}
|
||||
|
||||
// NewIntegrationForm returns a new AuthForm.
|
||||
|
@ -69,5 +75,8 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
|||
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
|
||||
WallabagUsername: r.FormValue("wallabag_username"),
|
||||
WallabagPassword: r.FormValue("wallabag_password"),
|
||||
NunuxKeeperEnabled: r.FormValue("nunux_keeper_enabled") == "1",
|
||||
NunuxKeeperURL: r.FormValue("nunux_keeper_url"),
|
||||
NunuxKeeperAPIKey: r.FormValue("nunux_keeper_api_key"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ func (c *Controller) ShowIntegrations(ctx *handler.Context, request *handler.Req
|
|||
WallabagClientSecret: integration.WallabagClientSecret,
|
||||
WallabagUsername: integration.WallabagUsername,
|
||||
WallabagPassword: integration.WallabagPassword,
|
||||
NunuxKeeperEnabled: integration.NunuxKeeperEnabled,
|
||||
NunuxKeeperURL: integration.NunuxKeeperURL,
|
||||
NunuxKeeperAPIKey: integration.NunuxKeeperAPIKey,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-02 21:59:10.082800492 -0800 PST m=+0.010175821
|
||||
// 2018-02-24 17:47:34.994475549 +0000 GMT
|
||||
|
||||
package static
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-02-10 22:33:47.060422476 -0800 PST m=+0.024328540
|
||||
// 2018-02-24 17:47:34.995215527 +0000 GMT
|
||||
|
||||
package static
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-29 20:38:56.472493026 -0800 PST m=+0.027898185
|
||||
// 2018-02-24 17:47:34.995856638 +0000 GMT
|
||||
|
||||
package static
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue