I have spent the last hour or so trying to open URL encoded file:/// URI paths even with the most agressive bypass techniques GPT could think of and none could go through in Card View.
Apparently, as the bot says, this is an Electron sandbox issue…?
Use case: PDFs, movies with posters as covers and clicking path link below it to open the files with system set program.
(I didn’t figure out yet, how to click the image and open the PDF or play music or video, so I add another prop below the cover image.)
YAML example:
thumbnail: "[[coverimage.jpg]]"
path: "file:///Y:/path/to/video/filename_url_encoded.avi"
Apparently, you cannot have <> flankers here, only in the main body of the note. I had URL encoded path put there (through Python script to create my md files).
In the main body in the note, clicking
[![[coverimage.jpg]]](<file:///Y:/path/to/video/filename.avi>) construct works.
Opens video in external vid player, even if it is an mp4, but clicking is more easily done in Reading Mode, of course.
Here, if you add the <>, no URL encoding is needed.
Objective: Clicking Path Link to Open files through Bases Cards View
Tried what the doctor should order first:
1. link(path, "▶ Play Video")
2. something similar to the above (I forgot)
3. html("<a href='" + path + "' target='_blank' rel='noreferrer'>▶ Play Video</a>")
Didn’t work. Clicking the link did nothing.
I tried 7-8 different methods. Nada. Then, finally…
What works
Create a launcher.bat file and keep it safe (you can put it in your vault in some SYSTEM/subfolder):
@echo off
:: Remove the protocol prefix (ms-openlocalfile:) from the passed argument
set "filepath=%~1"
set "filepath=%filepath:ms-openlocalfile:=%"
:: Remove surrounding quotes if any
set "filepath=%filepath:"=%"
:: Launch the file with the default application
start "" "%filepath%"
Then create a text file, “New Document.txt” or whatever, with:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ms-openlocalfile]
@="URL:Open Local File"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ms-openlocalfile\shell]
[HKEY_CLASSES_ROOT\ms-openlocalfile\shell\open]
[HKEY_CLASSES_ROOT\ms-openlocalfile\shell\open\command]
@="\"C:\\Path\\To\\launcher.bat\" \"%1\""
Here in the last line, add the full path to your launcher.bat file. Note the \\ in the path.
Rename this file to ms-openlocalfile.reg and double-click it to register it.
Then, go back to your Base formula, and add html('<a href="ms-openlocalfile:' + path + '">▶ Play Video</a>'). You need to add your own property. It may not be path like mine and you can change▶ Play Video if it’s not a video file, of course.
Done.