-
-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable serving local files and fix browser history #614
base: master
Are you sure you want to change the base?
Conversation
Currently when accessing /page/{bufnr} the browser history is modified to show /{bufnr}. This commit enables serving said /{bufnr} urls, so you can go back and forth in the browser history. This also fixes the page breaking if reloaded.
If no route matching the url is found, search the local computer for files matching the route.
bump |
1 similar comment
bump |
+1, I'd love to have this feature, especially useful if you use markdown as a second brain. I've implemented similar functionality on my own fork of Instant Markdown Preview, but this plugin is miles ahead - thanks for the good work. |
Is Instant Markdown Preview still actively maintained? |
Yes, it still is, though it uses mathjax, which is (or was) painfully slow to render long documents with lots of formulas, and that's a deal breaker for me. I use katex in my own branch. The other feature that may make me go back, is that beyond serving local files, I like for local markdown files to be automatically previewed, so you can essentially link them and jump from file to file (which is also a feature in my branch of instant markdown preview). |
Interesting, have you tried getting those features upstreamed with Instant Markdown Preview? Seems iamcco isn't maintaining this one anymore, and he is the only one with commit access. I've been speaking to a couple of previous users here who started Vivify, its a rewrite inspired by this project, they are accepting contributions if you wanted to try there. Otherwise you could make your own fork of this and see if anyone will follow. |
I'll certainly give a try to Vivify, thanks for making me aware of it! Instant markdown upstream has diverged too much from my own branch, as well as preferences, for me to consider contributing or requesting new features. Forking this project has crossed my mind, probably starting from this patch (your fork), and then implementing markdown rendering for linked files, but I'll test vivify first, I just love the idea. |
Take a look, see which would be easier to start as a base. Vivify already lets you browse and navigate through your local .md files but doesn't do instant "as you type" updates from vim (yet). Alternatively, if there is enough demand for it, I'm happy to host a fork of this, we could pull some of the PR's from here that are sitting dormant. I'm not super .js experienced, but i can project manage 😅 or we could do it on yours, i don't really mind. |
Sounds great, though, being honest with myself and not having a lot of time in hands atm, I'll wait and see where vivify heads to and. I may still take you up on your offer. I tested Vivify, and it actually does navigate as you type now, as long as it is focussed on the document that is being edited. It would be nice if it could change the document if another markdown buffer is entered in vim (which I implemented in my own branch of Instant Markdow). |
This was me, used a different GitHub account to post, sorry. |
Hey mate, No worries, you should be able to have both installed without any problems. You might want to also take a look at this discussion to see if that is what you are after: jannis-baum/Vivify#123 |
Cheers, I see that you were also already pushing for it! I added my 2 cents. |
Doesn't seem like it is going to be that hard to add. I'm going to help Jannis at least until that feature gets added, then I'd like to know your thoughts on whether or not you think it is worth trying to revive this project or to focus all energy on Vivify. |
Add a catchall to
routes.js
where just before serving a 404, it searches the local filesystem for any matching files.If the files are found, it serves them naively.
When scanning the local filesystem, it searches both the absolute path and the relative path, and
~/
is expanded to the user's home directory.Additionally, in order to make it more usable, enable URLs of the form
/{bufnr}
in addition to the current/page/{bufnr}
in order to restore working browser history, which broke in a79fc02. (If e.g. reloading the page, the URL currently saved in the browser history is not caught inroutes.js
).Fixes #492 and works towards #491 and #58 but not quite. Due to the files being served naively, the browser renders e.g. PDF files, but markdown files are just downloaded.