ransome1 / sleek

todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)
https://github.com/ransome1/sleek/wiki
MIT License
1.46k stars 113 forks source link

Link to and open local files by recognising system file protocols #360

Closed Bumpyride closed 9 months ago

Bumpyride commented 2 years ago

Did you check if a similar feature request has already been reported? I did check and relevant comments/comparisons are included below

Is your feature request related to a problem? Please describe. Not related to a problem

Describe the solution you'd like Sleek already supports the HTTP/HTTPS and sendto: protocols automatically, so that including a URL string or an email address in the todo text line will then show the link symbol next to it. Obviously, clicking on the symbol then opens the web page in the browser or a new email.

It would be really practical if in addition, Sleek could be extended to recognise something like a file: protocol where the link then opens a local file with its associated program (according to file ext). I imagine that the implementation could follow along the lines of the due: or rec: syntax, perhaps something like file:c:\mydir\myfile.pdf or file:"c:\mydir\file name with spaces.txt", or file:/home/me/myfile.pdf under Linux/MacOS. As a bonus, if the file does not exist, activating the link could open the associated program with a blank document.

This enhancement would probably also take care of feature request Notes for tasks #338 without using exernal dependencies. A note is simply a file linked to from Sleek.

Describe alternatives you've considered A good example would be Typora, a Markdown editor.
Its syntax uses angle brackets \file://myfile.ext\ or links [](file://file with spaces.ext).

mimmori commented 2 years ago

+1

mshuflin commented 2 years ago

+1 for this. Another example is Joplin, which uses this syntax joplin://x-callback-url/openNote?id=x1234567a

comminutus commented 2 years ago

+1 for this, as @mshuflin mentioned I'd also use it for joplin links.

ransome1 commented 2 years ago

Unfortunately I don't have enough time to work on this at the moment. If any of you guys have knowledge in JavaScript and especially regular expressions, you can take a look at the library sleek uses, that converts the markdown into HTML. It's called marked.js and has built in extensibility. If someone can figure out, how to extend marked.js to support prefixes as file or joplin, I am happy to implement the solution.

Bumpyride commented 2 years ago

I just went under the hood of draw.io for a similiar use case. It turns out that it may be security settings preventing access to local file system. I'll fork this repo and see what I can do. BTW, thanks for the recent updates and a great little program!

github-actions[bot] commented 1 year ago

This is an automated response. We acknowledge your report, and we appreciate your engagement. However, as there has been no recent activity in this thread, it has been marked as stale. If you have any further feedback or if the matter is still relevant, please do not hesitate to respond. Otherwise, this thread will be automatically closed in 15 days from now.

mshuflin commented 1 year ago

Still an issue

On Mon, Aug 7, 2023, 7:36 PM github-actions[bot] @.***> wrote:

This is an automated response. We acknowledge your report, and we appreciate your engagement. However, as there has been no recent activity in this thread, it has been marked as stale. If you have any further feedback or if the matter is still relevant, please do not hesitate to respond. Otherwise, this thread will be automatically closed in 15 days from now.

— Reply to this email directly, view it on GitHub https://github.com/ransome1/sleek/issues/360#issuecomment-1667693157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM336IHLPKOROV2FJAYGOALXUDHNBANCNFSM5SXUMNUA . You are receiving this because you were mentioned.Message ID: @.***>

mshuflin commented 1 year ago

in Sleek 1.x, we could use markdown to make this happen, for example:

[link to note](joplin://x-callback-url/openNote?id=x1234567a)

In 2.x it appears it is not implemented yet

mshuflin commented 10 months ago

I wonder, would this and #563 both be solved by implementing marked as mentioned here?

ransome1 commented 10 months ago

I wonder, would this and #563 both be solved by implementing marked as mentioned here?

@mshuflin I think it does solve both. I already tried to implemented but had to realize, that the way the we are creating the rows in sleek is not compatible with how marked works. It will take quite some time to figure this out. That's why I decided to dedicate my time on other tasks, mostly bugfixing and refactoring. I will keep you guys posted, once this topic is being picked up again.

ransome1 commented 10 months ago

@mshuflin @comminutus @Bumpyride @mimmori, the most recent pre-release now incorporates link detection and offers basic support for protocols beyond HTTPS.

Conventional links like http://www.test.com are now recognized, along with Markdown links such as <http://www.test.com> or [Test](https://www.test.com).

Links to the file system function should work like <file:///Users/USERNAME/Desktop/file.txt>. The same applies to Joplin links: <joplin://x-callback-url/openNote?id=x1234567a>.

Further adjustments might be made to support different protocol links without requiring brackets or full Markdown syntax in upcoming releases.

Feel free to experiment with it and share your feedback on what works and what doesn't: https://github.com/ransome1/sleek/releases/tag/v2.0.9-rc.1

mshuflin commented 10 months ago

thanks for implementing this. Based on my testing,

what works:

what does not work:

Overall, I think it is working as expected.

(in case it matters, Macos sonoma (M2), sleek v2.0.9-rc.1)

Bumpyride commented 10 months ago

Thanks for implementing from me, too. I can pretty much confirm what @mshuflin discovered, except that I didn't test Markdown text formatting.

I focused on the original issue, namely linking to local files, and I could only get the angle brackets "<>" with the "file://" protocol to work (under Windows 10), for example: <file://C:\mydir\myfile.pdf> BTW, it does not seem to matter if two or three forward slashes follow the protocol.

However, Markdown links like [My file](file://C:\mydir\myfile.pdf) do not work with local files. It will show "My file" as a link label (standard Markdown) but will not open the file. Links to local files are now possible but it would be nice to be able to display a friendly label for the link.

Local file names that include spaces, for example "c:\mydir\file name with spaces.txt" do not work, regardless of protocol or link syntax, with or without quotes. I tried all sorts of variations.

Other protocols, like joplin://, cintanotes://, etc do work, provided the link is enclosed in angle brackets.

ransome1 commented 9 months ago

Local file names that include spaces, for example "c:\mydir\file name with spaces.txt" do not work, regardless of protocol or link syntax, with or without quotes. I tried all sorts of variations.

That is correct. It is not supported out of the box by upstream (react-markdown) and I don't see the benefit of adding more logic to sleek to cover each case. I think it is good enough to add the custom protocol in order to achieve this.

However, Markdown links like My file do not work with local files.

This should now work in this latest pre-release: https://github.com/ransome1/sleek/releases/tag/v2.0.9-rc.4

Other protocols, like joplin://, cintanotes://, etc do work, provided the link is enclosed in angle brackets.

I did not explicitely tested the cases of Joplin and Cintanotes, but I think if those applications are installed, the Markdown link as well as the link in brackets should trigger the applications.

skostojohn commented 4 months ago

I am having issues with links to local files (e.g. <file:///home/scott/file.txt> - they are recognized as links but don't seem to do anything when clicked. Using v2.0.14.

Web links and links to other apps (Obsidian) seem to work fine.

Anyone have ideas as to what I might be doing wrong, or seeing the same behavior?

Thanks! Scott