Module:AusAward
Yi palo
Documentation for this module may be created at Module:AusAward/doc
require('strict')
local p = {}
local data = mw.loadData('Module:AusAward/data')
local milawarddata = mw.loadData('Module:MilAward/data')
local getArgs = require('Module:Arguments').getArgs
-- Australian Award Data
-- Data Fields
-- AwardID: This is just a duplicate of the lookup code, but expressed as a number instead of a string
-- Title: Person's title/rank. Not wikilinked.
--- FirstName: Initials or first name(s)
-- Surname: Person's Surname
-- Year: Year of Award
-- Month: Month of award
-- Day: Day of award
-- 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
-- ShortCite: Short citation
-- ShortCiteRef: Reference for the short citation
-- Award: Name of the award
-- MilAward: Code for the award in the Module:MilAward/data module
-- State: Australian State of the recipient
-- Suburb: Australian Suburb of the recipient
-- Postcode: Australian Postcode of the recipient
-- AnnounceEvent:What event the award was announced at
-- AnnounceEventCite: Citation for the announcement event
-- LongCite: Long Citation
-- LongCiteRef: Reference for the long Citation
-- Note: Any additional info about this recipient
function p.Award(frame)
local output = ''
local templateArgs = getArgs(frame)
local AwardID = templateArgs["AwardID"] or ''
if not AwardID then
output = '<span style="color:#d33">Error: No AwardID specified</span>'
return output
end
if data[AwardID] then
output = output .. AwardID .. ": "
output = output .. data[AwardID].AwardID .. " - " .. data[AwardID].Award .. "<br />"
output = output .. data[AwardID].FirstName .. " " .. data[AwardID].Surname .. " Year: " .. data[AwardID].Year .. "<br />"
-- output = output .. data[AwardID].ShortCite .. "<ref>" .. data[AwardID].ShortCiteRef .. "</ref> <br />"
local ShortCite = data[AwardID].shortCite or ''
if string.len(ShortCite) > 0 then
local citationTemplate = 'cite web'
local citationParams = {
url = "https://honours.pmc.gov.au/honours/awards/" .. data[AwardID].AwardID,
title = data[AwardID].Surname .. ", " .. data[AwardID].FirstName,
publisher = "Australian Government: Department of the Prime Minister and Cabinet",
accessdate = '9 May 2023',
}
local citation = frame:expandTemplate{title = citationTemplate, args = citationParams}
local refTag = mw.getCurrentFrame():extensionTag('ref', citation)
output = output .. data[AwardID].ShortCite .. tostring(refTag) .. " <br />"
end
output = output .. data[AwardID].MilAward
if milawarddata[data[AwardID].MilAward] then
output = output .. ": [[File:" .. milawarddata[data[AwardID].MilAward].RibbonImage .. "]] <br />"
end
return output
else
output = '<span style="color:#d33">Error: code '.. AwardID .. ' 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.AwardTable(frame)
-- Data Fields
-- AwardID: This is just a duplicate of the lookup code, but expressed as a number instead of a string
-- Title: Person's title/rank. Not wikilinked.
--- FirstName: Initials or first name(s)
-- Surname: Person's Surname
-- Year: Year of Award
-- Month: Month of award
-- Day: Day of award
-- 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
-- ShortCite: Short citation
-- ShortCiteRef: Reference for the short citation
-- Award: Name of the award
-- MilAward: Code for the award in the Module:MilAward/data module
-- State: Australian State of the recipient
-- Suburb: Australian Suburb of the recipient
-- Postcode: Australian Postcode of the recipient
-- AnnounceEvent:What event the award was announced at
-- AnnounceEventCite: Citation for the announcement event
-- LongCite: Long Citation
-- LongCiteRef: Reference for the long Citation
-- Note: Any additional info about this recipient
-- Number: Sequential number
local output = ''
local templateArgs = getArgs(frame)
local localfloat = templateArgs["float"] or ''
local Award = templateArgs["Award"] or ''
if string.len(Award) < 1 then
Award = 'All'
end
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 Recipients (" .. Award ..") \n" -- Caption
tableCode = tableCode .. "|-\n"
tableCode = tableCode .. "! Name !! Date !! No. !! Award ID !! Short Citation !! Long Citation \n" -- removed !! Notes
-- Iterate through the data in the table
for code, record in pairs(data) do
-- Generate wiki table code for the Recipients
tableCode = tableCode .. "|-\n"
if string.len(record.WikiPage) > 0 then
tableCode = tableCode .. '|data-sort-value="' .. record.Surname .. ',' .. record.FirstName .. '"|' .. record.Title .. ' [[' .. record.WikiPage .. '|' .. record.FirstName .. ' ' .. record.Surname .. ']]'
else
tableCode = tableCode .. '|data-sort-value="' .. record.Surname .. ',' .. record.FirstName .. '"|' .. record.Title .. ' ' .. record.FirstName .. ' ' .. record.Surname
end
if string.len(record.Note) > 0 then
tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', args = {record.Note} } .. '\n'
else
tableCode = tableCode .. '\n'
end
if string.len(record.Year) > 0 then
local dts=record.Day .. "-" .. record.Month .. "-" .. record.Year
tableCode = tableCode .. '|align=center|' .. mw.getCurrentFrame():expandTemplate{ title = 'dts', args = {dts} } .. '\n'
-- tableCode = tableCode .. "|align=center|" .. record.Day .. "/" .. record.Month .. "/" .. record.Year .. "\n"
else
tableCode = tableCode .. '|align=center|\n'
end
tableCode = tableCode .. "|align=right|" .. record.Number .." \n" -- This is a sequence number. Gotta still figure this out
local citationTemplate = 'cite web'
local citationParams = {
url = "https://honours.pmc.gov.au/honours/awards/" .. record.AwardID,
title = record.Surname .. ", " .. record.FirstName,
publisher = "Australian Government: Department of the Prime Minister and Cabinet",
accessdate = '9 May 2023',
}
local citation = frame:expandTemplate{title = citationTemplate, args = citationParams}
-- data.templatestyles = mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = 'Hlist/styles.css' } }
local refname = record.Surname .. record.FirstName .. record.AwardID
local refTag = mw.getCurrentFrame():extensionTag{name = 'ref', args = {name = refname}, content = citation}
tableCode = tableCode .. "|align=right| " .. record.AwardID .. tostring(refTag) .. "\n"
local RefTag2 = mw.getCurrentFrame():extensionTag{name = 'ref', args = {name = refname}}
tableCode = tableCode .. "| " .. record.ShortCite .. tostring(RefTag2) .. "\n"
tableCode = tableCode .. "| " .. record.LongCite
if string.len(record.LongCiteRef) > 0 then
tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', record.LongCiteRef } .. '\n'
else
tableCode = tableCode .. "\n"
end
-- tableCode = tableCode .. "| " .. record.Note .. "\n" -- Removed this from the table as it's included as an efn note
end
tableCode = tableCode .. "|}" -- End the table
return tableCode
end
return p
-- Initial Code by John Dovey (9 May 2023) [[User:BoonDock]]