Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:MasterGunner
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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 = '<span style="color:#d33">Error: No code specified</span>' return output end if data[gunnercode] then output = output .. gunnercode .. ": " output = output .. data[gunnercode].Code .. " Master Gunner" .. "<br />" output = output .. data[gunnercode].FirstName .. " " .. data[gunnercode].Surname .. " Year: " .. data[gunnercode].Year .. "<br />" return output else output = '<span style="color:#d33">Error: code '.. gunnercode .. ' not found</span>' end return output end 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 = '<span style="color:#d33">Error: No "code" specified. Use the Gunner number preceded by an A for example, code=A100</span>[[Category:Master Gunner Error]]' return output end if data[gunnercode] then -- Send Info -- Generate wiki table code for the Master Gunner local float = templateArgs.float or 'none' if float == "left" then float = "floatleft" elseif float == "right" then float = "floatright" elseif float == "none" then float = '' end local tableCode = '{| class="wikitable ' .. float .. '" style="text-align:center" \n' -- tableCode = tableCode .. "|+ Master Gunner \n" -- Caption tableCode = tableCode .. "|-\n" tableCode = tableCode .. '!colspan=2 style="background:red; color:white;"| Master Gunner: ' .. data[gunnercode].Code .. '\n' tableCode = tableCode .. "|-\n" tableCode = tableCode .. "|colspan=2|[[file:SANDF Arty Master Gunner badge embossed.png|border|" .. imagesize .. "|link=List of badges of the South African Army#Proficiency: Master Gunner|Master Gunner]]\n" tableCode = tableCode .. "|-\n" tableCode = tableCode .. "|colspan=2|" .. p.GetGunner("A" .. data[gunnercode].Code) if string.len(data[gunnercode].Post) > 1 then tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', args = {"Post occupied when award was made: " .. data[gunnercode].Post} } end if string.len(data[gunnercode].Note) > 1 then tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', args = {data[gunnercode].Note} } end tableCode = tableCode .. "\n" tableCode = tableCode .. "|-\n " tableCode = tableCode .. "|colspan=2|[[Master Gunners of the South African Army|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 .. "|}" return tableCode end return output end function p.GetGunner(gunnercode) local output = '' if not data[gunnercode] then output = "Unknown" else if string.len(data[gunnercode].WikiPage) < 1 then output = data[gunnercode].Rank .. "<br />".. data[gunnercode].FirstName .. " " .. data[gunnercode].Surname else output = data[gunnercode].Rank .. "<br />" .. "[[" .. data[gunnercode].WikiPage .. "|" .. data[gunnercode].FirstName .. " " .. data[gunnercode].Surname .. "]]" end end return output -- Should never get here, but belts-and -braces... just to be sure end 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 = '{| class="wikitable sortable" \n' tableCode = tableCode .. "|+ List of Master Gunners \n" -- Caption tableCode = 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.WikiPage .. "|" .. record.Surname .. "]]" end -- if string.len(record.Post)>1 then -- tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', args = {"Post occupied when award was made: " .. record.Post} } -- end tableCode = tableCode .. "\n" tableCode = tableCode .. "| " .. record.FirstName .. "\n" tableCode = tableCode .. "| " .. string.gsub(record.Post, ",", " - <br />") .. "\n" tableCode = tableCode .. "| " .. record.Year .. "\n" tableCode = tableCode .. "| <small>" .. record.Note .. "</small>\n" end tableCode = tableCode .. "|}" -- End the table return tableCode end return p -- Initial Code by John Dovey (13 April 2023) [[User:BoonDock]]
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Sandbox other
(
edit
)
Template:Template link
(
edit
)
Template:Template link expanded
(
edit
)
Template:Tl
(
edit
)
Template:Tlx
(
edit
)
Module:Arguments
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:MasterGunner/doc
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:String
(
edit
)
Module:Template link general
(
edit
)