Open DivineDominion opened 2 years ago
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.
@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 :)
I would rather just move the file and hide this technical detail to the user. So the user just sees the moved page.
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.
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.md
is not found, look for /subdir.md
and display that instead?
Yes: If /subdir/index.md
is not found, look for /subdir.md
and display that instead.
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.
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.
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:
/subdir
and edit it. This creates/subdir.md
(in the articles directory of Slim Wiki of course)/subdir
into an overview with links to/subdir/detail
. Follow that link and create that page. This creates/subdir/detail.md
./subdir
-- it says the page doesn't exist.The file tree at that point is:
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?