Skip to content
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

Allow relative URLs in bottom bar #71

Closed
CosmicToast opened this issue Aug 18, 2020 · 4 comments · Fixed by #72
Closed

Allow relative URLs in bottom bar #71

CosmicToast opened this issue Aug 18, 2020 · 4 comments · Fixed by #72
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@CosmicToast
Copy link
Contributor

Consider an index.gmi that exposes some subdirectories but not others (e.g a ./hidden link that's not in index.gmi).
(There are many such use-cases, such as leaving the door open to people with the link, or simply not wanting to have a directory exposed in the index, since most viewers will not care about it.)

In the current scenario, as far as I can tell, the only way to navigate to it is to type out the entire current prefix followed by /hidden, but the current path may be long.
It would be nice if one could type ./hidden in the bottom bar, and (if the current url is a real one) the resolution happens internally.

I notice that amfora already has this for link handling (followLink), but URL() specifically wants absolute paths.

There's a couple of ways I can think of implementing this, but the calls are kind of all over the place.
Could this feature be added for convenience's sake?
I think a "good enough" heuristic should be if the first character of the bottom bar is "." - this way the method can also take care of handling ".." (but also further, things like "../otherdir").

@makew0rld makew0rld added enhancement New feature or request good first issue Good for newcomers labels Aug 18, 2020
@makew0rld
Copy link
Owner

This is a good feature, and should be easy to implement. I've thought about how I want this myself, just never made an issue for it. This will be added, thanks! Likely by v1.6.0.

@CosmicToast
Copy link
Contributor Author

Please poke me whenever the commit is made (or you decide what path you want to take towards implementing it, so I can give it a shot in a way that doesn't conflict with how you want the project to work (all variants I can think of would change multiple parts of the project)).
I'll rebuild amfora (my bin bucket is HEAD-only) and that should give users a binary to test even pre-release :)

@makew0rld
Copy link
Owner

Basically change these lines to support any path starting with a dot, and use ResolveReference from the net/url package to get an absolute URL to provide to URL. You could also turn that into a function, but I suspect adding this will not increase the LOC in that section, so you can just leave it there.

Feel free to take a shot!

@makew0rld makew0rld changed the title allow relative URLs in bottom bar Allow relative URLs in bottom bar Aug 18, 2020
@CosmicToast
Copy link
Contributor Author

CC - done
was a bit sick so I didn't notice the comment (on how you wanted it done) until now :)
net +/- is actually in the - (6+/15-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants