Link to callback-urls?

Not specifically a Roam question though. Does anyone know if Org can link to callback URLs? It just asks me if I want to create a new heading.

Now that Roam seems to become like a library system for so many things in one place for me, I thought it’d be great if I could link into Obsidian vaults directly for deep dives. Obsidian allows this via callback urls.
They look like this obsidian://open?vault=Vaultname&file=Examplefile. I think it trips up because Org expects something from its own library of link types.

I have a feeling you can create your own link type: Adding Hyperlink Types (The Org Manual)

I think you can simply open a browser to handle the call back URL or perhaps call Obsidian directly (via shell command, perhaps?)???

I kinda have it working. Still have to figure out how to do file links. Vaults are useable because that’s easy. I can just concat the value.

(org-link-set-parameters
  "obsidian"

  :follow (lambda (vault)
            (browse-url (concat "obsidian://open?vault=" vault)))
)

So much to still figure out. But looks like I’ll eventually be able to have deep links down to headlines in biographies for dedicated Obsidian vaults right from the main library in Roam.

Extending your code, how about something like this?

(org-link-set-parameters
  "obsidian"
  :follow
  (lambda (path)
    (cl-destructuring-bind 
        (vault file) (split-string path "::")
      (browse-url (format "obsidian://open?vault=%s&file=%s" vault file)))))

If my test was done correctly, this lets you have this as an Org link, [[obsidian:Vaultname::Examplefile]], and you get to call this URL: obsidian://open?vault=Vaultname&file=Examplefile.

Thanks so much! That worked almost right away.

Instead of

It was

        (vault file) (split-string path ":")

Now I just have to figure out how to get them to show up in Roam UI. Shame that #Heading didn’t work after the filename but probably for the better since Obsidian goes by named links instead of unique IDs. Change a heading’s name and the link is dead.

It is really cool as it is now though. Roam stays clean with a birds-eye view of everything. When I mention something specific in a note, I can link it right into what’s essentially a souped up show-bible.

This looks like it should work but the html export has no effect on Roam UI.

(org-link-set-parameters
 "obsidian"
 :follow
 (lambda (path)
   (cl-destructuring-bind
       (vault file) (split-string path ":")
     (browse-url (format "obsidian://open?vault=%s&file=%s" vault file))
   )
   )
 :export
 (lambda (path vault file description backend)
   (format (pcase backend
             ('html "<a href=\"obsidian://open?=vault%s&file=%s\">%s</a>")
             )
           )
   )
 )

This works in export to HTML but Roam-UI is completely ignoring it. The created span has the browse-url value as a valueless attribute.

My org export backends list doesn’t have any roam entries. Roam has to know what to do with the other links, so I wonder how that is defined.

(org-link-set-parameters
 "obsidian"
 :follow
 (lambda (path)
   (cl-destructuring-bind
       (vault file) (split-string path ":")
     (browse-url (format "obsidian://open?vault=%s&file=%s" vault file))
   )
   )
 :export
   (lambda (path description backend info)
     (cl-destructuring-bind
         (vault file) (split-string path ":")
       (format (pcase backend
                 ('html "<a href=\"obsidian://open?vault=%s&file=%s\">%s</a>"))
               vault file description)))
)

Hi Frank,

I don’t think Org-roam-ui uses the Emacs Org export functionality.

I haven’t fully explored what exactly happens but here is my interpretation of the code:

  1. The user calls org-roam-ui-mode in Emacs → The graph is displayed in the browser
    At this stage, none of the node is exported to an HTML yet
  2. The user clicks on a specific node → The React app starts to pull the content of the Org file (and only the one clicked)
  3. Emacs passes the Org node in plain text
  4. The React app uses uniOrg to parse the Org text content → Org-roam-ui displays the parsed content as an HTML content on the right side of the browser

I think this is the Org parser uniorg it uses.

For your custom link type to work, I think you’d need to modify code in 3 or 4. For example, URL links directly written in an Org file works, so you would need to convert the link to an URL just before Emacs passes the Org node in plain text (step 3). Or do something with uniorg (step 4).

1 Like

Thanks for your continued help!

I’ll ask around on the uniorg GitHub what can be done there.