Module:Sandbox/Jarble/World topics explained

p =

local Navbox = require("Module:Navbox")country =

function p.main(frame) local pframe = frame:getParent local config = frame.args local args = pframe.args return p._main(args)end

function p._main(args) if mw.title.getCurrentTitle

"Template:World topic" then state = "autocollapse" else state = args.state end if args[1] ~= nil or args.prefix ~= nil and (args[2]

nil or ags.suffix

nil) then titlemid = " the" end if args.title ~= nil then title = args.title else title = ""..(args[1] or args.prefix or "")..(titlemid or "").." World"..(args.suffix or "").."" end if args.group1 ~= nil and args.group1 ~= "" then group1 = args.group1 end local sorter = for n in pairs(country) do table.insert(sorter, n) end table.sort(sorter)

if args.noredlinks ~= nil then list1 = table.concat(noredlinks(args[1], args[2], args.prefix, args.suffix, sorter)) else list1 = table.concat(redlinks(args[1], args[2], args.prefix, args.suffix, sorter)) end local navarguments = return Navbox._navbox(navarguments)end

function noredlinks(args1, args2, argsprefix, argssuffix, sorter) local list = for x, y in pairs(sorter) do if mw.title.new((args1 or argsprefix or "").." "..linktarget(y, country[y][1])..(args2 or argssuffix or "")).exists

true then table.insert(list, li(""..y.."")) elseif y

"Georgia" then if mw.title.new((args1 or argsprefix or "").." "..y..(args2 or argssuffix or "")).exists

true then table.insert(list, li(""..y.."")) end end end return listend

function redlinks(args1, args2, argsprefix, argssuffix, sorter) local list = for x, y in pairs(sorter) do if y

"Georgia" then if mw.title.new((args1 or argsprefix or "").." "..country[y][1]..(args2 or argssuffix or "")).exists

true then table.insert(list, li(""..y.."")) else table.insert(list, li(""..y.."")) end else table.insert(list, li("".. y .. "")) end end return listend

function li(text) local li = mw.html.create("li") li :wikitext(text) :done return tostring(li)end

function linktarget(x, y) if y ~= nil and y

"" then return x else return y endend

return p