require('strict')local p = local data = mw.loadData('Module:MasterGunner/data')local getArgs = require('Module:Arguments').getArgs-- South African Master Gunner Data-- Data Fields-- Code: This is just a duplicate of the lookup code, but expressed as a number instead of a string-- Rank: Person's rank. Not wikilinked--- FirstName: Initials or first name(s)-- Surname: Person's Surname-- Year: Year appointed Master Gunner-- WikiPage: If the person has a Wiki article, name of the article here-- PostNoms: list of Post Nominal Titles. Stored in Lua table format ie Curly braces with values seperated by commas-- Post: The name of the post that they held when awarded. Commas will be turned into line breaks-- Note: Any additional info about this Gunner.-- RecipCat: Category for recipients. "List of Master Gunners (South Africa)"
function p.Gunner(frame) local output = local templateArgs = getArgs(frame) local gunnercode = templateArgs["code"] or nil -- local pagename=templateArgs["pagename"] or nil if not gunnercode then output = '
Error: No code specified' return output end if data[gunnercode] then output = output .. gunnercode .. ": " output = output .. data[gunnercode].Code .. " Master Gunner" .. "function p.GunnerBox(frame) local output = local templateArgs = getArgs(frame) local gunnercode = templateArgs["code"] or nil local imagesize = templateArgs["imagesize"] or '150px' if not gunnercode then output = '
Error: No "code" specified. Use the Gunner number preceded by an A for example, code=A100' return output endif data[gunnercode] then -- Send Info -- Generate wiki table code for the Master Gunner
local float = templateArgs.float or 'none' if float
"right" then float = "floatright" elseif float
local tableCode = '
-\n" tableCode = tableCode .. '!colspan=2 style="background:red; color:white;" | Master Gunner: ' .. data[gunnercode].Code .. '\n' tableCode = tableCode .. " | -\n" tableCode = tableCode .. " | border|" .. imagesize .. "|link=List of badges of the South African Army#Proficiency: Master Gunner|Master Gunner\n" tableCode = tableCode .. " | -\n" tableCode = tableCode .. " | " .. p.GetGunner("A" .. data[gunnercode].Code) if string.len(data[gunnercode].Post) > 1 then tableCode = tableCode .. mw.getCurrentFrame:expandTemplate end if string.len(data[gunnercode].Note) > 1 then tableCode = tableCode .. mw.getCurrentFrame:expandTemplate end tableCode = tableCode .. "\n" tableCode = tableCode .. " | -\n " tableCode = tableCode .. " | Year ".. data[gunnercode].Year .. "\n" tableCode = tableCode .. " | -\n" local prevgunner="A" .. data[gunnercode].Code -1 .. "" tableCode = tableCode .. " | ←" .. data[gunnercode].Code -1 .. ": " .. p.GetGunner(prevgunner) .. "\n" local nextgunner="A" .. data[gunnercode].Code +1 .."" tableCode = tableCode .. " | " .. p.GetGunner(nextgunner) .. " :".. data[gunnercode].Code +1 .. "→\n" tableCode = tableCode .. " |
function p.GunnerTable(frame) -- Data Fields-- Code: This is just a duplicate of the lookup code, but expressed as a number instead of a string-- Rank: Person's rank. Not wikilinked--- FirstName: Initials or first name(s)-- Surname: Person's Surname-- Year: Year appointed Master Gunner-- WikiPage: If the person has a Wiki article, name of the article here-- PostNoms: list of Post Nominal Titles. Stored in Lua table format ie Curly braces with values seperated by commas-- Post: The name of the post that they held when awarded. Commas will be turned into line breaks-- Note: Any additional info about this Gunner.-- RecipCat: Category for recipients. "List of Master Gunners (South Africa)" local output = local templateArgs = getArgs(frame) local localfloat = templateArgs["float"] or if not localfloat then localfloat = "left" -- NOTE TODO: Make the table float according to the value of locafloat ;-) end local tableCode = '
-\n" tableCode = tableCode .. "! Code | Number | Rank | Surname | First Names | Post | Year | Note \n" -- Iterate through the data in the table "GunnerData" for code, record in pairs(data) do -- Generate wiki table code for the Master Gunner -- TODO: If record.Surname "Unknown" make the row distinctive somehow. tableCode = tableCode .. " | -\n" tableCode = tableCode .. " | " ..code .. "\n" tableCode = tableCode .. " | " .. record.Code .. "\n" tableCode = tableCode .. " | " .. record.Rank .. "\n" if string.len(record.WikiPage) < 1 then tableCode = tableCode .. " | " .. record.Surname else tableCode = tableCode .. " | " .. "" .. record.Surname .. "" end -- if string.len(record.Post)>1 then -- tableCode = tableCode .. mw.getCurrentFrame:expandTemplate -- end tableCode = tableCode .. "\n" tableCode = tableCode .. " | " .. record.FirstName .. "\n" tableCode = tableCode .. " | " .. string.gsub(record.Post, ",", " - ") .. "\n" tableCode = tableCode .. " | " .. record.Year .. "\n" tableCode = tableCode .. " | " .. record.Note .. "\n" end tableCode = tableCode .. " |
---|
return p-- Initial Code by John Dovey (13 April 2023)