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

Traversing subdirectories #16

Open
daenney opened this issue Jan 2, 2023 · 4 comments
Open

Traversing subdirectories #16

daenney opened this issue Jan 2, 2023 · 4 comments

Comments

@daenney
Copy link
Contributor

daenney commented Jan 2, 2023

First off, thanks for legit, it's rather neat!

I was looking at how to make it support traversing subdirectories and so far I have the necessary infrastructure in place that would let me do this, including being able to limit the recursion depth.

The problem I'm running into is flow and its URL path handling:

mux.HandleFunc("/:name", d.Multiplex, "GET", "POST")

Unsurprisingly, /:name only captures a single segment. But when you have subdirectories you need either /:parent/:name or /:name. If I can assume there's only max 1 parent this can be solved without much trouble. But if there's a desire to allow for an arbitrary path depth it becomes problematic as the wildcard ... can only be used once and only at the end of a path. I'm not sure how to consume multiple path segments.

I'm wondering if you've given any thought around how to solve this?

@icyphox
Copy link
Owner

icyphox commented Jan 3, 2023

Thanks!

I have indeed been thinking about this (or rather, something adjacent to this) for a bit. I was looking to implement "directories as categories", similar to cgit's section-from-path configuration option. Essentially, if you've got a tree that looks like:

repos/
├── category1/
│   ├── foo
│   └── bar
└── category2/
    ├── baz
    └── ...

they'd then show up under those respective subheadings in the repo index. A visual example for what I'm describing can be seen in this cgit instance: https://git.peppe.rs (notice "cli", "config", ...).

With that preface out of the way,

If I can assume there's only max 1 parent this can be solved without much trouble.

this is a fair assumption. Having one level of traversal was also what I had in mind for the above feature.

@lillian-b
Copy link

lillian-b commented Mar 30, 2024

I have a basic implementation of "directories as categories", but it doesn't work well with also having top-level repositories.
Right now my implementation (here, links are broken except from index) uses _ in url to denote a repo in the root folder - but that's not a very clean solution.

cgit does support this mode of displaying repositories, but from what I can tell, it does not actually traverse subdirectories and rather is just a per-repo configuration in cgitrc.

If anyone has an idea of how to implement this (I did try simply having both /{pre}/{name} and /{name} endpoints registered, but they conflicted), I'm happy to do the implementation work.

@icyphox
Copy link
Owner

icyphox commented Mar 30, 2024

Hi, so there's an existing PR that implements category support but in its current state it breaks clones. I haven't quite figured out how to make it work but perhaps it might serve as a starting point?

@lillian-b
Copy link

I'll take a look at that, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants