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

For missing /subdir/index.md fall back to /subdir.md if it exists? #16

Open
DivineDominion opened this issue Feb 16, 2022 · 8 comments
Open

Comments

@DivineDominion
Copy link
Contributor

When a less tech-savvy friend for whom I set up Slim Wiki encountered how subfolders work, he was confused by the fact that old pages were forgotten. Here's a procedure description so you see what I mean:

  • Navigate to non-existing page at /subdir and edit it. This creates /subdir.md (in the articles directory of Slim Wiki of course)
  • Transform /subdir into an overview with links to /subdir/detail. Follow that link and create that page. This creates /subdir/detail.md.
  • Go back to the overview URL at /subdir -- it says the page doesn't exist.

The file tree at that point is:

├── index.md
├── subdir
│   └── detail.md
├── subdir.md

So when you browse /subdir, Slim Wiki says the file is missing because it's looking for /subdir/index.md in the file system.

In that case, I would suggest to either fall-back to the overshadowed /subdir.md, or recognize this special case and offer to move /subdir.md to /subdir/index.md with the click of a button. The latter is not as magical, but probably more robust because the editor doesn't need to change file lookup routines.

To the end user, it appears that the content at /subdir is lost. But you have to change the file into a directory index file and then everything's alright. At the moment, though, this is rather panic inducing for organically growing wiki users :)


@til-schneider What do you think about this?

@til-schneider
Copy link
Owner

I think, moving /subdir.md to /subdir/index.md would be best. This way, the file system doesn't end up in several directories which handle this differently, just because they happend to be created the one or the other way.

@DivineDominion
Copy link
Contributor Author

@til-schneider Do you fancy any particular way to implement this? I'd suggest showing a different placeholder text than "this page doesn't exist":

Found a file with a similar name at `/subdir.md` that is overshadowed by this directory.
You can move that file into this directory as `/subdir/index.md`.

[Import file as directory index]

And when you click the button, well, it'll move the file :)

@til-schneider
Copy link
Owner

I would rather just move the file and hide this technical detail to the user. So the user just sees the moved page.

@til-schneider
Copy link
Owner

til-schneider commented Feb 16, 2022

Oh, wait! Doesn't this break all the relative links?

If yes, we should probably keep the /subdir.md file and detect this case when looking up the page.

@DivineDominion
Copy link
Contributor Author

Right -- It would break any link where the optional file suffix .md is used! I didn't realize that this even works to disambiguate the paths. Neat, so the file is still accessible.

So: if /subdir/index.mdis not found, look for /subdir.md and display that instead?

@til-schneider
Copy link
Owner

Yes: If /subdir/index.md is not found, look for /subdir.md and display that instead.

@til-schneider
Copy link
Owner

I'm still not quite sure whether relative links are an issue or not... In the end both /subdir/index.md and /subdir.md will get the same URL /subdir, right? So relative links should work just the same? I think this needs some testing first.

@DivineDominion
Copy link
Contributor Author

Relative links are resolved as absolute paths before the file is read when the GET request is being made, so at that point we should be able to have a canonical way to make this decision.

I played around with the code a bite (see PR's :)) and will be taking a jab at implementing this next week or so.

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

2 participants