fix org-agenda-api container startup

This commit is contained in:
2026-03-25 11:45:55 -07:00
committed by Kat Huang
parent 6a64103569
commit 65d1967d94
3 changed files with 30 additions and 10 deletions

View File

@@ -18,6 +18,12 @@
;; Load tangled config files in order ;; Load tangled config files in order
(let ((config-dir (file-name-directory load-file-name))) (let ((config-dir (file-name-directory load-file-name)))
;; Containerized Emacs runs without a normal home directory. Some packages
;; spawn async subprocesses using `user-emacs-directory` as cwd, so ensure
;; that path exists before loading the full config.
(setq user-emacs-directory "/tmp/emacs/")
(make-directory user-emacs-directory t)
;; Load preface first (defines variables with default values) ;; Load preface first (defines variables with default values)
(when (file-exists-p (expand-file-name "org-config-preface.el" config-dir)) (when (file-exists-p (expand-file-name "org-config-preface.el" config-dir))
(load (expand-file-name "org-config-preface.el" config-dir))) (load (expand-file-name "org-config-preface.el" config-dir)))
@@ -175,13 +181,17 @@ Returns nil for non-entry templates or templates that can't be converted."
(defun imalison:convert-all-capture-templates () (defun imalison:convert-all-capture-templates ()
"Convert all org-capture-templates to org-agenda-api-capture-templates format." "Convert all org-capture-templates to org-agenda-api-capture-templates format."
(let ((converted '())) (let ((converted '())
(dolist (template org-capture-templates) (templates (and (boundp 'org-capture-templates) org-capture-templates)))
(dolist (template templates)
(let ((api-template (imalison:convert-capture-template template))) (let ((api-template (imalison:convert-capture-template template)))
(when api-template (when api-template
(push api-template converted)))) (push api-template converted))))
(nreverse converted))) (nreverse converted)))
;; Ensure org-capture variables are defined before converting templates.
(require 'org-capture nil t)
;; Default prompts for TODO templates when extraction fails ;; Default prompts for TODO templates when extraction fails
(defvar imalison:default-todo-prompts (defvar imalison:default-todo-prompts
'(("Title" :type string :required t)) '(("Title" :type string :required t))

View File

@@ -10,6 +10,12 @@
;; Load tangled config files in order ;; Load tangled config files in order
(let ((config-dir (file-name-directory load-file-name))) (let ((config-dir (file-name-directory load-file-name)))
;; Containerized Emacs runs without a normal home directory. Some packages
;; spawn async subprocesses using `user-emacs-directory` as cwd, so ensure
;; that path exists before loading the full config.
(setq user-emacs-directory "/tmp/emacs/")
(make-directory user-emacs-directory t)
;; Load preface first (defines variables with default values) ;; Load preface first (defines variables with default values)
(when (file-exists-p (expand-file-name "org-config-preface.el" config-dir)) (when (file-exists-p (expand-file-name "org-config-preface.el" config-dir))
(load (expand-file-name "org-config-preface.el" config-dir))) (load (expand-file-name "org-config-preface.el" config-dir)))
@@ -158,13 +164,17 @@ Returns nil for non-entry templates or templates that can't be converted."
(defun imalison:convert-all-capture-templates () (defun imalison:convert-all-capture-templates ()
"Convert all org-capture-templates to org-agenda-api-capture-templates format." "Convert all org-capture-templates to org-agenda-api-capture-templates format."
(let ((converted '())) (let ((converted '())
(dolist (template org-capture-templates) (templates (and (boundp 'org-capture-templates) org-capture-templates)))
(dolist (template templates)
(let ((api-template (imalison:convert-capture-template template))) (let ((api-template (imalison:convert-capture-template template)))
(when api-template (when api-template
(push api-template converted)))) (push api-template converted))))
(nreverse converted))) (nreverse converted)))
;; Ensure org-capture variables are defined before converting templates.
(require 'org-capture nil t)
;; Auto-generate API capture templates from org-capture-templates ;; Auto-generate API capture templates from org-capture-templates
(setq org-agenda-api-capture-templates (imalison:convert-all-capture-templates)) (setq org-agenda-api-capture-templates (imalison:convert-all-capture-templates))

View File

@@ -5,23 +5,23 @@ user := "imalison"
# Get all todos # Get all todos
get-all-todos: get-all-todos:
@curl -s -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" "{{base_url}}/get-all-todos" | jq . # gitleaks:allow @curl -s -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" "{{base_url}}/get-all-todos" | jq . # gitleaks:allow
# Get today's agenda # Get today's agenda
get-todays-agenda: get-todays-agenda:
@curl -s -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" "{{base_url}}/get-todays-agenda" | jq . # gitleaks:allow @curl -s -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" "{{base_url}}/get-todays-agenda" | jq . # gitleaks:allow
# Get agenda (day view) # Get agenda (day view)
agenda: agenda:
@curl -s -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" "{{base_url}}/agenda" | jq . # gitleaks:allow @curl -s -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" "{{base_url}}/agenda" | jq . # gitleaks:allow
# Get agenda files # Get agenda files
agenda-files: agenda-files:
@curl -s -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" "{{base_url}}/agenda-files" | jq . # gitleaks:allow @curl -s -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" "{{base_url}}/agenda-files" | jq . # gitleaks:allow
# Get todo states # Get todo states
todo-states: todo-states:
@curl -s -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" "{{base_url}}/todo-states" | jq . # gitleaks:allow @curl -s -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" "{{base_url}}/todo-states" | jq . # gitleaks:allow
# Health check # Health check
health: health:
@@ -30,7 +30,7 @@ health:
# Create a todo # Create a todo
create-todo title: create-todo title:
# gitleaks:allow # gitleaks:allow
@curl -s -X POST -u "{{user}}:$(pass show org-agenda-api/imalison | head -1)" \ @curl -s -X POST -u "{{user}}:$(pass show org-agenda-api-imalison | head -1)" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"title": "{{title}}"}' \ -d '{"title": "{{title}}"}' \
"{{base_url}}/create-todo" | jq . "{{base_url}}/create-todo" | jq .