Module:Sandbox/Relentlessly/Cycling race/teamroster explained

local p =

function p.teamroster(frame) local columns = tonumber(frame.args.columns)

1 and tonumber(frame.args.columns) or 2 --defaults to two columns local squadSeason = mw.wikibase.getEntityObject(frame.args[1]) local flags = local riderIds = local riderNames = local riderBirthdays = local labelMissing = false local wiki = mw.site.server local WDlink_off = false

-- WDlink_off is used to decide if a Wikidata flag will be shown if wiki

"//www.wikidata.org" or wiki

"//fr.wikipedia.org" or wiki

"//en.wikipedia.org" or wiki

"//br.wikipedia.org" or wiki

"//ca.wikipedia.org" or wiki

"//de.wikipedia.org" or wiki

"//eo.wikipedia.org" or wiki

"//es.wikipedia.org" or wiki

"//lb.wikipedia.org" or wiki

"//nl.wikipedia.org" or wiki

"//no.wikipedia.org" or wiki

"//pl.wikipedia.org" or wiki

"//pt.wikipedia.org" or wiki

"//ro.wikipedia.org" then WDlink_off = true end

local startOfSeason = squadSeason.claims["P580"][1].mainsnak.datavalue.value.time local _, _, seasonYear, seasonMonth, seasonDay = string.find(startOfSeason, "(%d+)-(%d+)-0*(%d+)")

local i = 1 while squadSeason.claims["P527"][i] do riderIds[i] = 'Q' .. squadSeason.claims["P527"][i].mainsnak.datavalue.value['numeric-id'] local rider = mw.wikibase.getEntityObject(riderIds[i]) local label = rider:getLabel local link = rider:getSitelink if label

null then label = '\'\ .. rider:getLabel('en') .. ' (en)\'\ labelMissing = true end if link

null then riderNames[i] = label elseif label

link then riderNames[i] = '' .. label .. '' else riderNames[i] = '' .. label .. '' end if pcall(function local riderBirthday = rider.claims["P569"][1].mainsnak.datavalue.value.time local _, _, year, month, day = string.find(riderBirthday, "(%d+)-(%d+)-0*(%d+)") riderBirthdays[i] = end ) then else riderBirthdays[i] = end

if pcall(function flags[i] = flag(getNationalityOnDate (riderIds[i], startOfSeason), startOfSeason) end ) then else flags[i] = end

i = i + 1 end

local tableBody = local tableHeader = frame:expandTemplate local tableFoot = frame:expandTemplate i = 1 local tableSize = table.getn(riderNames) while riderNames[i] do tableBody = tableBody .. frame:expandTemplate

if columns

2 and math.floor((tableSize + 1)/2)

i then tableBody = tableBody .. tableFoot ..'' .. tableHeader end i = i + 1 end local tableStart = '

' local tableEnd = '
' --if labelMissing then tableEnd = tableEnd .. getMissingLabelTrackingCategory end --

return '

'.. tableStart.. tableHeader.. tableBody.. tableFoot.. tableEnd.. '
'end

return p