summaryrefslogtreecommitdiff
path: root/org-roam-ui.el
diff options
context:
space:
mode:
authorKirill Rogovoy <[email protected]>2021-07-17 15:00:38 +0300
committerKirill Rogovoy <[email protected]>2021-07-17 15:01:11 +0300
commit97edeb725b7f0cd154a158330f7429e745062801 (patch)
tree5cdfc4272d544a4ea47103d0c6bf7656eda335bf /org-roam-ui.el
parent9b46f1da6cc37204bc54913f95ef31cf879d4881 (diff)
Add a servlet to serve the web app build
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r--org-roam-ui.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el
index 3f2c737..1301627 100644
--- a/org-roam-ui.el
+++ b/org-roam-ui.el
@@ -1,6 +1,9 @@
(require 'json)
(require 'simple-httpd)
+(setq org-roam-ui/root-dir (file-name-directory load-file-name))
+(setq org-roam-ui/app-build-dir (expand-file-name "./" org-roam-ui/root-dir))
+
(define-minor-mode
org-roam-ui-mode
"Start the http API for org-roam-ui."
@@ -15,6 +18,7 @@
(t
(httpd-stop))))
+
(defservlet* graph application/json ()
(let* (
(nodes-db-rows (org-roam-db-query `[:select [*] :from nodes]))
@@ -26,6 +30,9 @@
(insert response)
(httpd-send-header t "text/plain" 200 :Access-Control-Allow-Origin "*"))))
+(httpd-def-file-servlet app org-roam-ui/app-build-dir)
+
+
(defun nodes-row-to-cons (row)
(list
(cons 'id (elt row 0))