From 97edeb725b7f0cd154a158330f7429e745062801 Mon Sep 17 00:00:00 2001 From: Kirill Rogovoy Date: Sat, 17 Jul 2021 15:00:38 +0300 Subject: Add a servlet to serve the web app build --- org-roam-ui.el | 7 +++++++ 1 file changed, 7 insertions(+) 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)) -- cgit v1.2.3