Cross-platform links to external files

I would like to have a way of specifying links that resolve differently on different platforms. For instance on windows it would use the path as a relative path inside a local folder. On OSX it would the same but to a different local folder. On the phone it could resolve to a url that could be constructed with some rule.

So in the end I would like the ability to create some sort of client dependent links. I am wondering if there is a plugin to do that. It seems like a simple link shortcut like keywords in chrome. I thought perhaps there is a plugin that does this already.

Thank you!

2 Likes

Are they all within your vault, or are these folders outside of your vault?

If inside the vault, there is an api call to get local address of the vault within that context.

Outside the vault. Most often they are pdfs that I want to open with the default viewer.

1 Like

Then I’m at a loss, and you might have an issue reaching them especially on Android and/or iOS, as those are rather closed operating systems.

On windows and osx I reckon it should be possible to detect where you are somehow, and use that to produce a proper base for your links. I’m on mobile right now, so can’t really check exactly how to do so.

Will the sub-links be the same on the various platforms, so it’s just the base which will change? And what plugins do you intend to use? Templater? Dataview?

On the desktop I was thinking about simply changing the base. I was hoping that could be done relatively easily. Actually I could call a local script, I even thought about having a URI system on each of my computers.

Clearly on mobiles it is more tricky. So there I thought I could simply transform it to a URI that points to Dropbox or any other online storage.

But bottom line, I would like to find out if there is a way for me to specify a link keyword that rewrites the link

Imagine I have a link like mylink:fodler1/filename1.pdf in my notes,
then somewhere I can provide a simple rewrite rules that takes this and transforms it into a new link like file:///drive:/%s or https://me.github.com/pdfs/%s.

I have in mind something like chrome search query fields

I would suggest that you use third-party software to handle this, such as Zotero. It may not be a perfect solution, but it’s worth a try.

The limitations are quite obvious, as you have to import your files into the third-party software and lose some freedom in file management. Additionally, you will need to install it on every device that you use.

Thank you for the suggestion. I have looked into zotero before. I might have to do that then.

One option to use for the base within Obsidian could be to use dv.view() scripts, see Dataview doc for dv.view(). This could provide with you with whatever framework you would need to supply the appropriate links on the various platforms.

This script could also easily hold the various bases, and rewrite rules needed to accommodate these as well. What would be the better base for the various platforms I’m not sure of. I’m also not sure which way is the better way to detect which platform you’re on, whether you should parse that from the user agent settings somewhere, or from within the app context or the result from Show debug info, or what not. (It could be that the navigator object would be a good place to start… )

What about a personal WebDAV server ? A basic Synology, for example, is not very expensive, and rather easily configured as a WebDAV server. You can then store on it the files you need and reference them in an “OS agnostic” way. You should then be able to access them even from an iPad or an Android device — I’m pretty positive. (Not more than that, because I’m not an IT professional and work only on Apple platforms.)

This is a great suggestion. First I can use inline js to hack something together as a proof of concept. I am going to do that! This is actually great, because I wanted to create links using bibtex keys. I think I will be able to do that easily using js and data stored into a given file somewhere in my vault. I will post here once I have a small version of it!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.