aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nicolas Carlier <n.carlier@nunux.org>2018-02-25 19:49:08 +0000
committerGravatar fguillot <fred@miniflux.net>2018-02-25 11:49:08 -0800
commit34ce1142313b74e21a74c08c6dbd8d4312d7e336 (patch)
treee536c737e3f6d2512644a23bfead7ab5509aedaa
parent3030145b3048245405766c3a73a099af82ba9750 (diff)
Add Nunux Keeper integration
-rw-r--r--http/client.go3
-rw-r--r--integration/integration.go12
-rw-r--r--integration/nunuxkeeper/nunuxkeeper.go63
-rwxr-xr-xlocale/translations.go17
-rw-r--r--locale/translations/de_DE.json3
-rw-r--r--locale/translations/fr_FR.json3
-rwxr-xr-xlocale/translations/pl_PL.json3
-rw-r--r--model/integration.go3
-rw-r--r--sql/schema_version_14.sql3
-rw-r--r--sql/sql.go6
-rw-r--r--storage/integration.go18
-rw-r--r--storage/migration.go2
-rw-r--r--template/common.go2
-rw-r--r--template/html/integrations.html13
-rw-r--r--template/views.go17
-rw-r--r--ui/form/integration.go9
-rw-r--r--ui/integrations.go3
-rw-r--r--ui/static/bin.go2
-rw-r--r--ui/static/css.go2
-rw-r--r--ui/static/js.go2
20 files changed, 170 insertions, 16 deletions
diff --git a/http/client.go b/http/client.go
index 401d621..9bcd14e 100644
--- a/http/client.go
+++ b/http/client.go
@@ -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
}
diff --git a/integration/integration.go b/integration/integration.go
index 1468a2b..05c7794 100644
--- a/integration/integration.go
+++ b/integration/integration.go
@@ -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)
+ }
+ }
}
diff --git a/integration/nunuxkeeper/nunuxkeeper.go b/integration/nunuxkeeper/nunuxkeeper.go
new file mode 100644
index 0000000..4627e8d
--- /dev/null
+++ b/integration/nunuxkeeper/nunuxkeeper.go
@@ -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
+}
diff --git a/locale/translations.go b/locale/translations.go
index f51bce2..e7588ec 100755
--- a/locale/translations.go
+++ b/locale/translations.go
@@ -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",
}
diff --git a/locale/translations/de_DE.json b/locale/translations/de_DE.json
index f781fa0..c66f8da 100644
--- a/locale/translations/de_DE.json
+++ b/locale/translations/de_DE.json
@@ -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",
diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json
index ca2ec06..42cdb13 100644
--- a/locale/translations/fr_FR.json
+++ b/locale/translations/fr_FR.json
@@ -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",
diff --git a/locale/translations/pl_PL.json b/locale/translations/pl_PL.json
index ed77866..946005e 100755
--- a/locale/translations/pl_PL.json
+++ b/locale/translations/pl_PL.json
@@ -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ą",
diff --git a/model/integration.go b/model/integration.go
index 5ddaef2..721c701 100644
--- a/model/integration.go
+++ b/model/integration.go
@@ -24,4 +24,7 @@ type Integration struct {
WallabagClientSecret string
WallabagUsername string
WallabagPassword string
+ NunuxKeeperEnabled bool
+ NunuxKeeperURL string
+ NunuxKeeperAPIKey string
}
diff --git a/sql/schema_version_14.sql b/sql/schema_version_14.sql
new file mode 100644
index 0000000..bfd7ca2
--- /dev/null
+++ b/sql/schema_version_14.sql
@@ -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 ''; \ No newline at end of file
diff --git a/sql/sql.go b/sql/sql.go
index 979c3af..80be63f 100644
--- a/sql/sql.go
+++ b/sql/sql.go
@@ -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",
diff --git a/storage/integration.go b/storage/integration.go
index aacb520..5a60d85 100644
--- a/storage/integration.go
+++ b/storage/integration.go
@@ -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,
)
diff --git a/storage/migration.go b/storage/migration.go
index 73267ec..ed219de 100644
--- a/storage/migration.go
+++ b/storage/migration.go
@@ -12,7 +12,7 @@ import (
"github.com/miniflux/miniflux/sql"
)
-const schemaVersion = 13
+const schemaVersion = 14
// Migrate run database migrations.
func (s *Storage) Migrate() {
diff --git a/template/common.go b/template/common.go
index 61661e8..8240b2d 100644
--- a/template/common.go
+++ b/template/common.go
@@ -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
diff --git a/template/html/integrations.html b/template/html/integrations.html
index 91f5b7a..7e3d2f4 100644
--- a/template/html/integrations.html
+++ b/template/html/integrations.html
@@ -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>
diff --git a/template/views.go b/template/views.go
index 8bc6cdc..d4240a7 100644
--- a/template/views.go
+++ b/template/views.go
@@ -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",
diff --git a/ui/form/integration.go b/ui/form/integration.go
index 8cc6d35..f8cadaf 100644
--- a/ui/form/integration.go
+++ b/ui/form/integration.go
@@ -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"),
}
}
diff --git a/ui/integrations.go b/ui/integrations.go
index b301851..7459601 100644
--- a/ui/integrations.go
+++ b/ui/integrations.go
@@ -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,
},
}))
}
diff --git a/ui/static/bin.go b/ui/static/bin.go
index 11a953b..4db4b0a 100644
--- a/ui/static/bin.go
+++ b/ui/static/bin.go
@@ -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
diff --git a/ui/static/css.go b/ui/static/css.go
index 8ced226..d78cd06 100644
--- a/ui/static/css.go
+++ b/ui/static/css.go
@@ -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
diff --git a/ui/static/js.go b/ui/static/js.go
index 45fc161..aefa198 100644
--- a/ui/static/js.go
+++ b/ui/static/js.go
@@ -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