diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-25 01:56:51 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-25 01:56:51 +0200 |
commit | ebaad8c293c51a95a78a7674c6cd26998357d09b (patch) | |
tree | 4d3d28f100fd00b09e245490e1c82695f7479805 /org-roam-ui.el | |
parent | 790b0cd2057ee9467c1f5cad5143d79830de484f (diff) |
added parent node viewing toggle
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r-- | org-roam-ui.el | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index d823e77..b6c3ad6 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -58,6 +58,11 @@ 35901 "Port to serve the org-roam-ui interface.") +(defcustom org-roam-ui-link-child-notes t + "TODO" + :group 'org-roam-ui + :type 'boolean) + (define-minor-mode org-roam-ui-mode "Enable org-roam-ui. @@ -81,8 +86,9 @@ This serves the web-build and API over HTTP." (links-columns [source dest type]) (nodes-db-rows (org-roam-db-query `[:select ,nodes-columns :from nodes])) (links-db-rows (org-roam-db-query `[:select ,links-columns :from links :where (or (= type "id") (= type "cite"))])) + (links-total (append links-db-rows (when org-roam-ui-link-child-notes (org-roam-ui-link-children-parents)))) (response (json-encode `((nodes . ,(mapcar (apply-partially #'org-roam-ui-sql-to-alist (append nodes-columns nil)) nodes-db-rows)) - (links . ,(mapcar (apply-partially #'org-roam-ui-sql-to-alist '(source target type)) links-db-rows)))))) + (links . ,(mapcar (apply-partially #'org-roam-ui-sql-to-alist '(source target type)) links-total)))))) (insert response) (httpd-send-header t "application/json" 200 :Access-Control-Allow-Origin "*"))) @@ -94,6 +100,18 @@ ROWS is the sql result, while COLUMN-NAMES is the columns to use." (push (cons (pop column-names) (pop rows)) res)) res)) +(defun org-roam-ui-link-children-parents () + "Return list of links from child notes to their parent file node." +(let* ((parents (org-roam-db-query `[:select [file id] :from nodes :where (= level 0)])) + (row)) + (dolist (dad parents) + (if-let + ((children +(org-roam-db-query `[:select [id] :from nodes :where (and (> level 0) (= file ,(car dad)))]))) + (dolist (child children) (push (list (car child) (elt dad 1) "parent") row)))) + row) + ) + (defservlet* theme text/stream () (progn (when (boundp 'doom-themes--colors) |