Add Linkwarden integration

This commit is contained in:
knrdl 2024-02-12 02:12:37 +01:00 committed by GitHub
parent ccb9eed573
commit 1d90ce9dd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 215 additions and 3 deletions

View file

@ -846,4 +846,13 @@ var migrations = []func(tx *sql.Tx) error{
_, err = tx.Exec(sql) _, err = tx.Exec(sql)
return err return err
}, },
func(tx *sql.Tx) (err error) {
sql := `
ALTER TABLE integrations ADD COLUMN linkwarden_enabled bool default 'f';
ALTER TABLE integrations ADD COLUMN linkwarden_url text default '';
ALTER TABLE integrations ADD COLUMN linkwarden_api_key text default '';
`
_, err = tx.Exec(sql)
return err
},
} }

View file

@ -12,6 +12,7 @@ import (
"miniflux.app/v2/internal/integration/instapaper" "miniflux.app/v2/internal/integration/instapaper"
"miniflux.app/v2/internal/integration/linkace" "miniflux.app/v2/internal/integration/linkace"
"miniflux.app/v2/internal/integration/linkding" "miniflux.app/v2/internal/integration/linkding"
"miniflux.app/v2/internal/integration/linkwarden"
"miniflux.app/v2/internal/integration/matrixbot" "miniflux.app/v2/internal/integration/matrixbot"
"miniflux.app/v2/internal/integration/notion" "miniflux.app/v2/internal/integration/notion"
"miniflux.app/v2/internal/integration/nunuxkeeper" "miniflux.app/v2/internal/integration/nunuxkeeper"
@ -228,6 +229,27 @@ func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
} }
} }
if userIntegrations.LinkwardenEnabled {
slog.Debug("Sending entry to linkwarden",
slog.Int64("user_id", userIntegrations.UserID),
slog.Int64("entry_id", entry.ID),
slog.String("entry_url", entry.URL),
)
client := linkwarden.NewClient(
userIntegrations.LinkwardenURL,
userIntegrations.LinkwardenAPIKey,
)
if err := client.CreateBookmark(entry.URL, entry.Title); err != nil {
slog.Error("Unable to send entry to Linkwarden",
slog.Int64("user_id", userIntegrations.UserID),
slog.Int64("entry_id", entry.ID),
slog.String("entry_url", entry.URL),
slog.Any("error", err),
)
}
}
if userIntegrations.ReadwiseEnabled { if userIntegrations.ReadwiseEnabled {
slog.Debug("Sending entry to Readwise", slog.Debug("Sending entry to Readwise",
slog.Int64("user_id", userIntegrations.UserID), slog.Int64("user_id", userIntegrations.UserID),

View file

@ -0,0 +1,80 @@
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package linkwarden // import "miniflux.app/v2/internal/integration/linkwarden"
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"
"miniflux.app/v2/internal/urllib"
"miniflux.app/v2/internal/version"
)
const defaultClientTimeout = 10 * time.Second
type Client struct {
baseURL string
apiKey string
}
func NewClient(baseURL, apiKey string) *Client {
return &Client{baseURL: baseURL, apiKey: apiKey}
}
func (c *Client) CreateBookmark(entryURL, entryTitle string) error {
if c.baseURL == "" || c.apiKey == "" {
return fmt.Errorf("linkwarden: missing base URL or API key")
}
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/v1/links")
if err != nil {
return fmt.Errorf(`linkwarden: invalid API endpoint: %v`, err)
}
requestBody, err := json.Marshal(&linkwardenBookmark{
Url: entryURL,
Name: "",
Description: "",
Tags: []string{},
Collection: map[string]interface{}{},
})
if err != nil {
return fmt.Errorf("linkwarden: unable to encode request body: %v", err)
}
request, err := http.NewRequest(http.MethodPost, apiEndpoint, bytes.NewReader(requestBody))
if err != nil {
return fmt.Errorf("linkwarden: unable to create request: %v", err)
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("User-Agent", "Miniflux/"+version.Version)
request.AddCookie(&http.Cookie{Name: "__Secure-next-auth.session-token", Value: c.apiKey})
request.AddCookie(&http.Cookie{Name: "next-auth.session-token", Value: c.apiKey})
httpClient := &http.Client{Timeout: defaultClientTimeout}
response, err := httpClient.Do(request)
if err != nil {
return fmt.Errorf("linkwarden: unable to send request: %v", err)
}
defer response.Body.Close()
if response.StatusCode >= 400 {
return fmt.Errorf("linkwarden: unable to create link: url=%s status=%d", apiEndpoint, response.StatusCode)
}
return nil
}
type linkwardenBookmark struct {
Url string `json:"url"`
Name string `json:"name"`
Description string `json:"description"`
Tags []string `json:"tags"`
Collection map[string]interface{} `json:"collection"`
}

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API-Schlüssel", "form.integration.linkding_api_key": "Linkding API-Schlüssel",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Lesezeichen als ungelesen markieren", "form.integration.linkding_bookmark": "Lesezeichen als ungelesen markieren",
"form.integration.linkwarden_activate": "Artikel in Linkwarden speichern",
"form.integration.linkwarden_endpoint": "Linkwarden API-Endpunkt",
"form.integration.linkwarden_api_key": "Linkwarden API-Schlüssel",
"form.integration.matrix_bot_activate": "Neue Artikel in Matrix übertragen", "form.integration.matrix_bot_activate": "Neue Artikel in Matrix übertragen",
"form.integration.matrix_bot_user": "Benutzername für Matrix", "form.integration.matrix_bot_user": "Benutzername für Matrix",
"form.integration.matrix_bot_password": "Passwort für Matrix-Benutzer", "form.integration.matrix_bot_password": "Passwort für Matrix-Benutzer",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Κλειδί API Linkding", "form.integration.linkding_api_key": "Κλειδί API Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Σημείωση του σελιδοδείκτη ως μη αναγνωσμένου", "form.integration.linkding_bookmark": "Σημείωση του σελιδοδείκτη ως μη αναγνωσμένου",
"form.integration.linkwarden_activate": "Αποθήκευση άρθρων στο Linkwarden",
"form.integration.linkwarden_endpoint": "Τελικό σημείο Linkwarden API",
"form.integration.linkwarden_api_key": "Κλειδί API Linkwarden",
"form.integration.matrix_bot_activate": "Μεταφορά νέων άρθρων στο Matrix", "form.integration.matrix_bot_activate": "Μεταφορά νέων άρθρων στο Matrix",
"form.integration.matrix_bot_user": "Όνομα χρήστη για το Matrix", "form.integration.matrix_bot_user": "Όνομα χρήστη για το Matrix",
"form.integration.matrix_bot_password": "Κωδικός πρόσβασης για τον χρήστη Matrix", "form.integration.matrix_bot_password": "Κωδικός πρόσβασης για τον χρήστη Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API key", "form.integration.linkding_api_key": "Linkding API key",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Mark bookmark as unread", "form.integration.linkding_bookmark": "Mark bookmark as unread",
"form.integration.linkwarden_activate": "Save entries to Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden API Endpoint",
"form.integration.linkwarden_api_key": "Linkwarden API key",
"form.integration.matrix_bot_activate": "Push new entries to Matrix", "form.integration.matrix_bot_activate": "Push new entries to Matrix",
"form.integration.matrix_bot_user": "Username for Matrix", "form.integration.matrix_bot_user": "Username for Matrix",
"form.integration.matrix_bot_password": "Password for Matrix user", "form.integration.matrix_bot_password": "Password for Matrix user",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Clave de API de Linkding", "form.integration.linkding_api_key": "Clave de API de Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Marcar marcador como no leído", "form.integration.linkding_bookmark": "Marcar marcador como no leído",
"form.integration.linkwarden_activate": "Enviar artículos a Linkwarden",
"form.integration.linkwarden_endpoint": "Acceso API de Linkwarden",
"form.integration.linkwarden_api_key": "Clave de API de Linkwarden",
"form.integration.matrix_bot_activate": "Transferir nuevos artículos a Matrix", "form.integration.matrix_bot_activate": "Transferir nuevos artículos a Matrix",
"form.integration.matrix_bot_user": "Nombre de usuario para Matrix", "form.integration.matrix_bot_user": "Nombre de usuario para Matrix",
"form.integration.matrix_bot_password": "Contraseña para el usuario de Matrix", "form.integration.matrix_bot_password": "Contraseña para el usuario de Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API-avain", "form.integration.linkding_api_key": "Linkding API-avain",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Merkitse kirjanmerkki lukemattomaksi", "form.integration.linkding_bookmark": "Merkitse kirjanmerkki lukemattomaksi",
"form.integration.linkwarden_activate": "Tallenna artikkelit Linkkiin",
"form.integration.linkwarden_endpoint": "Linkwarden API-päätepiste",
"form.integration.linkwarden_api_key": "Linkwarden API-avain",
"form.integration.matrix_bot_activate": "Siirrä uudet artikkelit Matrixiin", "form.integration.matrix_bot_activate": "Siirrä uudet artikkelit Matrixiin",
"form.integration.matrix_bot_user": "Matrixin käyttäjätunnus", "form.integration.matrix_bot_user": "Matrixin käyttäjätunnus",
"form.integration.matrix_bot_password": "Matrix-käyttäjän salasana", "form.integration.matrix_bot_password": "Matrix-käyttäjän salasana",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Clé d'API de Linkding", "form.integration.linkding_api_key": "Clé d'API de Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Marquer le lien comme non lu", "form.integration.linkding_bookmark": "Marquer le lien comme non lu",
"form.integration.linkwarden_activate": "Sauvegarder les articles vers Linkwarden",
"form.integration.linkwarden_endpoint": "URL de l'API de Linkwarden",
"form.integration.linkwarden_api_key": "Clé d'API de Linkwarden",
"form.integration.matrix_bot_activate": "Envoyer les nouveaux articles vers Matrix", "form.integration.matrix_bot_activate": "Envoyer les nouveaux articles vers Matrix",
"form.integration.matrix_bot_user": "Nom de l'utilisateur Matrix", "form.integration.matrix_bot_user": "Nom de l'utilisateur Matrix",
"form.integration.matrix_bot_password": "Mot de passe de l'utilisateur Matrix", "form.integration.matrix_bot_password": "Mot de passe de l'utilisateur Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "लिंकिंग एपीआई कुंजी", "form.integration.linkding_api_key": "लिंकिंग एपीआई कुंजी",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "बुकमार्क को अपठित के रूप में चिह्नित करें", "form.integration.linkding_bookmark": "बुकमार्क को अपठित के रूप में चिह्नित करें",
"form.integration.linkwarden_activate": "Save entries to Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden API Endpoint",
"form.integration.linkwarden_api_key": "Linkwarden API key",
"form.integration.matrix_bot_activate": "नए लेखों को मैट्रिक्स में स्थानांतरित करें", "form.integration.matrix_bot_activate": "नए लेखों को मैट्रिक्स में स्थानांतरित करें",
"form.integration.matrix_bot_user": "मैट्रिक्स के लिए उपयोगकर्ता नाम", "form.integration.matrix_bot_user": "मैट्रिक्स के लिए उपयोगकर्ता नाम",
"form.integration.matrix_bot_password": "मैट्रिक्स उपयोगकर्ता के लिए पासवर्ड", "form.integration.matrix_bot_password": "मैट्रिक्स उपयोगकर्ता के लिए पासवर्ड",

View file

@ -436,6 +436,9 @@
"form.integration.linkding_api_key": "Kunci API Linkding", "form.integration.linkding_api_key": "Kunci API Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Tandai markah sebagai belum dibaca", "form.integration.linkding_bookmark": "Tandai markah sebagai belum dibaca",
"form.integration.linkwarden_activate": "Simpan artikel ke Linkwarden",
"form.integration.linkwarden_endpoint": "Titik URL API Linkwarden",
"form.integration.linkwarden_api_key": "Kunci API Linkwarden",
"form.integration.matrix_bot_activate": "Kirim entri baru ke Matrix", "form.integration.matrix_bot_activate": "Kirim entri baru ke Matrix",
"form.integration.matrix_bot_user": "Nama Pengguna Matrix", "form.integration.matrix_bot_user": "Nama Pengguna Matrix",
"form.integration.matrix_bot_password": "Kata Sandi Matrix", "form.integration.matrix_bot_password": "Kata Sandi Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "API key dell'account Linkding", "form.integration.linkding_api_key": "API key dell'account Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Segna i preferiti come non letti", "form.integration.linkding_bookmark": "Segna i preferiti come non letti",
"form.integration.linkwarden_activate": "Salva gli articoli su Linkwarden",
"form.integration.linkwarden_endpoint": "Endpoint dell'API di Linkwarden",
"form.integration.linkwarden_api_key": "API key dell'account Linkwarden",
"form.integration.matrix_bot_activate": "Trasferimento di nuovi articoli a Matrix", "form.integration.matrix_bot_activate": "Trasferimento di nuovi articoli a Matrix",
"form.integration.matrix_bot_user": "Nome utente per Matrix", "form.integration.matrix_bot_user": "Nome utente per Matrix",
"form.integration.matrix_bot_password": "Password per l'utente Matrix", "form.integration.matrix_bot_password": "Password per l'utente Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding の API key", "form.integration.linkding_api_key": "Linkding の API key",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "ブックマークを未読にする", "form.integration.linkding_bookmark": "ブックマークを未読にする",
"form.integration.linkwarden_activate": "Linkwarden に記事を保存する",
"form.integration.linkwarden_endpoint": "Linkwarden の API Endpoint",
"form.integration.linkwarden_api_key": "Linkwarden の API key",
"form.integration.matrix_bot_activate": "新しい記事をMatrixに転送する", "form.integration.matrix_bot_activate": "新しい記事をMatrixに転送する",
"form.integration.matrix_bot_user": "Matrixのユーザー名", "form.integration.matrix_bot_user": "Matrixのユーザー名",
"form.integration.matrix_bot_password": "Matrixユーザ用パスワード", "form.integration.matrix_bot_password": "Matrixユーザ用パスワード",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API-sleutel", "form.integration.linkding_api_key": "Linkding API-sleutel",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Markeer bookmark als gelezen", "form.integration.linkding_bookmark": "Markeer bookmark als gelezen",
"form.integration.linkwarden_activate": "Opslaan naar Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden URL",
"form.integration.linkwarden_api_key": "Linkwarden API-sleutel",
"form.integration.matrix_bot_activate": "Nieuwe artikelen overbrengen naar Matrix", "form.integration.matrix_bot_activate": "Nieuwe artikelen overbrengen naar Matrix",
"form.integration.matrix_bot_user": "Gebruikersnaam voor Matrix", "form.integration.matrix_bot_user": "Gebruikersnaam voor Matrix",
"form.integration.matrix_bot_password": "Wachtwoord voor Matrix-gebruiker", "form.integration.matrix_bot_password": "Wachtwoord voor Matrix-gebruiker",

View file

@ -442,6 +442,9 @@
"form.integration.linkding_api_key": "Linkding API key", "form.integration.linkding_api_key": "Linkding API key",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Zaznacz zakładkę jako nieprzeczytaną", "form.integration.linkding_bookmark": "Zaznacz zakładkę jako nieprzeczytaną",
"form.integration.linkwarden_activate": "Zapisz artykuły do Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden URL",
"form.integration.linkwarden_api_key": "Linkwarden API key",
"form.integration.matrix_bot_activate": "Przenieś nowe artykuły do Matrix", "form.integration.matrix_bot_activate": "Przenieś nowe artykuły do Matrix",
"form.integration.matrix_bot_user": "Nazwa użytkownika dla Matrix", "form.integration.matrix_bot_user": "Nazwa użytkownika dla Matrix",
"form.integration.matrix_bot_password": "Hasło dla użytkownika Matrix", "form.integration.matrix_bot_password": "Hasło dla użytkownika Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Chave de API do Linkding", "form.integration.linkding_api_key": "Chave de API do Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Salvar marcador como não lido", "form.integration.linkding_bookmark": "Salvar marcador como não lido",
"form.integration.linkwarden_activate": "Salvar itens no Linkwarden",
"form.integration.linkwarden_endpoint": "Endpoint de API do Linkwarden",
"form.integration.linkwarden_api_key": "Chave de API do Linkwarden",
"form.integration.matrix_bot_activate": "Transferir novos artigos para o Matrix", "form.integration.matrix_bot_activate": "Transferir novos artigos para o Matrix",
"form.integration.matrix_bot_user": "Nome de utilizador para Matrix", "form.integration.matrix_bot_user": "Nome de utilizador para Matrix",
"form.integration.matrix_bot_password": "Palavra-passe para utilizador da Matrix", "form.integration.matrix_bot_password": "Palavra-passe para utilizador da Matrix",

View file

@ -442,6 +442,9 @@
"form.integration.linkding_api_key": "API-ключ Linkding", "form.integration.linkding_api_key": "API-ключ Linkding",
"form.integration.linkding_tags": "Теги Linkding", "form.integration.linkding_tags": "Теги Linkding",
"form.integration.linkding_bookmark": "Помечать закладки как непрочитанное", "form.integration.linkding_bookmark": "Помечать закладки как непрочитанное",
"form.integration.linkwarden_activate": "Сохранять статьи в Linkwarden",
"form.integration.linkwarden_endpoint": "Конечная точка Linkwarden API",
"form.integration.linkwarden_api_key": "API-ключ Linkwarden",
"form.integration.matrix_bot_activate": "Репостить новые статьи в Matrix", "form.integration.matrix_bot_activate": "Репостить новые статьи в Matrix",
"form.integration.matrix_bot_user": "Имя пользователя Matrix", "form.integration.matrix_bot_user": "Имя пользователя Matrix",
"form.integration.matrix_bot_password": "Пароль пользователя Matrix", "form.integration.matrix_bot_password": "Пароль пользователя Matrix",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API Anahtarı", "form.integration.linkding_api_key": "Linkding API Anahtarı",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Yer imini okunmadı olarak işaretle", "form.integration.linkding_bookmark": "Yer imini okunmadı olarak işaretle",
"form.integration.linkwarden_activate": "Makaleleri Linkwarden'e kaydet",
"form.integration.linkwarden_endpoint": "Linkwarden API Uç Noktası",
"form.integration.linkwarden_api_key": "Linkwarden API Anahtarı",
"form.integration.matrix_bot_activate": "Yeni makaleleri Matrix'e aktarın", "form.integration.matrix_bot_activate": "Yeni makaleleri Matrix'e aktarın",
"form.integration.matrix_bot_user": "Matrix için Kullanıcı Adı", "form.integration.matrix_bot_user": "Matrix için Kullanıcı Adı",
"form.integration.matrix_bot_password": "Matrix kullanıcısı için şifre", "form.integration.matrix_bot_password": "Matrix kullanıcısı için şifre",

View file

@ -443,6 +443,9 @@
"form.integration.linkding_api_key": "Ключ API Linkding", "form.integration.linkding_api_key": "Ключ API Linkding",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "Відмічати закладку як непрочитану", "form.integration.linkding_bookmark": "Відмічати закладку як непрочитану",
"form.integration.linkwarden_activate": "Зберігати статті до Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden API Endpoint",
"form.integration.linkwarden_api_key": "Ключ API Linkwarden",
"form.integration.matrix_bot_activate": "Перенесення нових статей в Матрицю", "form.integration.matrix_bot_activate": "Перенесення нових статей в Матрицю",
"form.integration.matrix_bot_user": "Ім'я користувача для Matrix", "form.integration.matrix_bot_user": "Ім'я користувача для Matrix",
"form.integration.matrix_bot_password": "Пароль для користувача Matrix", "form.integration.matrix_bot_password": "Пароль для користувача Matrix",

View file

@ -437,6 +437,9 @@
"form.integration.linkding_api_key": "Linkding API 密钥", "form.integration.linkding_api_key": "Linkding API 密钥",
"form.integration.linkding_tags": "Linkding 默认标签", "form.integration.linkding_tags": "Linkding 默认标签",
"form.integration.linkding_bookmark": "标记为未读", "form.integration.linkding_bookmark": "标记为未读",
"form.integration.linkwarden_activate": "保存文章到 Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden API 端点",
"form.integration.linkwarden_api_key": "Linkwarden API 密钥",
"form.integration.matrix_bot_activate": "将新文章推送到 Matrix", "form.integration.matrix_bot_activate": "将新文章推送到 Matrix",
"form.integration.matrix_bot_user": "Matrix Bot 用户名", "form.integration.matrix_bot_user": "Matrix Bot 用户名",
"form.integration.matrix_bot_password": "Matrix Bot 密码", "form.integration.matrix_bot_password": "Matrix Bot 密码",

View file

@ -439,6 +439,9 @@
"form.integration.linkding_api_key": "Linkding API 金鑰", "form.integration.linkding_api_key": "Linkding API 金鑰",
"form.integration.linkding_tags": "Linkding Tags", "form.integration.linkding_tags": "Linkding Tags",
"form.integration.linkding_bookmark": "標記為未讀", "form.integration.linkding_bookmark": "標記為未讀",
"form.integration.linkwarden_activate": "儲存文章到 Linkwarden",
"form.integration.linkwarden_endpoint": "Linkwarden API 端點",
"form.integration.linkwarden_api_key": "Linkwarden API 金鑰",
"form.integration.matrix_bot_activate": "推送文章到 Matrix", "form.integration.matrix_bot_activate": "推送文章到 Matrix",
"form.integration.matrix_bot_user": "Matrix 的用戶名", "form.integration.matrix_bot_user": "Matrix 的用戶名",
"form.integration.matrix_bot_password": "Matrix 的密碼", "form.integration.matrix_bot_password": "Matrix 的密碼",

View file

@ -59,6 +59,9 @@ type Integration struct {
LinkdingAPIKey string LinkdingAPIKey string
LinkdingTags string LinkdingTags string
LinkdingMarkAsUnread bool LinkdingMarkAsUnread bool
LinkwardenEnabled bool
LinkwardenURL string
LinkwardenAPIKey string
MatrixBotEnabled bool MatrixBotEnabled bool
MatrixBotUser string MatrixBotUser string
MatrixBotPassword string MatrixBotPassword string

View file

@ -163,6 +163,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
linkding_api_key, linkding_api_key,
linkding_tags, linkding_tags,
linkding_mark_as_unread, linkding_mark_as_unread,
linkwarden_enabled,
linkwarden_url,
linkwarden_api_key,
matrix_bot_enabled, matrix_bot_enabled,
matrix_bot_user, matrix_bot_user,
matrix_bot_password, matrix_bot_password,
@ -247,6 +250,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
&integration.LinkdingAPIKey, &integration.LinkdingAPIKey,
&integration.LinkdingTags, &integration.LinkdingTags,
&integration.LinkdingMarkAsUnread, &integration.LinkdingMarkAsUnread,
&integration.LinkwardenEnabled,
&integration.LinkwardenURL,
&integration.LinkwardenAPIKey,
&integration.MatrixBotEnabled, &integration.MatrixBotEnabled,
&integration.MatrixBotUser, &integration.MatrixBotUser,
&integration.MatrixBotPassword, &integration.MatrixBotPassword,
@ -362,9 +368,12 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
rssbridge_url=$73, rssbridge_url=$73,
omnivore_enabled=$74, omnivore_enabled=$74,
omnivore_api_key=$75, omnivore_api_key=$75,
omnivore_url=$76 omnivore_url=$76,
linkwarden_enabled=$77,
linkwarden_url=$78,
linkwarden_api_key=$79
WHERE WHERE
user_id=$77 user_id=$80
` `
_, err := s.db.Exec( _, err := s.db.Exec(
query, query,
@ -444,6 +453,9 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
integration.OmnivoreEnabled, integration.OmnivoreEnabled,
integration.OmnivoreAPIKey, integration.OmnivoreAPIKey,
integration.OmnivoreURL, integration.OmnivoreURL,
integration.LinkwardenEnabled,
integration.LinkwardenURL,
integration.LinkwardenAPIKey,
integration.UserID, integration.UserID,
) )
@ -475,6 +487,7 @@ func (s *Storage) HasSaveEntry(userID int64) (result bool) {
pocket_enabled='t' OR pocket_enabled='t' OR
linkace_enabled='t' OR linkace_enabled='t' OR
linkding_enabled='t' OR linkding_enabled='t' OR
linkwarden_enabled='t' OR
apprise_enabled='t' OR apprise_enabled='t' OR
shiori_enabled='t' OR shiori_enabled='t' OR
shaarli_enabled='t' OR shaarli_enabled='t' OR

View file

@ -177,6 +177,25 @@
</div> </div>
</details> </details>
<details {{ if .form.LinkwardenEnabled }}open{{ end }}>
<summary>Linkwarden</summary>
<div class="form-section">
<label>
<input type="checkbox" name="linkwarden_enabled" value="1" {{ if .form.LinkwardenEnabled }}checked{{ end }}> {{ t "form.integration.linkwarden_activate" }}
</label>
<label for="form-linkwarden-url">{{ t "form.integration.linkwarden_endpoint" }}</label>
<input type="url" name="linkwarden_url" id="form-linkwarden-url" value="{{ .form.LinkwardenURL }}" placeholder="https://linkwarden.app" spellcheck="false">
<label for="form-linkwarden-api-key">{{ t "form.integration.linkwarden_api_key" }}</label>
<input type="text" name="linkwarden_api_key" id="form-linkwarden-api-key" value="{{ .form.LinkwardenAPIKey }}" spellcheck="false">
<div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
</div>
</div>
</details>
<details {{ if .form.MatrixBotEnabled }}open{{ end }}> <details {{ if .form.MatrixBotEnabled }}open{{ end }}>
<summary>Matrix Bot</summary> <summary>Matrix Bot</summary>
<div class="form-section"> <div class="form-section">

View file

@ -65,6 +65,9 @@ type IntegrationForm struct {
LinkdingAPIKey string LinkdingAPIKey string
LinkdingTags string LinkdingTags string
LinkdingMarkAsUnread bool LinkdingMarkAsUnread bool
LinkwardenEnabled bool
LinkwardenURL string
LinkwardenAPIKey string
MatrixBotEnabled bool MatrixBotEnabled bool
MatrixBotUser string MatrixBotUser string
MatrixBotPassword string MatrixBotPassword string
@ -143,6 +146,9 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
integration.LinkdingAPIKey = i.LinkdingAPIKey integration.LinkdingAPIKey = i.LinkdingAPIKey
integration.LinkdingTags = i.LinkdingTags integration.LinkdingTags = i.LinkdingTags
integration.LinkdingMarkAsUnread = i.LinkdingMarkAsUnread integration.LinkdingMarkAsUnread = i.LinkdingMarkAsUnread
integration.LinkwardenEnabled = i.LinkwardenEnabled
integration.LinkwardenURL = i.LinkwardenURL
integration.LinkwardenAPIKey = i.LinkwardenAPIKey
integration.MatrixBotEnabled = i.MatrixBotEnabled integration.MatrixBotEnabled = i.MatrixBotEnabled
integration.MatrixBotUser = i.MatrixBotUser integration.MatrixBotUser = i.MatrixBotUser
integration.MatrixBotPassword = i.MatrixBotPassword integration.MatrixBotPassword = i.MatrixBotPassword
@ -223,6 +229,9 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
LinkdingAPIKey: r.FormValue("linkding_api_key"), LinkdingAPIKey: r.FormValue("linkding_api_key"),
LinkdingTags: r.FormValue("linkding_tags"), LinkdingTags: r.FormValue("linkding_tags"),
LinkdingMarkAsUnread: r.FormValue("linkding_mark_as_unread") == "1", LinkdingMarkAsUnread: r.FormValue("linkding_mark_as_unread") == "1",
LinkwardenEnabled: r.FormValue("linkwarden_enabled") == "1",
LinkwardenURL: r.FormValue("linkwarden_url"),
LinkwardenAPIKey: r.FormValue("linkwarden_api_key"),
MatrixBotEnabled: r.FormValue("matrix_bot_enabled") == "1", MatrixBotEnabled: r.FormValue("matrix_bot_enabled") == "1",
MatrixBotUser: r.FormValue("matrix_bot_user"), MatrixBotUser: r.FormValue("matrix_bot_user"),
MatrixBotPassword: r.FormValue("matrix_bot_password"), MatrixBotPassword: r.FormValue("matrix_bot_password"),

View file

@ -79,6 +79,9 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
LinkdingAPIKey: integration.LinkdingAPIKey, LinkdingAPIKey: integration.LinkdingAPIKey,
LinkdingTags: integration.LinkdingTags, LinkdingTags: integration.LinkdingTags,
LinkdingMarkAsUnread: integration.LinkdingMarkAsUnread, LinkdingMarkAsUnread: integration.LinkdingMarkAsUnread,
LinkwardenEnabled: integration.LinkwardenEnabled,
LinkwardenURL: integration.LinkwardenURL,
LinkwardenAPIKey: integration.LinkwardenAPIKey,
MatrixBotEnabled: integration.MatrixBotEnabled, MatrixBotEnabled: integration.MatrixBotEnabled,
MatrixBotUser: integration.MatrixBotUser, MatrixBotUser: integration.MatrixBotUser,
MatrixBotPassword: integration.MatrixBotPassword, MatrixBotPassword: integration.MatrixBotPassword,