Linbreux / wikmd

A file based wiki that uses markdown
https://linbreux.github.io/wikmd/
MIT License
326 stars 37 forks source link

Directory Listings Missing First Character #79

Open sqshr opened 1 year ago

sqshr commented 1 year ago

Hello, I have observed that when listing files (and clicking the subsequent links), the first character of the top level directory is missing. As a written example:

with Wiki as the root, when you click "List all pages" you see:

These files are contents searchable- so it's not a wiki wide issue. I've had a look to try and work it out, but couldn't see where in the code the issue was (apologies). When listing all pages, the wiki doesn't throw out any errors. When you click one of the bad links you get the below error in the log:

FileNotFoundError: [Errno 2] No such file or directory: '/home/sqshr/Wiki/echnical/Cisco.md'

I know this error isn't useful for the above issue (hence omitting the Traceback)- but want to show willing :)

Thanks!

sqshr commented 1 year ago

Ok, so- I've looked a little more. I think the issue comes from line 123 onwards in wiki.py

folder = root[len(cfg.wiki_directory + "/"):]

If I remove the + "/" from lines 123, 128, and 132- it seems to solve the problem. In a quick look round I couldn't see any ill effects elsewhere- but I'm not confident to state that for a fact!

Oliver-Hanikel commented 1 year ago

list_wiki seems overall a bit janky. Instead of operating on strings we could use paths. This would make the code more resilient to edge cases like this one. It would probably make the code more readable too.

As a quick fix: If you have the wiki directory configured with a trailing slash then drop it.