Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Relentlessly/Cycling race/teamroster
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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] = '[[' .. link .. '|' .. 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] = { year = year, month = month, day = day } 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{title = 'User:Relentlessly/cycling race/top'} local tableFoot = frame:expandTemplate{title = 'User:Relentlessly/cycling race/foot'} i = 1 local tableSize = table.getn(riderNames) while riderNames[i] do tableBody = tableBody .. frame:expandTemplate{title = 'User:Relentlessly/cycling race/row', args = { name = riderNames[i], nationality = 'ITA', seasonyear = seasonYear, seasonmonth = seasonMonth, seasonday = seasonDay, birthyear = riderBirthdays[i]['year'], birthmonth = riderBirthdays[i]['month'], birthday = riderBirthdays[i]['day'] }} if columns == 2 and math.floor((tableSize + 1)/2) == i then tableBody = tableBody .. tableFoot ..'</td><td width="1%"></td><td style="vertical-align:top;" width="44%">' .. tableHeader end i = i + 1 end local tableStart = '<table border="0"><tr><td style="vertical-align:top;" width="44%">' local tableEnd = '</td></tr></table>' --[[ if labelMissing then tableEnd = tableEnd .. getMissingLabelTrackingCategory() end --]] return '<table style="border:1px solid rgb(200,200,200)"><tr><td>'.. tableStart.. tableHeader.. tableBody.. tableFoot.. tableEnd.. '</td></tr></table>' end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Relentlessly/Cycling race/teamroster/doc
(
edit
)