Add option to send only the URL to Wallabag
This commit is contained in:
parent
133a1f83e3
commit
3f64e4b943
25 changed files with 110 additions and 65 deletions
|
@ -610,4 +610,10 @@ var migrations = []func(tx *sql.Tx) error{
|
|||
`)
|
||||
return
|
||||
},
|
||||
func(tx *sql.Tx) (err error) {
|
||||
_, err = tx.Exec(`
|
||||
ALTER TABLE integrations ADD COLUMN wallabag_only_url bool default 'f';
|
||||
`)
|
||||
return
|
||||
},
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
|
|||
integration.WallabagClientSecret,
|
||||
integration.WallabagUsername,
|
||||
integration.WallabagPassword,
|
||||
integration.WallabagOnlyURL,
|
||||
)
|
||||
|
||||
if err := client.AddEntry(entry.URL, entry.Title, entry.Content); err != nil {
|
||||
|
|
|
@ -20,11 +20,12 @@ type Client struct {
|
|||
clientSecret string
|
||||
username string
|
||||
password string
|
||||
onlyURL bool
|
||||
}
|
||||
|
||||
// NewClient returns a new Wallabag client.
|
||||
func NewClient(baseURL, clientID, clientSecret, username, password string) *Client {
|
||||
return &Client{baseURL, clientID, clientSecret, username, password}
|
||||
func NewClient(baseURL, clientID, clientSecret, username, password string, onlyURL bool) *Client {
|
||||
return &Client{baseURL, clientID, clientSecret, username, password, onlyURL}
|
||||
}
|
||||
|
||||
// AddEntry sends a link to Wallabag.
|
||||
|
@ -48,9 +49,14 @@ func (c *Client) createEntry(accessToken, link, title, content string) error {
|
|||
return fmt.Errorf("wallbag: unable to get entries endpoint: %v", err)
|
||||
}
|
||||
|
||||
data := map[string]string{"url": link, "title": title}
|
||||
if !c.onlyURL {
|
||||
data["content"] = content
|
||||
}
|
||||
|
||||
clt := client.New(endpoint)
|
||||
clt.WithAuthorization("Bearer " + accessToken)
|
||||
response, err := clt.PostJSON(map[string]string{"url": link, "title": title, "content": content})
|
||||
response, err := clt.PostJSON(data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("wallabag: unable to post entry: %v", err)
|
||||
}
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Verbinden Sie Ihr Pocket Konto",
|
||||
"form.integration.wallabag_activate": "Artikel in Wallabag speichern",
|
||||
"form.integration.wallabag_only_url": "Nur URL senden (anstelle des vollständigen Inhalts)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag URL",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client-ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client-Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Συνδέστε τον λογαριασμό Pocket σας",
|
||||
"form.integration.wallabag_activate": "Αποθήκευση άρθρων στο Wallabag",
|
||||
"form.integration.wallabag_only_url": "Αποστολή μόνο URL (αντί για πλήρες περιεχόμενο)",
|
||||
"form.integration.wallabag_endpoint": "Τελικό σημείο Wallabag API ",
|
||||
"form.integration.wallabag_client_id": "Ταυτότητα πελάτη Wallabag",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Μυστικό Πελάτη",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Connect your Pocket account",
|
||||
"form.integration.wallabag_activate": "Save articles to Wallabag",
|
||||
"form.integration.wallabag_only_url": "Send only URL (instead of full content)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag API Endpoint",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Token de acceso de Pocket",
|
||||
"form.integration.pocket_connect_link": "Conectar a la cuenta de Pocket",
|
||||
"form.integration.wallabag_activate": "Guardar artículos a Wallabag",
|
||||
"form.integration.wallabag_only_url": "Enviar solo URL (en lugar de contenido completo)",
|
||||
"form.integration.wallabag_endpoint": "Extremo de API de Wallabag",
|
||||
"form.integration.wallabag_client_id": "ID de cliente de Wallabag",
|
||||
"form.integration.wallabag_client_secret": "Secreto cliente de Wallabag",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket-käyttöoikeustunnus",
|
||||
"form.integration.pocket_connect_link": "Yhdistä Pocket-tilisi",
|
||||
"form.integration.wallabag_activate": "Tallenna artikkelit Wallabagiin",
|
||||
"form.integration.wallabag_only_url": "Lähetä vain URL-osoite (koko sisällön sijaan)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag API -päätepiste",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Jeton d'accès de l'API de Pocket",
|
||||
"form.integration.pocket_connect_link": "Connectez votre compte Pocket",
|
||||
"form.integration.wallabag_activate": "Sauvegarder les articles vers Wallabag",
|
||||
"form.integration.wallabag_only_url": "Envoyer uniquement l'URL (au lieu du contenu complet)",
|
||||
"form.integration.wallabag_endpoint": "URL de l'API de Wallabag",
|
||||
"form.integration.wallabag_client_id": "Identifiant unique du client Wallabag",
|
||||
"form.integration.wallabag_client_secret": "Clé secrète du client Wallabag",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "पॉकेट एक्सेस टोकन",
|
||||
"form.integration.pocket_connect_link": "अपना पॉकेट खाता कनेक्ट करें",
|
||||
"form.integration.wallabag_activate": "विषय सहेजें वालाबाग में ",
|
||||
"form.integration.wallabag_only_url": "केवल URL भेजें (पूर्ण सामग्री के बजाय)",
|
||||
"form.integration.wallabag_endpoint": "वालबैग एपीआई एंडपॉइंट",
|
||||
"form.integration.wallabag_client_id": "वालाबैग क्लाइंट आईडी",
|
||||
"form.integration.wallabag_client_secret": "वालाबैग क्लाइंट सीक्रेट",
|
||||
|
|
|
@ -334,6 +334,7 @@
|
|||
"form.integration.pocket_connect_link": "Collega il tuo account Pocket",
|
||||
"form.integration.wallabag_activate": "Salva gli articoli su Wallabag",
|
||||
"form.integration.wallabag_endpoint": "Endpoint dell'API di Wallabag",
|
||||
"form.integration.wallabag_only_url": "Invia solo URL (invece del contenuto completo)",
|
||||
"form.integration.wallabag_client_id": "Client ID dell'account Wallabag",
|
||||
"form.integration.wallabag_client_secret": "Client secret dell'account Wallabag",
|
||||
"form.integration.wallabag_username": "Nome utente dell'account Wallabag",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket の Access Token",
|
||||
"form.integration.pocket_connect_link": "Pocket account に接続",
|
||||
"form.integration.wallabag_activate": "Wallabag に記事を保存する",
|
||||
"form.integration.wallabag_only_url": "URL のみを送信 (完全なコンテンツではなく)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag の API Endpoint",
|
||||
"form.integration.wallabag_client_id": "Wallabag の Client ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag の Client Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Verbind je Pocket-account",
|
||||
"form.integration.wallabag_activate": "Opslaan naar Wallabag",
|
||||
"form.integration.wallabag_only_url": "Alleen URL verzenden (in plaats van volledige inhoud)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag URL",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client-ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client-Secret",
|
||||
|
|
|
@ -335,6 +335,7 @@
|
|||
"form.integration.pocket_access_token": "Token dostępu kieszeń",
|
||||
"form.integration.pocket_connect_link": "Połącz swoje konto Pocket",
|
||||
"form.integration.wallabag_activate": "Zapisz artykuły do Wallabag",
|
||||
"form.integration.wallabag_only_url": "Wyślij tylko adres URL (zamiast pełnej treści)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag URL",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client-ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Token de acesso do Pocket",
|
||||
"form.integration.pocket_connect_link": "Conectar a conta do Pocket",
|
||||
"form.integration.wallabag_activate": "Salvar itens no Wallabag",
|
||||
"form.integration.wallabag_only_url": "Enviar apenas URL (em vez de conteúdo completo)",
|
||||
"form.integration.wallabag_endpoint": "Endpoint da API do Wallabag",
|
||||
"form.integration.wallabag_client_id": "ID de cliente (Client ID) do Wallabag",
|
||||
"form.integration.wallabag_client_secret": "Segredo do cliente (Client Secret) do Wallabag",
|
||||
|
|
|
@ -334,6 +334,7 @@
|
|||
"form.integration.pocket_consumer_key": "Pocket Consumer Key",
|
||||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Подключить аккаунт Pocket",
|
||||
"form.integration.wallabag_only_url": "Отправлять только URL (вместо всего содержимого)",
|
||||
"form.integration.wallabag_activate": "Сохранять статьи в Wallabag",
|
||||
"form.integration.wallabag_endpoint": "Конечная точка Wallabag API",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client ID",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Pocket hesabını bağla",
|
||||
"form.integration.wallabag_activate": "Makaleleri Wallabag'e kaydet",
|
||||
"form.integration.wallabag_only_url": "Yalnızca URL gönder (tam içerik yerine)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag API Uç Noktası",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client Secret",
|
||||
|
|
|
@ -332,6 +332,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket Access Token",
|
||||
"form.integration.pocket_connect_link": "Підключити ваш обліковий запис Pocket",
|
||||
"form.integration.wallabag_activate": "Зберігати статті до Wallabag",
|
||||
"form.integration.wallabag_only_url": "Надіслати лише URL (замість повного вмісту)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag API Endpoint",
|
||||
"form.integration.wallabag_client_id": "Wallabag Client ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag Client Secret",
|
||||
|
|
|
@ -331,6 +331,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket 访问密钥",
|
||||
"form.integration.pocket_connect_link": "连接您的 Pocket 帐户",
|
||||
"form.integration.wallabag_activate": "保存文章到 Wallabag",
|
||||
"form.integration.wallabag_only_url": "仅发送 URL(而不是完整内容)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag URL",
|
||||
"form.integration.wallabag_client_id": "Wallabag 客户端 ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag 客户端 Secret",
|
||||
|
|
|
@ -333,6 +333,7 @@
|
|||
"form.integration.pocket_access_token": "Pocket 訪問金鑰",
|
||||
"form.integration.pocket_connect_link": "連線您的 Pocket 帳戶",
|
||||
"form.integration.wallabag_activate": "儲存文章到 Wallabag",
|
||||
"form.integration.wallabag_only_url": "仅发送 URL(而不是完整内容)",
|
||||
"form.integration.wallabag_endpoint": "Wallabag URL",
|
||||
"form.integration.wallabag_client_id": "Wallabag 客戶端 ID",
|
||||
"form.integration.wallabag_client_secret": "Wallabag 客戶端 Secret",
|
||||
|
|
|
@ -21,6 +21,7 @@ type Integration struct {
|
|||
GoogleReaderUsername string
|
||||
GoogleReaderPassword string
|
||||
WallabagEnabled bool
|
||||
WallabagOnlyURL bool
|
||||
WallabagURL string
|
||||
WallabagClientID string
|
||||
WallabagClientSecret string
|
||||
|
|
|
@ -125,6 +125,7 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
|||
googlereader_username,
|
||||
googlereader_password,
|
||||
wallabag_enabled,
|
||||
wallabag_only_url,
|
||||
wallabag_url,
|
||||
wallabag_client_id,
|
||||
wallabag_client_secret,
|
||||
|
@ -168,6 +169,7 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
|
|||
&integration.GoogleReaderUsername,
|
||||
&integration.GoogleReaderPassword,
|
||||
&integration.WallabagEnabled,
|
||||
&integration.WallabagOnlyURL,
|
||||
&integration.WallabagURL,
|
||||
&integration.WallabagClientID,
|
||||
&integration.WallabagClientSecret,
|
||||
|
@ -223,32 +225,33 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
fever_username=$9,
|
||||
fever_token=$10,
|
||||
wallabag_enabled=$11,
|
||||
wallabag_url=$12,
|
||||
wallabag_client_id=$13,
|
||||
wallabag_client_secret=$14,
|
||||
wallabag_username=$15,
|
||||
wallabag_password=$16,
|
||||
nunux_keeper_enabled=$17,
|
||||
nunux_keeper_url=$18,
|
||||
nunux_keeper_api_key=$19,
|
||||
pocket_enabled=$20,
|
||||
pocket_access_token=$21,
|
||||
pocket_consumer_key=$22,
|
||||
googlereader_enabled=$23,
|
||||
googlereader_username=$24,
|
||||
googlereader_password=$25,
|
||||
telegram_bot_enabled=$26,
|
||||
telegram_bot_token=$27,
|
||||
telegram_bot_chat_id=$28,
|
||||
espial_enabled=$29,
|
||||
espial_url=$30,
|
||||
espial_api_key=$31,
|
||||
espial_tags=$32,
|
||||
linkding_enabled=$33,
|
||||
linkding_url=$34,
|
||||
linkding_api_key=$35
|
||||
wallabag_only_url=$12,
|
||||
wallabag_url=$13,
|
||||
wallabag_client_id=$14,
|
||||
wallabag_client_secret=$15,
|
||||
wallabag_username=$16,
|
||||
wallabag_password=$17,
|
||||
nunux_keeper_enabled=$18,
|
||||
nunux_keeper_url=$19,
|
||||
nunux_keeper_api_key=$20,
|
||||
pocket_enabled=$21,
|
||||
pocket_access_token=$22,
|
||||
pocket_consumer_key=$23,
|
||||
googlereader_enabled=$24,
|
||||
googlereader_username=$25,
|
||||
googlereader_password=$26,
|
||||
telegram_bot_enabled=$27,
|
||||
telegram_bot_token=$28,
|
||||
telegram_bot_chat_id=$29,
|
||||
espial_enabled=$30,
|
||||
espial_url=$31,
|
||||
espial_api_key=$32,
|
||||
espial_tags=$33,
|
||||
linkding_enabled=$34,
|
||||
linkding_url=$35,
|
||||
linkding_api_key=$36
|
||||
WHERE
|
||||
user_id=$36
|
||||
user_id=$37
|
||||
`
|
||||
_, err = s.db.Exec(
|
||||
query,
|
||||
|
@ -263,6 +266,7 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
integration.FeverUsername,
|
||||
integration.FeverToken,
|
||||
integration.WallabagEnabled,
|
||||
integration.WallabagOnlyURL,
|
||||
integration.WallabagURL,
|
||||
integration.WallabagClientID,
|
||||
integration.WallabagClientSecret,
|
||||
|
@ -305,32 +309,33 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
fever_username=$9,
|
||||
fever_token=$10,
|
||||
wallabag_enabled=$11,
|
||||
wallabag_url=$12,
|
||||
wallabag_client_id=$13,
|
||||
wallabag_client_secret=$14,
|
||||
wallabag_username=$15,
|
||||
wallabag_password=$16,
|
||||
nunux_keeper_enabled=$17,
|
||||
nunux_keeper_url=$18,
|
||||
nunux_keeper_api_key=$19,
|
||||
pocket_enabled=$20,
|
||||
pocket_access_token=$21,
|
||||
pocket_consumer_key=$22,
|
||||
googlereader_enabled=$23,
|
||||
googlereader_username=$24,
|
||||
googlereader_password=$25,
|
||||
telegram_bot_enabled=$26,
|
||||
telegram_bot_token=$27,
|
||||
telegram_bot_chat_id=$28,
|
||||
espial_enabled=$29,
|
||||
espial_url=$30,
|
||||
espial_api_key=$31,
|
||||
espial_tags=$32,
|
||||
linkding_enabled=$33,
|
||||
linkding_url=$34,
|
||||
linkding_api_key=$35
|
||||
wallabag_only_url=$12,
|
||||
wallabag_url=$13,
|
||||
wallabag_client_id=$14,
|
||||
wallabag_client_secret=$15,
|
||||
wallabag_username=$16,
|
||||
wallabag_password=$17,
|
||||
nunux_keeper_enabled=$18,
|
||||
nunux_keeper_url=$19,
|
||||
nunux_keeper_api_key=$20,
|
||||
pocket_enabled=$21,
|
||||
pocket_access_token=$22,
|
||||
pocket_consumer_key=$23,
|
||||
googlereader_enabled=$24,
|
||||
googlereader_username=$25,
|
||||
googlereader_password=$26,
|
||||
telegram_bot_enabled=$27,
|
||||
telegram_bot_token=$28,
|
||||
telegram_bot_chat_id=$29,
|
||||
espial_enabled=$30,
|
||||
espial_url=$31,
|
||||
espial_api_key=$32,
|
||||
espial_tags=$33,
|
||||
linkding_enabled=$34,
|
||||
linkding_url=$35,
|
||||
linkding_api_key=$36
|
||||
WHERE
|
||||
user_id=$36
|
||||
user_id=$37
|
||||
`
|
||||
_, err = s.db.Exec(
|
||||
query,
|
||||
|
@ -345,6 +350,7 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
|
|||
integration.FeverUsername,
|
||||
integration.FeverToken,
|
||||
integration.WallabagEnabled,
|
||||
integration.WallabagOnlyURL,
|
||||
integration.WallabagURL,
|
||||
integration.WallabagClientID,
|
||||
integration.WallabagClientSecret,
|
||||
|
|
|
@ -119,6 +119,10 @@
|
|||
<input type="checkbox" name="wallabag_enabled" value="1" {{ if .form.WallabagEnabled }}checked{{ end }}> {{ t "form.integration.wallabag_activate" }}
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="wallabag_only_url" value="1" {{ if .form.WallabagOnlyURL }}checked{{ end }}> {{ t "form.integration.wallabag_only_url" }}
|
||||
</label>
|
||||
|
||||
<label for="form-wallabag-url">{{ t "form.integration.wallabag_endpoint" }}</label>
|
||||
<input type="url" name="wallabag_url" id="form-wallabag-url" value="{{ .form.WallabagURL }}" placeholder="http://v2.wallabag.org/" spellcheck="false">
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ type IntegrationForm struct {
|
|||
GoogleReaderUsername string
|
||||
GoogleReaderPassword string
|
||||
WallabagEnabled bool
|
||||
WallabagOnlyURL bool
|
||||
WallabagURL string
|
||||
WallabagClientID string
|
||||
WallabagClientSecret string
|
||||
|
@ -63,6 +64,7 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
|
|||
integration.GoogleReaderEnabled = i.GoogleReaderEnabled
|
||||
integration.GoogleReaderUsername = i.GoogleReaderUsername
|
||||
integration.WallabagEnabled = i.WallabagEnabled
|
||||
integration.WallabagOnlyURL = i.WallabagOnlyURL
|
||||
integration.WallabagURL = i.WallabagURL
|
||||
integration.WallabagClientID = i.WallabagClientID
|
||||
integration.WallabagClientSecret = i.WallabagClientSecret
|
||||
|
@ -103,6 +105,7 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
|||
GoogleReaderUsername: r.FormValue("googlereader_username"),
|
||||
GoogleReaderPassword: r.FormValue("googlereader_password"),
|
||||
WallabagEnabled: r.FormValue("wallabag_enabled") == "1",
|
||||
WallabagOnlyURL: r.FormValue("wallabag_only_url") == "1",
|
||||
WallabagURL: r.FormValue("wallabag_url"),
|
||||
WallabagClientID: r.FormValue("wallabag_client_id"),
|
||||
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
|
||||
|
|
|
@ -41,6 +41,7 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
|
|||
GoogleReaderEnabled: integration.GoogleReaderEnabled,
|
||||
GoogleReaderUsername: integration.GoogleReaderUsername,
|
||||
WallabagEnabled: integration.WallabagEnabled,
|
||||
WallabagOnlyURL: integration.WallabagOnlyURL,
|
||||
WallabagURL: integration.WallabagURL,
|
||||
WallabagClientID: integration.WallabagClientID,
|
||||
WallabagClientSecret: integration.WallabagClientSecret,
|
||||
|
|
Loading…
Reference in a new issue