Reorder infobox: Born, Died, then Nativity
Generate soldier lead as editable page wikitext
Line 1,047: Line 1,047:
function p.displayName(frame)
function p.displayName(frame)
return displayName(frame)
return displayName(frame)
end
local function displayNameFrom(getArg)
local first = prettyNamePart(getArg('first'))
local middle = prettyNamePart(getArg('middle'))
local surname = prettyNamePart(getArg('surname'))
local suffix = prettyNamePart(getArg('suffix'))
local parts = {}
if first ~= '' then
table.insert(parts, first)
end
if middle ~= '' then
table.insert(parts, middle)
end
if surname ~= '' then
table.insert(parts, surname)
end
local name = table.concat(parts, ' ')
if suffix ~= '' then
if name ~= '' then
name = name .. ', ' .. suffix
else
name = suffix
end
end
if name == '' then
name = 'This soldier'
end
return name
end
local function preferredRankFrom(getArg)
local rank = expandRank(getArg('rank_final'))
if rank == '' then
rank = expandRank(getArg('class_rank'))
end
return rank
end
local function buildLead(getArg)
local name = displayNameFrom(getArg)
local rank = preferredRankFrom(getArg)
local role = 'United States Army soldier'
if rank ~= '' then
role = 'United States Army ' .. rank
end
local classLinks = classLinkList(getArg('class_number'), true)
local trained
if #classLinks == 1 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in ' .. classLinks[1]
elseif #classLinks == 2 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in ' .. classLinks[1] .. ' and ' .. classLinks[2]
elseif #classLinks > 2 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in '
.. table.concat(classLinks, ', ', 1, #classLinks - 1)
.. ', and ' .. classLinks[#classLinks]
else
trained = ' associated with Camp Ritchie, Maryland'
end
local lead = string.format(
"'''%s'''%s was a %s%s.",
name,
lifespan(getArg('birth_year'), getArg('death_year')),
role,
trained
)
local who = prettyNamePart(getArg('first'))
if who == '' then
who = prettyNamePart(getArg('surname'))
end
if who == '' then
who = 'He'
end
local enlist = prettyPlace(getArg('enlistment_place'))
if enlist ~= '' then
lead = lead .. ' ' .. who .. ' enlisted at ' .. enlist .. '.'
end
return lead
end
end


Line 1,229: Line 1,309:


function p.lead(frame)
function p.lead(frame)
local name = displayName(frame)
return buildLead(function(key)
local rank = preferredRank(frame)
return parentArg(frame, key)
local role = 'United States Army soldier'
end)
if rank ~= '' then
end
role = 'United States Army ' .. rank
end
 
local classLinks = classLinkList(parentArg(frame, 'class_number'), true)
local trained
if #classLinks == 1 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in ' .. classLinks[1]
elseif #classLinks == 2 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in ' .. classLinks[1] .. ' and ' .. classLinks[2]
elseif #classLinks > 2 then
trained = ' who trained at [[Camp Ritchie]], Maryland, in '
.. table.concat(classLinks, ', ', 1, #classLinks - 1)
.. ', and ' .. classLinks[#classLinks]
else
trained = ' associated with Camp Ritchie, Maryland'
end


local lead = string.format(
function p.leadFrom(frame)
"'''%s'''%s was a %s%s.",
return buildLead(function(key)
name,
return trim(frame.args[key] or '')
lifespan(parentArg(frame, 'birth_year'), parentArg(frame, 'death_year')),
end)
role,
trained
)
local who = prettyNamePart(parentArg(frame, 'first'))
if who == '' then
who = prettyNamePart(parentArg(frame, 'surname'))
end
if who == '' then
who = 'He'
end
local enlist = prettyPlace(parentArg(frame, 'enlistment_place'))
if enlist ~= '' then
lead = lead .. ' ' .. who .. ' enlisted at ' .. enlist .. '.'
end
return lead
end
end