Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track org-roam-directory #312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions org-roam-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ Format as, i.e. with double backslashes for a single backslash:
:type 'alist)

;; Internal vars
(defvar org-roam-ui--roam-directory nil
"Var to keep track of the current org-roam-directory, used in servlet")

(defvar org-roam-ui--ws-current-node nil
"Var to keep track of which node you are looking at.")
Expand Down Expand Up @@ -182,6 +184,7 @@ This serves the web-build and API over HTTP."
;;; else add them
(setq-local httpd-port org-roam-ui-port)
(setq httpd-root org-roam-ui-app-build-dir)
(setq org-roam-ui--roam-directory org-roam-directory)
(httpd-start)
(setq org-roam-ui-ws-server
(websocket-server
Expand Down Expand Up @@ -300,11 +303,13 @@ TODO: Be able to delete individual nodes."

(defservlet* node/:id text/plain ()
"Servlet for accessing node content."
(setq org-roam-directory org-roam-ui--roam-directory)
(insert (org-roam-ui--get-text (org-link-decode id)))
(httpd-send-header t "text/plain" 200 :Access-Control-Allow-Origin "*"))

(defservlet* img/:file text/plain ()
"Servlet for accessing images found in org-roam files."
(setq org-roam-directory org-roam-ui--roam-directory)
(progn
(httpd-send-file t (org-link-decode file))
(httpd-send-header t "text/plain" 200 :Access-Control-Allow-Origin "*")))
Expand Down