wikmd icon indicating copy to clipboard operation
wikmd copied to clipboard

Directory Listings Missing First Character

Open sqshr opened this issue 3 years ago • 2 comments

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:

  • Wiki/Technical/Cisco.md

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

  • echnical/Cisco

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 avatar Sep 27 '22 07:09 sqshr

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!

sqshr avatar Sep 27 '22 08:09 sqshr

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.

Oliver-Hanikel avatar Sep 29 '22 16:09 Oliver-Hanikel