From 2eaee0eba05a703234563417d674bc2e4a7b4e96 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Sun, 16 Mar 2025 13:33:44 +1000 Subject: Deal with complex directory trees. Just do the simple thing, drop a file in it so it's not empty. --- TODO.md | 8 -------- notYetAnotherWiki.lua | 13 +++++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/TODO.md b/TODO.md index dc5a44b..0b47dd4 100644 --- a/TODO.md +++ b/TODO.md @@ -17,14 +17,6 @@ Fix up linky conversion. DONE, mostly. - . Loop through the manually placed symlinks, adjusting "real URL" as we go. - + What to do about mulitple symlinks pointing to the same page? Compare timestamps, most recent wins. -Deal with complex directory trees. - -- /testing/even should display as even/deeper on the testing page, coz even/ has no files, but even/deeper does. -- On the other hand, I could just create an empty page with the sub directories shown as usual. -- Scanning /usr/share/doc on my super desktop with looots of software installed will be fun. -- On the gripping hand, this is where we want empty directories to vanish. -- SOOOOOOO don't show empty directories, but show their subs that have content, even if that sub is deep, but as per usual stop once we find a sub on that branch. EEEEW branches. - ## Some ideas diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index e84e9b0..53e3682 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua @@ -430,6 +430,19 @@ for name, file in pairs(Files) do end end +-- Find empty subs. +for name, sub in pairs(Subs) do + if 0 == #sub.files then + print("EMPTY " .. name) + h = io.open(name .. '/index.md', 'w') + if nil ~= h then + h:write('This directory has no files.') + h:close() + else + print("Can't open " .. name .. '/index.md for writing.') + end + end +end --------------------------------------------------------------------------------- -- cgit v1.1