Military sidebar: years/battles/ribbons + branch emblems
Military sidebar: years/battles/ribbons + branch emblems
Line 1,221: Line 1,221:
part = mw.ustring.gsub(part, '^[Ff]ile:', '')
part = mw.ustring.gsub(part, '^[Ff]ile:', '')
if part ~= '' then
if part ~= '' then
table.insert(files, '[[File:' .. part .. '|80px]]')
table.insert(files, part)
end
end
end
end
Line 1,227: Line 1,227:
return ''
return ''
end
end
return table.concat(files, ' ')
-- Wikipedia-style ribbon rack: centered table, ~4 across, full article width
local perRow = 4
local out = {}
table.insert(out, '{| class="wikitable soldier-ribbon-rack"')
for i, file in ipairs(files) do
if ((i - 1) % perRow) == 0 then
table.insert(out, '|-')
end
table.insert(out, '| [[File:' .. file .. '|106px|link=]]')
end
-- Pad last row so cells align
local rem = #files % perRow
if rem > 0 then
for _ = rem + 1, perRow do
table.insert(out, '|')
end
end
table.insert(out, '|}')
return table.concat(out, '\n')
end
 
local function formatAwardsLegend(raw)
raw = prettyProse(trim(raw))
if raw == '' then
return ''
end
-- Split semicolon / <br> lists into bullets when multiple awards
local parts = {}
raw = mw.ustring.gsub(raw, '<br%s*/?>', ';')
for part in mw.text.gsplit(raw, ';', true) do
part = trim(part)
if part ~= '' then
table.insert(parts, '* ' .. part)
end
end
if #parts <= 1 then
return raw
end
return table.concat(parts, '\n')
end
end


Line 1,543: Line 1,581:
addRow(tbl, 'Certificate', realCertificate(parentArg(frame, 'certificate')))
addRow(tbl, 'Certificate', realCertificate(parentArg(frame, 'certificate')))


-- Awards ribbons render in the article body (p.awardsSection), not this
-- narrow infobox — matching Wikipedia's main-column ribbon racks.
return tostring(tbl)
end
function p.awardsSection(frame)
local ribbons = formatAwardsRibbons(parentArg(frame, 'awards_ribbons'))
local ribbons = formatAwardsRibbons(parentArg(frame, 'awards_ribbons'))
local awardsText = prettyProse(parentArg(frame, 'awards'))
local awardsText = formatAwardsLegend(parentArg(frame, 'awards'))
-- Also show awards under military when ribbons present (Personal details still has text)
-- Body section is for the ribbon rack; skip if no ribbons (text stays in infobox)
if ribbons ~= '' then
if ribbons == '' then
addHeader(tbl, 'Awards and honors')
return ''
addRow(tbl, 'Ribbons', ribbons)
end
if awardsText ~= '' then
local parts = {
addRow(tbl, 'Awards', awardsText)
'<div class="soldier-awards-section">',
end
'== Awards and honors ==',
ribbons,
}
if awardsText ~= '' then
table.insert(parts, awardsText)
end
end
 
table.insert(parts, '</div>')
return tostring(tbl)
return table.concat(parts, '\n')
end
end