Infobox: full birth/death places, known for, awards
Military sidebar: years/battles/ribbons + branch emblems
Line 1,132: Line 1,132:
end
end
return raw
return raw
end
-- Small public-domain / Commons emblems uploaded as File:Branch emblem *.png
local BRANCH_EMBLEM = {
['United States Army'] = 'Branch emblem US Army.png',
['United States Marine Corps'] = 'Branch emblem US Marine Corps.png',
['United States Navy'] = 'Branch emblem US Navy.png',
['United States Army Air Forces'] = 'Branch emblem US Army Air Forces.png',
['United States Air Force'] = 'Branch emblem US Air Force.png',
['United States Coast Guard'] = 'Branch emblem US Coast Guard.png',
}
local function branchWithEmblem(name)
name = trim(name)
if name == '' then
return ''
end
local file = BRANCH_EMBLEM[name]
if file then
return '[[File:' .. file .. '|18px|link=|alt=]] ' .. name
end
-- Fuzzy contains
local low = mw.ustring.lower(name)
if mw.ustring.find(low, 'marine', 1, true) then
return '[[File:Branch emblem US Marine Corps.png|18px|link=|alt=]] ' .. name
end
if mw.ustring.find(low, 'navy', 1, true) then
return '[[File:Branch emblem US Navy.png|18px|link=|alt=]] ' .. name
end
if mw.ustring.find(low, 'air force', 1, true) or mw.ustring.find(low, 'air forces', 1, true) then
return '[[File:Branch emblem US Army Air Forces.png|18px|link=|alt=]] ' .. name
end
if mw.ustring.find(low, 'coast guard', 1, true) then
return '[[File:Branch emblem US Coast Guard.png|18px|link=|alt=]] ' .. name
end
if mw.ustring.find(low, 'army', 1, true) then
return '[[File:Branch emblem US Army.png|18px|link=|alt=]] ' .. name
end
return name
end
end


Line 1,142: Line 1,181:
for part in mw.text.gsplit(raw, ';', true) do
for part in mw.text.gsplit(raw, ';', true) do
part = expandBranchToken(part)
part = expandBranchToken(part)
if part ~= '' then
table.insert(parts, branchWithEmblem(part))
end
end
return table.concat(parts, '; ')
end
local function formatBattles(raw)
raw = trim(raw)
if raw == '' then
return ''
end
-- Allow HTML <br /> or semicolon / newline separated campaigns
raw = mw.ustring.gsub(raw, '\r', '')
if mw.ustring.find(raw, '<br', 1, true) or mw.ustring.find(raw, '\n', 1, true) then
return raw
end
local parts = {}
for part in mw.text.gsplit(raw, ';', true) do
part = trim(part)
if part ~= '' then
if part ~= '' then
table.insert(parts, part)
table.insert(parts, part)
end
end
end
end
return table.concat(parts, '; ')
if #parts <= 1 then
return raw
end
return table.concat(parts, '<br />')
end
 
local function formatAwardsRibbons(raw)
raw = trim(raw)
if raw == '' then
return ''
end
local files = {}
for part in mw.text.gsplit(raw, ';', true) do
part = trim(part)
part = mw.ustring.gsub(part, '^[Ff]ile:', '')
if part ~= '' then
table.insert(files, '[[File:' .. part .. '|80px]]')
end
end
if #files == 0 then
return ''
end
return table.concat(files, ' ')
end
end


Line 1,415: Line 1,496:


addHeader(tbl, 'Military service')
addHeader(tbl, 'Military service')
addRow(tbl, 'Allegiance', 'United States')
addRow(tbl, 'Allegiance', '[[File:Flag of the United States.png|20px|link=|alt=]] United States')
local branch = expandBranch(parentArg(frame, 'class_branch'))
local branchRaw = parentArg(frame, 'class_branch')
if branchRaw == '' then
branchRaw = parentArg(frame, 'branch')
end
local branch = expandBranch(branchRaw)
if branch == '' then
if branch == '' then
branch = 'United States Army'
branch = branchWithEmblem('United States Army')
end
end
addRow(tbl, 'Branch', branch)
addRow(tbl, 'Branch', branch)
addRow(tbl, 'Years of service', prettyProse(parentArg(frame, 'years_of_service')))
addRow(tbl, 'ASN', parentArg(frame, 'asn'), 'serial')
addRow(tbl, 'ASN', parentArg(frame, 'asn'), 'serial')


Line 1,450: Line 1,536:
addRow(tbl, 'Specialty', prettyProse(parentArg(frame, 'specialty')))
addRow(tbl, 'Specialty', prettyProse(parentArg(frame, 'specialty')))
addRow(tbl, 'Unit / division', prettyProse(parentArg(frame, 'division')))
addRow(tbl, 'Unit / division', prettyProse(parentArg(frame, 'division')))
addRow(tbl, 'Battles / wars', formatBattles(parentArg(frame, 'battles')))
addRow(tbl, 'IPW (German)', teamLinkList(parentArg(frame, 'ipw_ge'), 'IPW ', 'IPW'))
addRow(tbl, 'IPW (German)', teamLinkList(parentArg(frame, 'ipw_ge'), 'IPW ', 'IPW'))
addRow(tbl, 'IPW (Italian)', teamLinkList(parentArg(frame, 'ipw_it'), 'IPW Italian ', 'IPW Italian'))
addRow(tbl, 'IPW (Italian)', teamLinkList(parentArg(frame, 'ipw_it'), 'IPW Italian ', 'IPW Italian'))
addRow(tbl, 'LOC', parentArg(frame, 'loc'))
addRow(tbl, 'Arrived', parentArg(frame, 'date_arrive'))
addRow(tbl, 'Arrived', parentArg(frame, 'date_arrive'))
addRow(tbl, 'Departed', parentArg(frame, 'date_depart'))
addRow(tbl, 'Departed', parentArg(frame, 'date_depart'))
addRow(tbl, 'Certificate', realCertificate(parentArg(frame, 'certificate')))
addRow(tbl, 'Certificate', realCertificate(parentArg(frame, 'certificate')))
local ribbons = formatAwardsRibbons(parentArg(frame, 'awards_ribbons'))
local awardsText = prettyProse(parentArg(frame, 'awards'))
-- Also show awards under military when ribbons present (Personal details still has text)
if ribbons ~= '' then
addHeader(tbl, 'Awards and honors')
addRow(tbl, 'Ribbons', ribbons)
if awardsText ~= '' then
addRow(tbl, 'Awards', awardsText)
end
end


return tostring(tbl)
return tostring(tbl)