diff options
| author | dvs1 | 2025-03-27 09:47:22 +1000 |
|---|---|---|
| committer | dvs1 | 2025-03-27 09:47:22 +1000 |
| commit | f100e861884cb261bf0598215d3e7d8aba1f3f89 (patch) | |
| tree | 218ebc3aadc8eaef91ca88860131e0fa9c24acdc /notYetAnotherWiki.lua | |
| parent | Add the help page, link it to the help widget. (diff) | |
| download | notYetAnotherWiki-f100e861884cb261bf0598215d3e7d8aba1f3f89.zip notYetAnotherWiki-f100e861884cb261bf0598215d3e7d8aba1f3f89.tar.gz notYetAnotherWiki-f100e861884cb261bf0598215d3e7d8aba1f3f89.tar.bz2 notYetAnotherWiki-f100e861884cb261bf0598215d3e7d8aba1f3f89.tar.xz | |
directory -> folder
Let's be consistent, now we are using a folder icon.
Diffstat (limited to 'notYetAnotherWiki.lua')
| -rwxr-xr-x | notYetAnotherWiki.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index f12547a..0883d87 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
| @@ -215,10 +215,11 @@ else | |||
| 215 | print("Can't open everything.md for writing.") | 215 | print("Can't open everything.md for writing.") |
| 216 | end | 216 | end |
| 217 | 217 | ||
| 218 | -- Scan the subdirectories looking for our files. | 218 | -- Scan the sub folders looking for our files. |
| 219 | local Directory = arg[1] | 219 | local Folder = arg[1] |
| 220 | toSub('') | 220 | toSub('') |
| 221 | if nil == Directory then Directory = '.' end | 221 | if nil == Folder then Folder = '.' end |
| 222 | --GlobalMetaData.root = Folder | ||
| 222 | 223 | ||
| 223 | --[[ Sort out realURL for symlinked .md.md files. | 224 | --[[ Sort out realURL for symlinked .md.md files. |
| 224 | realURL is the generic URL part for this page. By policy it points to whatever is the latest copy / symlink of the original download .md.md. | 225 | realURL is the generic URL part for this page. By policy it points to whatever is the latest copy / symlink of the original download .md.md. |
| @@ -230,7 +231,7 @@ if nil == Directory then Directory = '.' end | |||
| 230 | For the "page moved" problem, that'll be the most recent symlink, the old one still has it's symlink pointing to the download .md.md, which gets updated with the current realURL. | 231 | For the "page moved" problem, that'll be the most recent symlink, the old one still has it's symlink pointing to the download .md.md, which gets updated with the current realURL. |
| 231 | So when some external old URL points to someplace a page used to be, it's old symlink points to the up to date download .md.md, and we know where to go to find the page now. | 232 | So when some external old URL points to someplace a page used to be, it's old symlink points to the up to date download .md.md, and we know where to go to find the page now. |
| 232 | ]] | 233 | ]] |
| 233 | for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md.md" -xtype l -printf "%P\n"'):lines() do | 234 | for l in io.popen('find -L ' .. Folder .. ' -name unsorted -prune -o -name "*.md.md" -xtype l -printf "%P\n"'):lines() do |
| 234 | local metadata = readMdMd(string.sub(l, 1, -4), {}) | 235 | local metadata = readMdMd(string.sub(l, 1, -4), {}) |
| 235 | if nil == metadata.realURL then | 236 | if nil == metadata.realURL then |
| 236 | metadata.realURL = string.sub(l, 1, -7) | 237 | metadata.realURL = string.sub(l, 1, -7) |
| @@ -256,7 +257,7 @@ for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "* | |||
| 256 | end | 257 | end |
| 257 | 258 | ||
| 258 | -- Clean up unsorted. | 259 | -- Clean up unsorted. |
| 259 | for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "*.md" -a -not -name "*.md.md" -xtype l -printf "%P\n"'):lines() do | 260 | for l in io.popen('find -L ' .. Folder .. ' -name unsorted -prune -o -name "*.md" -a -not -name "*.md.md" -xtype l -printf "%P\n"'):lines() do |
| 260 | local tp = '_fos' | 261 | local tp = '_fos' |
| 261 | local metadata = readMdMd(l, {}) | 262 | local metadata = readMdMd(l, {}) |
| 262 | if nil ~= metadata then | 263 | if nil ~= metadata then |
| @@ -273,7 +274,7 @@ for l in io.popen('find -L ' .. Directory .. ' -name unsorted -prune -o -name "* | |||
| 273 | end | 274 | end |
| 274 | 275 | ||
| 275 | -- Look for copied pages from the other wikis. | 276 | -- Look for copied pages from the other wikis. |
| 276 | for l in io.popen('find -L ' .. Directory .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do | 277 | for l in io.popen('find -L ' .. Folder .. ' -name "*.HTM" -type f,l -printf "%P\n"'):lines() do |
| 277 | -- Only do this if .HTM is newer than .md, or .md doesn't exist. | 278 | -- Only do this if .HTM is newer than .md, or .md doesn't exist. |
| 278 | local htime = io.popen("date -ur " .. l .. " +%s"):read('l') | 279 | local htime = io.popen("date -ur " .. l .. " +%s"):read('l') |
| 279 | local mtime = io.popen("date -ur " .. string.sub(l, 1, -4) .. "md +%s 2>/dev/null"):read('l') | 280 | local mtime = io.popen("date -ur " .. string.sub(l, 1, -4) .. "md +%s 2>/dev/null"):read('l') |
| @@ -424,14 +425,14 @@ writeString(l .. '_ORIGINAL1', body) | |||
| 424 | end | 425 | end |
| 425 | end | 426 | end |
| 426 | 427 | ||
| 427 | if '.' ~= Directory then | 428 | if '.' ~= Folder then |
| 428 | for l in io.popen('find -L . -name "*.md" -type f,l -printf "%P\n"'):lines() do | 429 | for l in io.popen('find -L . -name "*.md" -type f,l -printf "%P\n"'):lines() do |
| 429 | toFile(string.gsub(l, '%.md$', '')) | 430 | toFile(string.gsub(l, '%.md$', '')) |
| 430 | end | 431 | end |
| 431 | end | 432 | end |
| 432 | 433 | ||
| 433 | -- Can add in a distant directory to, for putting it's results in the current directory. | 434 | -- Can add in a distant folder to, for putting it's results in the current folder. |
| 434 | for l in io.popen('find -L ' .. Directory .. ' -name "*.md" -type f,l -printf "%P\n"'):lines() do | 435 | for l in io.popen('find -L ' .. Folder .. ' -name "*.md" -type f,l -printf "%P\n"'):lines() do |
| 435 | local n = string.gsub(l, '%.md$', '') | 436 | local n = string.gsub(l, '%.md$', '') |
| 436 | if nil == Files[n] then toFile(n) end | 437 | if nil == Files[n] then toFile(n) end |
| 437 | end | 438 | end |
| @@ -492,7 +493,7 @@ for name, sub in pairs(Subs) do | |||
| 492 | print("EMPTY " .. name) | 493 | print("EMPTY " .. name) |
| 493 | h = io.open(name .. '/index.md', 'w') | 494 | h = io.open(name .. '/index.md', 'w') |
| 494 | if nil ~= h then | 495 | if nil ~= h then |
| 495 | h:write('This directory has no files.') | 496 | h:write('This folder has no files.') |
| 496 | h:close() | 497 | h:close() |
| 497 | else | 498 | else |
| 498 | print("Can't open " .. name .. '/index.md for writing.') | 499 | print("Can't open " .. name .. '/index.md for writing.') |
| @@ -504,7 +505,7 @@ end | |||
| 504 | --------------------------------------------------------------------------------- | 505 | --------------------------------------------------------------------------------- |
| 505 | -- These functions assume the above file and sub scan has completed. | 506 | -- These functions assume the above file and sub scan has completed. |
| 506 | 507 | ||
| 507 | -- Which page in this directory should we show? | 508 | -- Which page in this folder should we show? |
| 508 | -- NOTE - only looking for the .md files we scanned for before, any stray HTML, html, HTM, and htm files will get ignored. | 509 | -- NOTE - only looking for the .md files we scanned for before, any stray HTML, html, HTM, and htm files will get ignored. |
| 509 | local whichPage = function(f) | 510 | local whichPage = function(f) |
| 510 | local fl = '' | 511 | local fl = '' |
| @@ -547,7 +548,7 @@ local whichWiki = function(metadata) | |||
| 547 | end | 548 | end |
| 548 | 549 | ||
| 549 | 550 | ||
| 550 | -- Calculate a link from the source directory to the destination directory. | 551 | -- Calculate a link from the source folder to the destination folder. |
| 551 | local linkFrom = function(source, dest) | 552 | local linkFrom = function(source, dest) |
| 552 | -- Evil hacks! | 553 | -- Evil hacks! |
| 553 | if 'Profiles' == dest then dest = 'PmWiki/Profiles' end | 554 | if 'Profiles' == dest then dest = 'PmWiki/Profiles' end |
