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

fix: display http(s) reflinks too #327

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
41 changes: 19 additions & 22 deletions org-roam-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ unchanged."
'list
(org-roam-ui--separate-ref-links
(org-roam-ui--get-cites))
(org-roam-ui--get-links))))
(org-roam-ui--separate-ref-links
(org-roam-ui--get-links)))))
(links-with-empty-refs (org-roam-ui--filter-citations links-db-rows))
(empty-refs (delete-dups (seq-map
(lambda (link)
Expand Down Expand Up @@ -489,9 +490,14 @@ were in the same table as the links)."
(org-roam-db-query
`[:select [links:source
links:dest
links:type]
links:type
refs:node-id]
:from links
:where (= links:type "id")])
:left :outer :join refs :on (= links:dest refs:ref)
:where (or
(= links:type "id")
(= links:type "http")
(= links:type "https"))])
;; Left outer join on refs means any id link (or cite link without a
;; corresponding node) will have 'nil for the `refs:node-id' value. Any
;; cite link where a node has that `:ROAM_REFS:' will have a value.
Expand All @@ -509,33 +515,24 @@ were in the same table as the links)."
(defun org-roam-ui--get-cites ()
"Get the citations when using the new db-model."
(org-roam-db-query
`[:select [citations:node-id citations:cite-key refs:node-id]
`[:select [citations:node-id citations:cite-key "cite" refs:node-id]
:from citations
:left :outer :join refs :on (= citations:cite-key refs:ref)]))

(defun org-roam-ui--separate-ref-links (links &optional old)
(defun org-roam-ui--separate-ref-links (links)
"Create separate entries for LINKS with existing reference nodes.
Optionally set OLD to t to support old citations db-model.

Convert any cite links that have nodes with associated refs to an
Convert any non-id links that have nodes with associated refs to an
id based link of type `ref' while removing the 'nil `refs:node-id'
from all other links."

(if (not old)
(seq-map
(lambda (link)
(pcase-let ((`(,source ,dest ,node-id) link))
(if node-id
(list source node-id "ref")
(list source dest "cite"))))
links)
(seq-map
(lambda (link)
(pcase-let ((`(,source ,dest ,type ,node-id) link))
(if node-id
(list source node-id "ref")
(list source dest type))))
links)))
(seq-map
(lambda (link)
(pcase-let ((`(,source ,dest ,type ,node-id) link))
(if node-id
(list source node-id "ref")
(list source dest type))))
links))

(defun org-roam-ui--update-current-node ()
"Send the current node data to the web-socket."
Expand Down