✨ (linkding) Add API integration package
All checks were successful
Publish / publish (push) Successful in 11s
All checks were successful
Publish / publish (push) Successful in 11s
This commit is contained in:
parent
d21f1d2def
commit
c983a022f3
1 changed files with 47 additions and 0 deletions
47
packages/linkding.el
Normal file
47
packages/linkding.el
Normal file
|
@ -0,0 +1,47 @@
|
|||
;;; linkding.el --- Linkding Integration -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
;;; Integration with Linkding.
|
||||
|
||||
;;; Code:
|
||||
(require 'json)
|
||||
(require 'plz)
|
||||
|
||||
(defcustom linkding-host ""
|
||||
"Hostname of the Linkding instance."
|
||||
:type '(string)
|
||||
:group 'linkding)
|
||||
|
||||
(defcustom linkding-user ""
|
||||
"Linkding user name."
|
||||
:type '(string)
|
||||
:group 'linkding)
|
||||
|
||||
(defun linkding--get-api-key ()
|
||||
"Get Linkding API key from auth store."
|
||||
(let ((result (auth-source-search :host linkding-host :user linkding-user)))
|
||||
(if result
|
||||
(funcall (plist-get (car result) :secret))
|
||||
nil)))
|
||||
|
||||
(defun linkding--build-headers ()
|
||||
"Build headers for Linkding Lab API request."
|
||||
`(("Content-Type" . "application/json")
|
||||
("Authorization" . ,(concat "Token " (linkding--get-api-key)))))
|
||||
|
||||
(defun linkding-add-bookmark (url)
|
||||
"Add URL as bookmark to Linkding."
|
||||
(interactive "sURL: ")
|
||||
(plz 'post (concat "https://" linkding-host "/api/bookmarks/")
|
||||
:headers (linkding--build-headers)
|
||||
:body (json-encode `(("url" . ,url)
|
||||
("title" . "")
|
||||
("description" . "")
|
||||
("notes" . "")
|
||||
("is_archived" . false)
|
||||
("unread" . false)
|
||||
("shared" . false)
|
||||
("tag_names" . [])))))
|
||||
|
||||
(provide 'linkding)
|
||||
;;; linkding.el ends here
|
Loading…
Add table
Reference in a new issue