(tandoor) Basic Tandoor recipe manager integration

This commit is contained in:
Marcel Kapfer 2025-06-28 15:11:58 +02:00
parent 9d0d4ce330
commit 2bb04f6953
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09
2 changed files with 51 additions and 0 deletions

View file

@ -2934,6 +2934,17 @@ API Integration for [[https://linkding.link/][Linkding]].
linkding-user "mmk2410"))
#+end_src
** Tandoor Integration
API Integration for [[https://tandoor.dev/][Tandoor]].
#+begin_src emacs-lisp
(use-package tandoor
:load-path "packages/"
:custom
(tandoor-host "recipes.mmk2410.org"))
#+end_src
* EDAM
A simple work-in-progress photography DAM in Emacs.

40
packages/tandoor.el Normal file
View file

@ -0,0 +1,40 @@
;;; tandoor.el --- Tandoor Integration -*- lexical-binding: t -*-
;;; Commentary:
;;; Integration with Tandoor.
;;; Code:
(require 'json)
(require 'plz)
(defcustom tandoor-host ""
"Hostname of the Tandoor instance."
:type '(string)
:group 'tandoor)
(defun tandoor--get-api-key ()
"Get Tandoor API key from auth store."
(let ((result (auth-source-search :host tandoor-host)))
(if result
(funcall (plist-get (car result) :secret))
nil)))
(defun tandoor--build-headers ()
"Build headers for Tandoor API request."
`(("Content-Type" . "application/json")
("Authorization" . ,(concat "Bearer " (tandoor--get-api-key)))))
(defun tandoor-shopping-list-add-entry (food amount unit)
"Add AMOUNT UNIT FOOD to Tandoor shopping list."
(interactive "sFood to add: \nsAmount: \nsUnit: ")
(plz 'post (concat "https://" tandoor-host "/api/shopping-list-entry/")
:headers (tandoor--build-headers)
:body (json-encode `(("food" ("name" . ,food))
("unit" ("name" . ,unit))
("amount" . ,amount)))
:as 'string
:then (lambda (res) (message "Entry added successfully."))
:else (lambda (res) (message "Failed to add entry."))))
(provide 'tandoor)
;;; tandoor.el ends here