Link Obsidian with AdvancedURI Plugin

AdvancedURI Plugin can navigate to specific notes per UUID instead of the file path to be able to rename these files, but to keep the link still working.

like this:
obsidian://advanced-uri?vault=Notes&uid=20220219170220

AdvancedURI Plugin

2 Likes

我写了一篇使用方法

1 Like

This can be a good way to fix the broken link issue once the Obsidian note is moved. Is it possible to change Hook’s behaviour of linking Obsidian notes with other items then? @LucB Currently, I set Use UID instead of file paths in the Advanced URI plugin, still the note link includes file path when hooking an Obsidian note to say this webpage.

It would be great if Hook can create note links by following Advanced URI’s settings.

1 Like

thank you. we will soon revisit the integration. Users will have the choice of URL schemes and integrations. Ideally Hook will be able to determine at run-time whether advanced Obsidian URI is present. Is there a way to do that via automation? If not present, then it would use the basic Obsidian URI. A bundle of scripts using hook://file/ URI is also required.

We also need to support Reveal File in Finder.

Welcome to the Hook Productivity Forum , @GeekMai. Thanks for sharing this!

Thank you all. Does any Obsidian user here have additional information regarding the following? Or would anyone be willing to link to this topic on their forum or their Discord server?

Hook is not able to get the advanced URI. Currently, it seems it is impossible to set a shortcut for just copying advanced URI without bringing up the UI. Besides it would be better to have proper automation without UI scripting

If the advanced URI plugin provide the following two we could provide integration:

  1. “copy advanced markdown URI” for both title and url.
  2. Allow the user to set a shortcut for “copy advanced markdown URI” without bringing up the UI so Hook can use the shortcut to get the markdown URI.

Then we could provide a script for the user to customize it. We can set a default hotkey, and they can change it.

However, much better would be to provide x-callback-url support in the plugin. Or other automation. Is that there or possible?

regarding Reveal File in Finder:

We used to have script that returns file path, but not any more. Current obsidian URL does not have enough information to reveal file in Finder. It would be important to get the full URL even for advanced plugin.

Advanced URI already has the following command/shortcut support:

  • Advanced URl: copy URl for command
  • Advanced URl: copy URI for daily note
  • Advanced URI: copy URI for file
  • Advanced URl: copy URI for search and replace

So maybe the third one can be used for this purpose?

Regarding “copy advanced markdown URI” for both title and url, since Hook can already get the file/note name, maybe this can be parsed with the URI from the shortcut?

Also, I linked this post to the Advanced URI GitHub issue: Better integration with Hook · Issue #46 · Vinzent03/obsidian-advanced-uri · GitHub

Maybe you could also exchange ideas there?

1 Like

@LucB Hey, I’m the author of the plugin. To understand this program first, you call some shortcut to get the Obsidian URI/Advanced-URI and store it internally. Then the user can easier use these saved links to open particular files. And you need my plugin to support file moving, because of the UUID feature?

You’re only interested in opening files and not writing to them, right? The ui is necessary to configure what exactly to do.

What exactly do you mean with the following?

“copy advanced markdown URI” for both title and url.

How would the x-callback-url approach look like? You would call an advanced-uri, which generates a new advanced-uri depending on parameters in that first uri?

1 Like

Thank you for getting back to us so quickly!

The x-callback-url approach would be great! What Hook needs is the current open document’s advanced url and title, and later Hook can use this url to open the obsidian file.

Something similar to Drafts’s x-callback-url getcurrentdraft action:

Okay. How do you want to get the generated uri? (I’m not really familiar with x-callbacks in general) I guess passing an uri from your site to call with two query parameters (file name and uri) is the easiest way. But that requires the user to accept opening an uri in another application two times, right?

How about using a specific x-callback-url action to return current note’s advanced uri and title. Let’s call it getCurrentNote for now.
From Hook, it will send a request like this:
obsidian://x-callback-url/getCurrentNote?x-success=hook://x-callback-url/setCurrentNode

Once receives the request, Obsidian will generate a new url like this and send the information back to Hook by opening this url:
hook://x-callback-url/setCurrentNode?advancedurl=url&title=theTitle

The user does not need to interact with this.

Currently, Hook use Obsidian’s hook-get-address action to get current document’s regular url and title. It copies a markdown link of the current focused note to the clipboard.

X-callback-url approach is preferred.

Thank you!

Ok, I think I’m finished implementing. I register now a new action called hook-get-advanced-uri (obsidian://hook-get-advanced-uri). It accepts the query parameter x-success, which it calls with the query parameters title and uri. They are both encoded. For markdown files, title omits the file extension (example). For other files like pdf it does include the extension(example.pdf). If no file is currently opened, it calls x-error with the query parameter key errorMessage and value No file opened (encoded). If everything is correct, I would be ready to release a new version.

3 Likes

That’s excellent!

Just one more thing, since one of the parameter is called uri, our request url need be like this:
obsidian://x-callback-url/getCurrentNote?x-success=hook://x-callback-url/setCurrentNode?urlkey=uri

which will be encoded as:
obsidian://x-callback-url/getCurrentNote?x-success=hook://x-callback-url/setCurrentNode%3Furlkey%3Duri

Please include all parameters of the original callback url (hook://x-callback-url/setCurrentNode), e.g.
hook://x-callback-url/setCurrentNode?urlkey=uri&uri=url&title=theTitle

Thank you very much for your quick response!

1 Like

Sorry, but I don’t really understand you. In general it wont be obsidian://x-callback-url/getCurrentNote. x-callback-url is to generous. I want the name to be more specific to my plugin. So I suggested hook-get-advanced-uri. In addition I think I don’t have access to any other path segments. So please leave the getCurrentNote.

Please include all parameters of the original callback url

I don’t understand which parameters you mean. Do you want the original uri to Obsidian to be passed to your x-success uri?

Sorry for the confusion.

I thought I changed it accordingly. It should be:
obsidian://hook-get-advanced-uri?x-success=hook://x-callback-url/setCurrentNode%3Furlkey%3Duri

I mean the parameter(s) in the url value of x-success, which, in the url mentioned above, is
urlkey=uri

Ah okay so you have your own query parameters already existing on the x-success uri. So, which query parameter keys should I use now? advanceduri and title?

It is up to you. I will change the parameters of hook callback url accordingly. E.g, if the parameter key is advanceduri, Hook’s request url will be:
obsidian://hook-get-advanced-uri?x-success=hook://x-callback-url/setCurrentNode%3Furlkey%3Dadvanceduri

So when Obsidian send the x-callback-url back to Hook, hook will know the url’s parameter is advanceduri.
hook://x-callback-url/setCurrentNode?urlkey=advanceduri&uri=url&title=theTitle

Thank you

Hey, if I set my uri parameter key to be advanceduri as you wrote in your last hook uri, wouldn’t the uri then be hook://x-callback-url/setCurrentNode?urlkey=advanceduri&advanceduri=url&title=theTitle. And the value url is my generated uri to open the file.

1 Like

You are correct! Sorry about the mistake.

Okay. Is there any reason to pass the key for the uri? Why not pass the uri directly to (in this case) urlkey?