local p =
--Similar to : make a piped link to a category, if it exists;--if it doesn't exist, just display the greyed link title without linkingfunction catlink(name, disp) name = mw.text.trim(name or ) disp = mw.text.trim(disp or ) local grey = '#888' local exists = mw.title.new(name, 'Category').exists if exists then return ''..disp..'' else return '
'..disp..'' endend--checks for existance & returns tracking if missingfunction checkparent(colon, name, sortkey) local exists = mw.title.new(name, 'Category').exists if not exists then return ''..sortkey..'' end return end
----Main --
function p.catnav(frame) local currtitle = mw.title.getCurrentTitle local namespace = currtitle.nsText local testcases = (currtitle.subpageText
nil then adj, civmilair = string.match(pagename, '^(.+) (military) aircraft$') --mil end if civmilair
nil then civmilair = string.match(pagename, '^(International) aircraft$') --int (special case) end if civmilair
'Category' or testcases then trackingcats[3] = '' end return table.concat(trackingcats) end local CivMilAir = civmilair:gsub("^%l", string.upper) --proceed according to category type local civmil = (civmilair ~= 'Aircraft' and civmilair ~= 'International') if civmil then --if DNE, find it via the title adjective if nation
) then for _, kv in pairs (countries) do if kv[2]
nil or (nation and nation
'International' then local basename = 'International aircraft' --static: no check/tracking needed if CivMilAir
'Civil' then parentcats[2] = '' else parentcats[2] = '' end elseif civmilair
nil or (nation and nation
'International' then parentcats[1] = '' --static: no check/tracking needed end local heading1 = CivMilAir..' aircraft' --assume civmil local heading2 = civmilair..' aircraft' --assume civmil if not civmil then heading1 = 'Aircraft' heading2 = 'aircraft' end local sep = ' • ' local catnav = '
-\n'.. ' | \n'.. ""..heading1.." by nationality of original manufacturer ".. 'International joint ventures ' for _, kv in pairs (countries) do local the_c = kv[1] local a = kv[2] local c = (string.gsub(the_c, '^the ', )) local basename = a..' '..civmilair..' aircraft' --assume civmil if not civmil then basename = 'Aircraft manufactured in '..the_c end catnav = catnav..catlink(basename, c)..sep end catnav = mw.text.trim(catnav, sep) catnav = catnav..'\n'.. ' |
return p