-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Make local file:... links navigate to the relevant file #307
Conversation
I looked at writing tests for this, but got completely confused by the large chunk of test code duplicated between two files. Here is just a small subset of the duplication: organice/src/lib/parse_org.unit.test.js Lines 104 to 124 in 591b13c
vs. organice/src/components/OrgFile/OrgFile.unit.test.js Lines 233 to 255 in 591b13c
What's going on here? |
I'm confused, too. I remember that I wrote many of these tests. But I certainly did not duplicate this code. As far I remember, I worked mostly in parse_org.unit.test.js. Is the second one some auto-generated artifact? I can check the commit history later... |
Good catch on the duplication of tests. Complete duplications can definitively go. Feel free to pick and chose the correct location depending on the context of the test. |
@munen commented on May 29, 2020 3:43 PM:
I don't really know enough about the tests yet to make the call on this 🤔 |
Sweet addition. It works well for me on a first try! Apart from the duplication of the tests, do you plan to write an integration test for this? |
Duplication fixed in #309. I'll look at writing a test on top of that PR. |
Make a link like [[file:foo/bar.org][bar]] into href="foo/bar.org" without target="_blank", so that it opens in the same organice window. This allows more convenient navigation around a network of .org files, and in particular an index.org file which facilitates quick jumping to the most commonly used other .org files.
New version pushed with integration test. |
Nice! How should Organice handle non-org file links? I think I didn't see a test like What does Organice do, if we try to open a non-org file? |
@aspiers (cc @schoettl): I deeply apologize, but I have merged this PR too eagerly without proper testing. After merging, I found multiple bugs immediately with using my main Org files (which have file links). I have opened an issue for that: #311 Tbh, the three bugs I found should all have been merge blockers. Of course it's on me, that I didn't test properly. But if we can't fix those soon, I'm inclined to revert the merge. It's very easy to get organice into a broken state with the current implementation. And, on I'm afraid the implementation would have to be changed to:
Of course, there might be other options to implement this feature. I'm just writing this solution down here, because that's how I envisioned the feature before. Since it's not trivial, I haven't gotten around to building it. |
The new logic for rendering file: links introduced by 200ok-ch#307 had a number of issues: - It created links for absolute paths, which does not make sense since there is no fully general mapping between the filesystem and any of the sync backends. - It created links for relative paths pointing outside the backend (e.g. ../../../../foo.org), - It used <a href="..."> rather than <Link to=...>, which meant the PWA treated them as external links. So create a <Link> for relative file: paths pointing to .org files, don't link other file: paths, and render all other links with <a ...> as before. Fixes 200ok-ch#311.
The new logic for rendering file: links introduced by 200ok-ch#307 had a number of issues: - It created links for absolute paths, which does not make sense since there is no fully general mapping between the filesystem and any of the sync backends. - It created links for relative paths pointing outside the backend (e.g. ../../../../foo.org), - It used <a href="..."> rather than <Link to=...>, which meant the PWA treated them as external links. So create a <Link> for relative file: paths pointing to .org files, don't link other file: paths, and render all other links with <a ...> as before. Fixes 200ok-ch#311.
The new logic for rendering file: links introduced by 200ok-ch#307 had a number of issues: - It created links for absolute paths, which does not make sense since there is no fully general mapping between the filesystem and any of the sync backends. - It created links for relative paths pointing outside the backend (e.g. ../../../../foo.org), - It used <a href="..."> rather than <Link to=...>, which meant the PWA treated them as external links. So create a <Link> for relative file: paths pointing to .org files within the backend, and render all other links with <a ...> as before, but converting any file: prefix into a file:// prefix as a best effort to keep the links working (in the case of absolute paths which may exist on the local filesystem), or at least to show the user the intention behind the link. Fixes 200ok-ch#311.
Make a link like
[[file:foo/bar.org][bar]]
intohref="foo/bar.org"
withouttarget="_blank"
, so that it opens in the same organice window. This allows more convenient navigation around a network of.org
files, and in particular anindex.org
file which facilitates quick jumping to the most commonly used other.org
files.