Module:Soldier: Difference between revisions
Map Lat/Bul/Alb/Lux/Bra nativity codes |
Interview and film cues on soldier profiles |
||
| Line 2,483: | Line 2,483: | ||
.. 'People moved between teams; overlapping service dates are not always documented.</div>' | .. 'People moved between teams; overlapping service dates are not always documented.</div>' | ||
.. '</div>' | .. '</div>' | ||
end | |||
function p.mediaCue(frame) | |||
local pageTitle = mw.title.getCurrentTitle().prefixedText | |||
local ok, data = pcall(mw.loadData, 'Module:Interviews/data') | |||
if not ok or type(data) ~= 'table' or type(data.by_title) ~= 'table' then | |||
return '' | |||
end | |||
local rec = data.by_title[pageTitle] | |||
if type(rec) ~= 'table' then | |||
return '' | |||
end | |||
local interviews = rec.interviews | |||
local films = rec.films | |||
local hasInterviews = type(interviews) == 'table' and #interviews > 0 | |||
local hasFilms = type(films) == 'table' and #films > 0 | |||
if not hasInterviews and not hasFilms then | |||
return '' | |||
end | |||
local name = displayName(frame) | |||
local blocks = {} | |||
if hasInterviews then | |||
local links = {} | |||
for _, item in ipairs(interviews) do | |||
local heading = item.heading or 'Interview' | |||
local short = item.short or heading | |||
table.insert( | |||
links, | |||
string.format('[[Ritchie Boy Interviews#%s|%s]]', heading, short) | |||
) | |||
end | |||
local label = #interviews == 1 and 'Interview' or 'Interviews' | |||
local body | |||
if #interviews == 1 then | |||
body = string.format( | |||
'Watch %s on [[Ritchie Boy Interviews#%s|%s]].', | |||
name, | |||
interviews[1].heading, | |||
interviews[1].short or interviews[1].heading | |||
) | |||
else | |||
body = string.format( | |||
'Watch %s in %d videos on [[Ritchie Boy Interviews]]: %s.', | |||
name, | |||
#interviews, | |||
table.concat(links, ' · ') | |||
) | |||
end | |||
table.insert( | |||
blocks, | |||
'<div class="soldier-interview-cue">' | |||
.. '<span class="soldier-interview-cue-label">' | |||
.. label | |||
.. '</span> ' | |||
.. body | |||
.. '</div>' | |||
) | |||
end | |||
if hasFilms then | |||
local links = {} | |||
for _, item in ipairs(films) do | |||
local heading = item.heading or 'Documentaries/Movies' | |||
local filmLabel = item.label or heading | |||
table.insert( | |||
links, | |||
string.format('[[Documentaries/Movies#%s|%s]]', heading, filmLabel) | |||
) | |||
end | |||
local body = string.format( | |||
'%s appears in %s.', | |||
name, | |||
table.concat(links, '; ') | |||
) | |||
table.insert( | |||
blocks, | |||
'<div class="soldier-film-cue">' | |||
.. '<span class="soldier-film-cue-label">On film</span> ' | |||
.. body | |||
.. '</div>' | |||
) | |||
end | |||
return '<div class="soldier-media-cue">' .. table.concat(blocks, '') .. '</div>' | |||
end | end | ||
return p | return p | ||