aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2026-02-05 12:40:57 +1000
committeronefang2026-02-05 12:40:57 +1000
commitdc810e9fa3a08552d9ea1e949970d4da34b21ab0 (patch)
treeb2e5b2348678f6d6559acb13d8f8dab6f2c043f5
parentWhitespace++ (diff)
downloadnotYetAnotherWiki-dc810e9fa3a08552d9ea1e949970d4da34b21ab0.zip
notYetAnotherWiki-dc810e9fa3a08552d9ea1e949970d4da34b21ab0.tar.gz
notYetAnotherWiki-dc810e9fa3a08552d9ea1e949970d4da34b21ab0.tar.bz2
notYetAnotherWiki-dc810e9fa3a08552d9ea1e949970d4da34b21ab0.tar.xz
More polygLua conversions.
-rwxr-xr-xnotYetAnotherWiki.lua32
1 files changed, 7 insertions, 25 deletions
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index f082eba..fb581e3 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -46,25 +46,6 @@ end
46--------------------------------------------------------------------------------- 46---------------------------------------------------------------------------------
47-- Useful functions, part 0. 47-- Useful functions, part 0.
48 48
49-- A simple table.subtable = subtable wont work, you end up with a reference so that changes to the later get applied to the former.
50local derefiTable = function(t, strip)
51 local argh = {}
52 for l, y in ipairs(t) do if (l ~= y.name) and strip then table.insert(argh, y) end end
53 return argh
54end
55local derefTable = function(t, strip)
56 local argh = {}
57 for l, y in pairs(t) do argh[l] = y end
58 return argh
59end
60
61
62local writeString = function(base, body)
63 local a, e = io.open(base, 'w')
64 if nil == a then print('Could not open ' .. base .. ' - ' .. e) else
65 a:write(body)
66 a:close()
67 end
68end 49end
69 50
70 51
@@ -314,7 +295,7 @@ os.execute('cp ' .. l .. ' ' .. l .. '_ORIGINAL0')
314 h = io.open(l, 'r') 295 h = io.open(l, 'r')
315 if nil ~= h then 296 if nil ~= h then
316 local body = h:read('*a') ; h:close() 297 local body = h:read('*a') ; h:close()
317writeString(l .. '_ORIGINAL1', body) 298_.string2file(body, l .. '_ORIGINAL1')
318 if 'Foswiki' == l:sub(1, 7) then 299 if 'Foswiki' == l:sub(1, 7) then
319 -- Strip out the actual content. 300 -- Strip out the actual content.
320 local beg, en = RE.find(body, [['<div id="patternMainContents">']]) if nil ~= beg then body = body:sub(en + 1) end 301 local beg, en = RE.find(body, [['<div id="patternMainContents">']]) if nil ~= beg then body = body:sub(en + 1) end
@@ -390,7 +371,7 @@ writeString(l .. '_ORIGINAL1', body)
390]=] 371]=]
391 end 372 end
392 373
393 writeString(l .. '_NEW', body) 374 _.string2file(body, l .. '_NEW')
394 elseif 'PmWiki' == l:sub(1, 6) then 375 elseif 'PmWiki' == l:sub(1, 6) then
395 local beg, en = RE.find(body, [['<!--PageText-->']]) if nil ~= beg then body = body:sub(en + 2) end 376 local beg, en = RE.find(body, [['<!--PageText-->']]) if nil ~= beg then body = body:sub(en + 2) end
396 beg, en = RE.find(body, [["div id='wikitext'>"]]) if nil ~= beg then body = body:sub(en + 2) end 377 beg, en = RE.find(body, [["div id='wikitext'>"]]) if nil ~= beg then body = body:sub(en + 2) end
@@ -448,7 +429,7 @@ writeString(l .. '_ORIGINAL1', body)
448--if nil ~= en then D('HTM1 ' .. body:sub(beg, en + 84) .. ' \t\t') end 429--if nil ~= en then D('HTM1 ' .. body:sub(beg, en + 84) .. ' \t\t') end
449 end 430 end
450 431
451 writeString(l .. '_NEW', body) 432 _.string2file(body, l .. '_NEW')
452 end 433 end
453 end 434 end
454 435
@@ -635,7 +616,8 @@ end
635local Bdy = '# All the pages\n\n| page | original page | last edited UTC | \n| --------- | ------- | --------------- | ' 616local Bdy = '# All the pages\n\n| page | original page | last edited UTC | \n| --------- | ------- | --------------- | '
636Pages = {} 617Pages = {}
637for name, file in pairs(Files) do 618for name, file in pairs(Files) do
638 local metadata = derefTable(Files[name].metadata, true) 619-- FIXME - don't think the deref is needed here, metedata isn't changed.
620 local metadata = _.derefTable(Files[name].metadata)
639 if ('everything' ~= name) then 621 if ('everything' ~= name) then
640 local ln, fw, pw, ts = 'DUNNO', '', '', '' 622 local ln, fw, pw, ts = 'DUNNO', '', '', ''
641 local title, link = whichWiki(metadata) 623 local title, link = whichWiki(metadata)
@@ -864,7 +846,7 @@ local Parse = Lunamark.reader.markdown.new(Writer, LunamarkOpts)
864--------------------------------------------------------------------------------- 846---------------------------------------------------------------------------------
865-- Loop through the files we found and actually create their HTML files. 847-- Loop through the files we found and actually create their HTML files.
866for name, file in pairs(Files) do 848for name, file in pairs(Files) do
867 local body, metadata = Files[name].body, derefTable(Files[name].metadata, true) 849 local body, metadata = Files[name].body, _.derefTable(Files[name].metadata)
868 local bits, bit = Files[name].bits, Files[name].bit 850 local bits, bit = Files[name].bits, Files[name].bit
869 local ln = #bits 851 local ln = #bits
870 local result = '' 852 local result = ''
@@ -1000,8 +982,8 @@ for name, file in pairs(Files) do
1000 982
1001 -- Write the file. 983 -- Write the file.
1002 if '' ~= result then 984 if '' ~= result then
1003 writeString(name .. '.HTML', result)
1004-- D('From ' .. name .. '.md -> ' .. base) 985-- D('From ' .. name .. '.md -> ' .. base)
986 _.string2file(result, name .. '.HTML')
1005 end 987 end
1006 end 988 end
1007end 989end