Module:Soldier: Difference between revisions
Story cue + same class/team rails |
Related rail: include MII/|teams=/notes teams; roster co-assignment note |
||
| Line 2,399: | Line 2,399: | ||
local pageTitle = mw.title.getCurrentTitle().prefixedText | local pageTitle = mw.title.getCurrentTitle().prefixedText | ||
local classRaw = parentArg(frame, 'class_number') | local classRaw = parentArg(frame, 'class_number') | ||
local sections = {} | local sections = {} | ||
local function | local function addTeamBlock(teamName, where) | ||
local | local teamPage = 'Team ' .. teamName | ||
local head = teamNameLink(teamName) | |||
local head = | |||
local cat = 'Category:' .. teamPage | local cat = 'Category:' .. teamPage | ||
local links = {} | |||
if where then | |||
local rows = cargoRows( | |||
'Soldiers', | |||
'ASN,Surname,First_name,Middle_name,_pageName=pageName', | |||
where, | |||
8, | |||
'Surname' | |||
) | |||
links = linkList(rows, asn, pageTitle, 8) | |||
end | |||
if #links > 0 then | if #links > 0 then | ||
table.insert( | table.insert( | ||
| Line 2,427: | Line 2,429: | ||
) | ) | ||
else | else | ||
-- MII and other non-Cargo teams: still surface the team page/category. | |||
table.insert( | table.insert( | ||
sections, | sections, | ||
'<div class="soldier-related-block"><div class="soldier-related-label">Team | '<div class="soldier-related-block"><div class="soldier-related-label">Team — ' | ||
.. head | .. head | ||
.. ' | .. '</div><div class="soldier-related-links">[[' | ||
.. cat | .. cat | ||
.. '| | .. '|Browse soldiers listed on this team]]</div></div>' | ||
) | ) | ||
end | end | ||
end | end | ||
-- Same sources as the infobox Teams row: roster IPW, |teams=, research notes. | |||
local teamNames = {} | |||
local seenTeams = {} | |||
local function addTeams(list) | |||
for _, name in ipairs(list) do | |||
appendUniqueTeamName(teamNames, seenTeams, name) | |||
end | |||
end | end | ||
addTeams(namesFromIpwGerman(parentArg(frame, 'ipw_ge'))) | |||
local | addTeams(namesFromIpwItalian(parentArg(frame, 'ipw_it'))) | ||
addTeams(namesFromTeamsParam(parentArg(frame, 'teams'))) | |||
addTeams(noteTeamNames(pageResearchNotesText())) | |||
' | |||
string.format('IPW_Italian="%s"', | for _, teamName in ipairs(teamNames) do | ||
) | local where = nil | ||
local geNum = mw.ustring.match(teamName, '^IPW (%d+)$') | |||
local itCode = mw.ustring.match(teamName, '^IPW Italian (.+)$') | |||
if geNum then | |||
where = string.format('IPW_German="%s"', geNum) | |||
elseif itCode then | |||
where = string.format('IPW_Italian="%s"', itCode) | |||
end | |||
addTeamBlock(teamName, where) | |||
end | end | ||
| Line 2,505: | Line 2,519: | ||
.. '<div class="soldier-related-heading">Same class and team</div>' | .. '<div class="soldier-related-heading">Same class and team</div>' | ||
.. table.concat(sections, '\n') | .. table.concat(sections, '\n') | ||
.. '<div class="soldier-related-note">These are other soldiers listed on the same class or team roster. ' | |||
.. 'People moved between teams; overlapping service dates are not always documented.</div>' | |||
.. '</div>' | .. '</div>' | ||
end | end | ||
return p | return p | ||