From 4490fb5ef230b97430b7597351e69036cebcca7d Mon Sep 17 00:00:00 2001 From: dvs1 Date: Fri, 14 Mar 2025 13:39:35 +1000 Subject: Fix up /Main/ and /bin/ linkies. --- notYetAnotherWiki.lua | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 33a9e32..9f543e2 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua @@ -629,6 +629,8 @@ local Writer = Lunamark.writer.html5.new(LunamarkOpts) local Context = {} -- Coz can't otherwise pass context through to the deeper Lunamark functions I'm overriding. local lunaLinky = function(url) -- Fix up the links. if ('https://wiki.devuan.org/' ~= url) and ('https://fos.wiki.devuan.org/' ~= url) then + -- TODO - This might be covering up a bug elsewhere. + if '/Main/' == string.sub(url, 1, 6) then url = 'https://fos.wiki.devuan.org/' .. url end for i, p in ipairs{'https://wiki.devuan.org/?n=', 'https://wiki.devuan.org?n=', 'PmWiki/uploads/', 'Foswiki/pub/', 'https://fos.wiki.devuan.org/'} do if p == string.sub(url, 1, #p) then local ur = string.sub(url, #p + 1) @@ -646,26 +648,28 @@ local lunaLinky = function(url) -- Fix up the links. end if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL end - local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)] - if nil == Context.path then - url = string.gsub(ur, '%.', '/', 1) - else - if nil == xlnk then xlnk = string.gsub(string.gsub(ur, '%..*', '', 1), '/.*', '', 1) end - if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end - if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end - if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end - if 'DUNNO/' == xlnk then print('OOPS! page not found - @' .. Context.path .. ' / ' .. Context.bit .. '\t' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end - end + if 'https://fos.wiki.devuan.org/bin/' ~= string.sub(url, 1, 32) then + local xlnk = xLinks[string.gsub(ur, '%..*', '', 1)] + if nil == Context.path then + url = string.gsub(ur, '%.', '/', 1) + else + if nil == xlnk then xlnk = string.gsub(string.gsub(ur, '%..*', '', 1), '/.*', '', 1) end + if '' ~= Context.path then xlnk = linkFrom(Context.path, xlnk) end + if '/' == string.sub(xlnk, 1, 1) then xlnk = string.sub(xlnk, 2) end + if ('' ~= xlnk) and ('/' ~= string.sub(xlnk, -1)) then xlnk = xlnk .. '/' end + if 'DUNNO/' == xlnk then print('OOPS! page not found - @' .. Context.path .. ' / ' .. Context.bit .. '\t' .. url .. ' -> ' .. xlnk .. ' ' .. string.gsub(ur, '.*%.', '', 1) .. '.HTML') end + end -- if (nil ~= md) and (nil ~= md.realURL) then url = md.realURL -- else url = xlnk .. string.gsub(ur, '.*%.', '', 1) -- end - if 'PmWiki/uploads/' == p then - url = '../' .. p .. string.gsub(ur, '%.', '.', 1) - elseif 'Foswiki/pub/' == p then - url = '../' .. p .. ur - else - url = url .. '.HTML' + if 'PmWiki/uploads/' == p then + url = '../' .. p .. string.gsub(ur, '%.', '.', 1) + elseif 'Foswiki/pub/' == p then + url = '../' .. p .. ur + else + url = url .. '.HTML' + end end end end -- cgit v1.1