aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/notYetAnotherWiki.lua
diff options
context:
space:
mode:
Diffstat (limited to 'notYetAnotherWiki.lua')
-rwxr-xr-xnotYetAnotherWiki.lua40
1 files changed, 32 insertions, 8 deletions
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua
index dc64fa2..bddf63a 100755
--- a/notYetAnotherWiki.lua
+++ b/notYetAnotherWiki.lua
@@ -248,21 +248,45 @@ for name, file in pairs(Files) do
248 end 248 end
249end 249end
250 250
251
252
253-- Figure out the original title and link for the original wiki.
254-- This functions assume the above file and sub scan has completed.
255local whichWiki = function(metadata)
256 local title, link = '', ''
257 if 'PmWiki' == metadata.ogWiki then
258 title = '[' .. metadata.ogBase .. '.' .. metadata.ogFile .. ']'
259 link = '(' .. metadata.ogURL .. '/?n=' .. metadata.ogBase .. '.' .. metadata.ogFile .. ')'
260 end
261 if 'Foswiki' == metadata.ogWiki then
262 title = '[' .. metadata.ogBase .. '/' .. metadata.ogFile .. ']'
263 link = '(' .. metadata.ogURL .. '/' .. metadata.ogBase .. '/' .. metadata.ogFile .. ')'
264 end
265 return title, link
266end
267
268
251-- Create an "everything" page, for URL links to every file.HTML. 269-- Create an "everything" page, for URL links to every file.HTML.
252-- TODO - sort the list of pages.
253local bdy, h = Files['everything'].body, io.open('everything.md', 'a+') 270local bdy, h = Files['everything'].body, io.open('everything.md', 'a+')
254bdy = bdy .. '\n\n| page | converted | Foswiki | PmWiki | \n| ---- | --------- | ------- | ------ | ' 271bdy = bdy .. '\n\n| page | converted | original page | last edited UTC | \n| ---- | --------- | ------- | --------------- | '
272pages = {}
255for name, file in pairs(Files) do 273for name, file in pairs(Files) do
256 local metadata = derefTable(Files[name].metadata, true) 274 local metadata = derefTable(Files[name].metadata, true)
257 if 'everything' ~= name then 275 if 'everything' ~= name then
258 local ln, fw, pw = 'DUNNO', '', '' 276 local ln, fw, pw, ts = 'DUNNO', '', '', ''
259 if 'PmWiki' == metadata.ogWiki then pw = '[' .. metadata.ogURL .. '](' .. metadata.ogURL .. ')' end 277 local title, link = whichWiki(metadata)
260 if 'Foswiki' == metadata.ogWiki then fw = '[' .. metadata.ogURL .. '](' .. metadata.ogURL .. ')' end 278 if 'PmWiki' == metadata.ogWiki then pw = 'PmWiki ' .. title .. link end
279 if 'Foswiki' == metadata.ogWiki then fw = 'Foswiki ' .. title .. link end
280 if nil ~= metadata.timestamp then ts = metadata.timestamp end
261 if nil ~= file.bit then ln = file.bit 281 if nil ~= file.bit then ln = file.bit
262 end 282 end
263 bdy = bdy .. '\n| ' .. name .. ' | [' .. ln .. '](<' .. name .. '.HTML>) | ' .. fw .. ' | ' .. pw .. ' |' 283 table.insert(pages, '\n| ' .. name .. ' | [' .. ln .. '](<' .. name .. '.HTML>) | ' .. fw .. ' ' .. pw .. ' | ' .. ts .. ' |')
264 end 284 end
265end 285end
286table.sort(pages, function(a, b) return (string.lower(a) < string.lower(b)) end)
287for i, f in ipairs(pages) do
288 bdy = bdy .. f
289end
266h:write(bdy) 290h:write(bdy)
267h:close() 291h:close()
268toFile('everything', 'body', parse(bdy)) 292toFile('everything', 'body', parse(bdy))
@@ -330,7 +354,6 @@ local linkFrom = function(source, dest)
330end 354end
331 355
332 356
333
334-- More of this actually doing things nonsense. 357-- More of this actually doing things nonsense.
335 358
336-- Loop through Subs, doing whichPage and inheritance. 359-- Loop through Subs, doing whichPage and inheritance.
@@ -375,7 +398,8 @@ for name, file in pairs(Files) do
375 for m, x in pairs(globalData) do if nil == metadata[m] then metadata[m] = x end end 398 for m, x in pairs(globalData) do if nil == metadata[m] then metadata[m] = x end end
376 399
377 if nil ~= metadata.ogURL then 400 if nil ~= metadata.ogURL then
378 body = body .. '\n\n---\n\n[Original page](' .. metadata.ogURL .. '), maybe you can edit it.\n' 401 local title, link = whichWiki(metadata)
402 body = body .. '\n\n---\n\n[Original page]' .. link .. ', maybe you can edit it.\n'
379 end 403 end
380 404
381 -- Figure out this pages trail links. 405 -- Figure out this pages trail links.