Module:Top icon explained

-- This module implements

local categoryHandler = require('Module:Category handler').main

local p =

local function makeName(sort, body) local sortnum = tonumber(sort) if sortnum then -- Zero-pad numbers so that they will sort properly in alphabetical -- order. (Yes, there really are decimal sort keys used on enwiki.) sort = string.format('%07.2f', sortnum) end math.randomseed(os.clock * 1000000000) local ret = ret[#ret + 1] = sort -- There should always be a body value present. This will force numeric -- sort keys to sort alphabetically. ret[#ret + 1] = body -- Add a random number to stop names from duplicating others on a page ret[#ret + 1] = math.random(1, 100000) return table.concat(ret, '-')end

local function makeFileLink(t) local ret = ret[#ret + 1] = '' return table.concat(ret)end

local function renderCategories(args, title) local categories = categoryHandler return categories or end

function p._main(args, frame, title) frame = frame or mw.getCurrentFrame title = title or mw.title.getCurrentTitle local image = args.image or args.imagename if not image then error('no image name specified', 2) end local name = makeName(args.icon_nr or args.number, args.name or args.id or image ) local fileLink = makeFileLink local nowiki = frame:extensionTag local indicator = frame:extensionTag local categories = renderCategories(args, title) return nowiki .. indicator .. categoriesend

function p.main(frame) local origArgs = require('Module:Arguments').getArgs(frame,) -- Copy all the specified arguments over to minimise the number of times we -- have to access the frame object. local args = for k, v in pairs(origArgs) do args[k] = v end return p._main(args, frame)end

return p