Munurin millum rættingarnar hjá "Module:Cycling race"
Content deleted Content added
update |
copy from wikidata Merki: Reverted |
||
Linja 13:
local wikilang = contentLanguage:getCode()
local wikibase = mw.wikibase
-- == Structure of the code ==
-- I) Constant
Line 50 ⟶ 48:
--== I) Classes declared as global ==
local textalign = "left"
local floattable = "left"
Line 84 ⟶ 61:
local standardtablecss=data.standardtablecss_part1..textalign..data.standardtablecss_part2
local lang_priority --for lang priority and fallback
if l10n["lang_priority"] then
lang_priority=l10n["lang_priority"]
else --default
lang_priority={}
table.insert(lang_priority,wikilang)
for _, lang in ipairs({'mul','en', 'fr', 'de','es','nl','it','da'}) do
if lang~=wikilang then
table.insert(lang_priority,lang)
end
end
end
--"country" means here, that there will be a separated column containing the country name
--otherwise a flag is typically added in another column, for instance before the rider name
local no_country_calendar={'ru','ar'}
local no_country_victories={'ru','ar','da'}
local no_country_classification={'es','da','no','ru','ar'}
--to avoid wrong display, or country names becoming very long,
--available_list==false --> country=false in the old code,
--should be implemented here
if not l10n["country_name_list"] then
table.insert(no_country_calendar, wiki)
table.insert(no_country_victories, wiki)
table.insert(no_country_classification, wiki)
end
--Note about WDlink_on
--On some wikipedia small wikidata flag are displayed after all data coming from wikidata
--to enable that set WDlink_on on true
local no_roll_startlist={'fr','da','no','ar','ru','de'}
local display_language_in_riderinfobox={'ru'}
Line 93 ⟶ 99:
local display_noweight_in_riderinfobox={'fr','pl'}
local display_noage_in_riderinfobox={'pl'}
local display_nonickname_in_riderinfobox={'pl'}
local display_cm_in_riderinfobox={'pl'}
local silver_theme_countries={'da', 'pl'}
local backgroundColor="#FFDF80"
Line 111 ⟶ 119:
--== II) Translation ==
local function translate(func_name_short, index,
if index==1000 then --code for some custom function
return title
Line 118 ⟶ 125:
if func_name_short then
local func_name
if
func_name=func_name_short.."_women_translate"
if l10n[func_name] and l10n[func_name][index] then
Line 130 ⟶ 137:
return "translation for "..func_name.." index ".. tostring(index).." not found"
else
end
end
end
local function plural(num)
local plural=false --latin language
local gen_singular=false --for slavic language
Line 161 ⟶ 168:
end
local function black_list( Label)
local black_list=l10n.black_list
--[[ List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed
Line 169 ⟶ 176:
end
local function country_name_from_list(countryID)
if l10n["country_name_list"] and l10n["country_name_list"][countryID] then
return l10n["country_name_list"][countryID]
end
return nil
end
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local word1
local word2=translate("func_prologue",2) --stage
local word
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
Line 224 ⟶ 232:
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10n=l10n["type_of_stage_translate"]
local border
Line 270 ⟶ 249:
if x=='time trial stage' then
if noborder then border="" else border="|right" end
local stages2 = {
["Q485321"] = "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologue.."]]"
}
if stages2[typ] then
return stages2[typ]
end
end
end
local function typeofstagelogo(stageID, noborder)
local sType
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
local stages = {
["Q20646667"] = {"plain stage", nil},
["Q20646670"] = {"hilly stage", nil},
["Q20680270"] = {"intermediate stage", nil},
["Q20646668"] = {"mountain stage", nil},
["Q485321"] = {"time trial stage", "Q485321"}, -- prologue
["Q2266066"] = {"time trial stage", "Q2266066"}, -- individual time trial
["Q2348250"] = {"time trial stage", "Q2348250"}, -- team time trial
["Q20679712"] = {"uphill time trial stage", nil}
}
for _, t in pairs(p) do
if t.mainsnak.snaktype == 'value' then
local iOf = t.mainsnak.datavalue.value.id
if stages[iOf] then
break
end
end
end
Line 319 ⟶ 309:
local function getLabelFallback(itemID, fallback)
local label
if fallback==nil then --default
fallback=lang_priority
end
for _, lang in ipairs(fallback) do
label = mw.wikibase.getLabelByLang(itemID, lang)
Line 335 ⟶ 328:
end
return nil
end
local arwiki_totemplate = mw.getCurrentFrame():getParent().args["totemplate"] or mw.getCurrentFrame().args["totemplate"]
arwiki_totemplate = (wiki == "ar" and arwiki_totemplate and arwiki_totemplate ~= "") or false
local function get_lf(frame)
local lf = frame
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
lf = frame:getParent()
end
return lf
end
local function get_and_checkID(frame)
local lf = get_lf(frame)
local entityID = mw.text.trim(lf.args[1])
entityID= string.gsub(entityID, "%c", "") --probably redundant
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
return entityID, lf
end
Line 418 ⟶ 431:
--[[ Get a Wikidata statement for an entity and property valid at the given timevalue ]]
local function checktime(s,q, time)
local start, startPrecision, END, endPrecision, timePrecision
if not q or not time then
return s
end
local _, _, _, m, _ = string.find(time, "(%d+)%p(%d+)%p(%d+)")
if m=="00" then
timePrecision=9
end
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
startPrecision = q.P580[1].datavalue.value.precision
if startPrecision == 9 or timePrecision==9 then -- precision is years
start = string.sub(start, 1, 5) -- Cut of everything after year
elseif startPrecision == 10 then -- precision is months
Line 439 ⟶ 456:
return s
end
if endPrecision == 9 or timePrecision==9 then -- precision 9 is 'years'
END = string.sub(END, 1, 6) .. '13' -- Set month to 13
elseif endPrecision == 10 then -- precision 10 is 'months'
Line 473 ⟶ 490:
local starttime, endtime
--local format = formats[wiki] or formats['']
if mode==nil then mode='long' end
Line 482 ⟶ 497:
if m=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
starttime =lang:formatDate( "Y", sTime )
else
Line 489 ⟶ 504:
else
if y ~= y2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F Y", sTime )
else
Line 495 ⟶ 510:
end
elseif m ~= m2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F", sTime )
else
Line 557 ⟶ 572:
end
elseif wiki == "pl" then
if y ~= y2 then starttime = lang:formatDate( "j
elseif m ~= m2 then starttime = lang:formatDate( "j xg", sTime )
else starttime = lang:formatDate( "j", sTime )
end
Line 565 ⟶ 580:
if m2=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
endtime= lang:formatDate( "Y", eTime )
else
Line 571 ⟶ 586:
end
else
if (mode=='long' and y ~= y2) or mode=="verylong" then
endtime = lang:formatDate("j F Y", eTime)
elseif y ~= y2 then --small
Line 581 ⟶ 596:
end
if wiki == "ar" then
if mode=='long' or mode=="verylong" or y ~= y2 then endtime = lang:formatDate( "d F Y", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "d F Y", eTime )
else endtime = lang:formatDate( "d F Y", eTime )
Line 587 ⟶ 602:
elseif wiki == "br" then endtime = lang:formatDate( "j", eTime ) .." a viz ".. lang:formatDate( "F Y", eTime )
elseif wiki == "ca" or wiki == "es" or wiki == "ast" then
if mode=='long' or mode=="verylong" or y ~= y2 then
endtime = lang:formatDate( "j", eTime ) .." de "..
lang:formatDate( "F", eTime ) .." de ".. lang:formatDate( "Y", eTime )
Line 596 ⟶ 611:
elseif wiki == "cs" then endtime = lang:formatDate( "j. xg Y", eTime )
elseif wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "lb" or wiki == "no" then
if mode=='long' or mode=="verylong" or y ~= y2 then
endtime = lang:formatDate( "j. F Y", eTime )
else
Line 620 ⟶ 635:
else endtime = lang:formatDate( "j. F", eTime )
end
elseif wiki == "pl" then endtime = lang:formatDate( "j xg Y", eTime )
end
end
Line 637 ⟶ 650:
local lang = contentLanguage
--handle problems with lack of precision
local
if string.sub(date,
dispDate= string.sub(date,1,6).."01-01"..string.sub(date,12)
if mode == 'long' or mode == 'onlyyear' or mode == 'monthly' then
else
mode = 'nodate'
end
elseif string.sub(date,10,11)=='00' then -- lack of day
dispDate= string.sub(date,1,9).."01"..string.sub(date,12)
mode = 'monthly'
elseif mode == 'small' then
elseif mode == 'onlyday' then
mode = 'nodate'
end
end
if format[mode] == nil then mode = 'nodate' end
return contentLanguage:formatDate(format[mode], dispDate)
end
Line 690 ⟶ 685:
end
local function isdisqualified(p,q) --disqualification can use deprecated or P1534
local cancelled=""
local disqualified=false
Line 715 ⟶ 710:
local cyrillic = {mk = true, ru = true}
local strictLangBool= strictLang[wiki] or strict
local correcttime, best, name, nametemp
local wantedLanguages = {}
for i, lang in ipairs(lang_priority) do
wantedLanguages[lang] = i
end
--case one, one official name / period overloaded with other languages as qualifier
--for instance https://www.wikidata.org/wiki/Q195833
best = 999
for _, p1448 in statements(teamID, 'P1448') do
correcttime=true
Line 731 ⟶ 725:
end
if correcttime then
if
local q = p1448.qualifiers.P1448
best = 999
Line 748 ⟶ 742:
lang=p1448.mainsnak.datavalue.value.language
if strictLangBool then
if wiki==lang then
name = p1448.mainsnak.datavalue.value.text
end
elseif wantedLanguages[lang] and wantedLanguages[lang] < best then
best = wantedLanguages[lang]
name = p1448.mainsnak.datavalue.value.text
else
if cyrillic[lang]==nil then --don't display cyrillic for latin wiki
Line 765 ⟶ 758:
if name then
return name, true
elseif not strictLangBool and nametemp then
return nametemp, false
end
Line 787 ⟶ 780:
end
local function checksitelink(sitelink, label)
if sitelink==label then
return "[[" .. sitelink .."]]"
else
return "[[" .. sitelink .. "|" .. label.. "]]"
end
end
-- RiderID --> RiderLink
local function getRiderLink(riderID, startOfSeason) --startOfSeason optional
Linja 848:
if sitelink and officialname then --if there is an official name, then use it
return
else
if officialname then return officialname end
Linja 859:
local c = p27[1].mainsnak.datavalue.value.id
if c=="Q159" or c=="Q184" or c=="Q212" or c=="Q232" then -- Q159, Q184, Q212, Q232 is Russia, Belarus, Ukraine, Kazakhstan
return
end
end
Linja 865:
end
if wiki == 'ru' then
local label = revertfirstlast(mw.text.trim(string.gsub(sitelink, "%b()", ""), " "))
return
else
return
end
end
Linja 902:
link = make_IllWD2_link(riderID)
else
link = getLabelFallback(riderID
if link then
link = string.gsub(link, "%b()", "")
Linja 911:
return link, correctlanguage
end
end
-- Get the countryID, return a single one, not a list
local function getCountryID(entityID, timeOfRace)
local countryID
if entityID then
local stm = getStatementForTime(entityID, 'P1532', timeOfRace) -- P1532 is country for sport
if stm == nil then
stm = getStatementForTime(entityID, 'P17', timeOfRace) -- P17 is country
end
if stm then countryID = stm.mainsnak.datavalue.value.id end
end
return countryID
end
--[[ Get the name of a country ]]
local function getCountryName(countryID)
local name =
if
local label, lang = wikibase.getLabelWithLang(countryID)
--[[ Uses standard language fallback. Should not return nil, nil, as all countries have English labels. ]]
Line 928 ⟶ 939:
end
end
return name or ''
end
Line 946 ⟶ 957:
--[[ Get sitelink, categoryID and maybe country for a team.
Returns sitelink, team category ID, countryID (only countryID if country arg is true ]]
local function getTeamLinkCat(teamID, timeOfRace, country,
local name, sitelink,
local parentID = getParentID(teamID)
local season=false
-- Find team category
--Hypothesis, it is a season, look in P2094
for _, p2094 in statements(teamID, 'P2094') do
if checktime(p2094, p2094.qualifiers, timeOfRace) then
catID = p2094.mainsnak.datavalue.value.id
break
end
end
end
--check if season
if season==false then --otherwise already clear
local natureID = p.mainsnak.datavalue.value.id
season=true
break
end
Line 973 ⟶ 983:
end
--look by the parent, then P31 is used for the category
if (not catID and parentID and season) then
p31 = getStatementForTime(parentID, 'P31', timeOfRace)
elseif not season then --it is the team look in the team directly
end
if p31 and data.teamCats[p31.mainsnak.datavalue.value.id] then
catID = p31.mainsnak.datavalue.value.id
end
-- Find country if needed
if country or data.natTeamCats[catID] then
countryID = getCountryID(teamID, timeOfRace)
end
if countryID and
if countryID=='Q145' then
name = getCountryName('Q23666')
Line 1.000 ⟶ 1.002:
name = getCountryName(countryID)
end
local t={Q20738667=34, Q54555994=35, Q99658502=36}
if t[catID] then --add U23, U19, B, (note: why "B" and not B)
name = name ..' '..translate("headoftableIII",t[catID])
end
sitelink = getRawTeamLink(teamID)
else
-- It is not a national cycling team
local isLocal
if season and
sitelink = wikibase.getSitelink(teamID)
name, isLocal = getOfficialName(teamID, timeOfRace,true) --problem here is that the label will be used if no official name, official name of the parent would actually be better...
if not sitelink and parentID then
sitelink = wikibase.getSitelink(parentID)
end
else
if parentID then -- try parent team first
sitelink = wikibase.getSitelink(parentID)
Line 1.050 ⟶ 1.026:
end
if not name or (not isLocal and
local partName, partIsLocal = getOfficialName(teamID, timeOfRace)
if partName and (not name or partIsLocal) then
Line 1.077 ⟶ 1.053:
end
end
return sitelink, catID, countryID
end
Line 1.098 ⟶ 1.074:
end
local function getReference(lf,statement, outputLocal)
local function formatRefDate(date, precision)
if precision == 9 then -- Precision is year
Line 1.183 ⟶ 1.159:
refargs.name = refText
end
return
end
end
end
--Some wikipedia, like WP:ar, don't use model like
--{{#invoke:Cycling race/infobox|Q123}}
--But have the module included in another module
--{{#invoke:wikidata|Cycling race/infobox|...
--in this case frame does not refer to the arguments of /infobox but to the wanted ones
--read https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#frame-object
local function get_arg(index, lf, number)
if lf.args[index] then
if number then
return tonumber(lf.args[index])
else
return string.gsub(lf.args[index], "%c", "")
end
end
return nil
end
Line 1.248 ⟶ 1.242:
local function getPlaceLink(placeID,timeOfRace)
local sitelink = wikibase.getSitelink(placeID)
local name = country_name_from_list(placeID)
if name==nil then
name=getOfficialName(placeID, timeOfRace,nil,true) --name should be in the right language
end
Line 1.274 ⟶ 1.264:
-- ClassID --> ClassLink
-- some WPs use a unique article for this case
local function classLinkFn(
local link, label
if wiki~="fr" then --not used
Line 1.282 ⟶ 1.272:
end
if
if wiki=="fr" then
label="JO"
Line 1.289 ⟶ 1.279:
end
else
label = getLabelFallback(
end
Line 1.302 ⟶ 1.292:
end
if wiki == "ar" then-- right now Q22348500 has no link in "ar"
link = make_IllWD2_link(
end
return link
Line 1.308 ⟶ 1.298:
--[[ Get local content to a infoboxe from template args ]]
local function getLocalContent(contents, args)
for _, content in pairs(contents) do
local name = content.name
if not name then
local nameNoShy = string.gsub(name, '­', '') -- filter soft hyphen out
local nameNoShyLow, name_pluralNoShyLow
Line 1.353 ⟶ 1.342:
end
local function checkDis(q) --discipline
dis="road"
local sport_id=nil
sport_id=q.P641[1].datavalue.value.id
elseif q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then --fallback
sport_id=q.P642[1].datavalue.value.id
end
if sport_id then
if sport_id == 'Q520611' or sport_id =='Q1031445' then
onlyRoad=false
dis="mountainBike"
elseif
onlyRoad=false
dis="cycloCross"
elseif
onlyRoad=false
dis="track"
Line 1.376 ⟶ 1.372:
if q and q.P54 and q.P54[1].snaktype == 'value' then -- P54 is member of sports team
teamID = q.P54[1].datavalue.value.id
link, catID, countryID
else
for _, s in statements(riderID, 'P54') do
Line 1.385 ⟶ 1.381:
if dis=='road' then --by default
teamID = p54.mainsnak.datavalue.value.id
link, catID, countryID
end
end
Line 1.391 ⟶ 1.387:
end
end
return link, teamID, catID, countryID
end
Line 1.435 ⟶ 1.431:
local link=''
local Sitelink = wikibase.getSitelink(Qnumber) -- link to WParticle
local Label = getLabelFallback(Qnumber
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(string.gsub(Sitelink, "%b()", "")..' ') .. "]]"
Line 1.451 ⟶ 1.447:
local function getCountryBool(no_country_list)
local country = true
if no_country_list then
for _, value in pairs(no_country_list) do -- get data if country should be printed in this wiki if value == wiki then country = false end
end
end
return country
end
local function
local error_message
if
error_message = func_error_message( 1)
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
Line 1.467 ⟶ 1.464:
error_message = ' [[File:Exclam icon.svg|12px|'.. error_message .. ']]'
end
return error_message
end
local function tableA(s)
local error_message=handle_error_message(s)
local t = mw.html.create('table')
:addClass('sortable')
:attr('cellpadding', '0')
Line 1.475 ⟶ 1.477:
:css('padding', '3px')
local title =translate(s.header_function,s.header_1, s.
if s.header_1 == 19 and wiki == "ar" then title = title .. " " .. s.year end
local wd_link = mw.html.create('span'):cssText('float:left; margin: 0 5px'):wikitext(wdLink(s.item..'#'..s.property))
if arwiki_totemplate then wd_link = wdLink(s.item..'#'..s.property) end
local caption =
:cssText('padding:2px; text-align:center; line-height: 1.8em;')
:css('background-color',backgroundColor)
Line 1.487 ⟶ 1.489:
local country=getCountryBool(s.no_country)
local header =
for i,k in ipairs(s.header_2) do
if i == s.country_column then
if
header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function,k,s.
end
end
Line 1.499 ⟶ 1.501:
local column = header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function,k,s.
if s.data_sort_type[i] == 'unsortable' then
column:addClass('unsortable')
Line 1.506 ⟶ 1.508:
end
return
end
local function tableB(s) --for startlist
local error_message
local roll = true
for _, value in pairs(s.no_roll_startlist) do -- get data if country should be printed in this wiki
Line 1.541 ⟶ 1.536:
local tSpan=tDiv:wikitext(tostring(wdlink_span))
tDiv:wikitext(translate("startlist",1,s.w_race or false))
tDiv = rollTable1:tag('div'):addClass("NavContent"):cssText("margin:0; background:white; display:block; text-align:left;")
Line 1.563 ⟶ 1.558:
:attr('colspan','3'):attr('align','center')
tCell:node(wdlink_span)
tCell:wikitext(translate("startlist",1,s.
local tRow=tCell:tag('tr')
Line 1.577 ⟶ 1.572:
{'Flag of Japan (1870–1999).svg', '+1870-02-27', '+1999-08-12'}},
Q20 = {'NOR', {'Flag of Norway.svg', '+1821-07-13'}},
Q27 = {'IRL', {'Flag of Ireland.svg', '+
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Ireland.svg', '+1937-12-29', '+1980-07-19'}},
Q28 = {'HUN', {'Flag of Hungary.svg', '+1957-05-23'}},
Q29 = {'ESP', {'Flag of Spain.svg', '+1981-12-06'},
Line 1.586 ⟶ 1.583:
{'Flag of Spain (1785–1873, 1875–1931).svg', '+1874', '+1931-04-13'}},
Q30 = {'USA', {'Flag of the United States.svg', '+1960-07-04'}},
Q31 = {'BEL', {'Flag of Belgium (civil).svg'
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Belgium (civil).svg', '+1800', '+1980-07-19'}},
Q32 = {'LUX', {'Flag of Luxembourg.svg'}},
Q33 = {'FIN', {'Flag of Finland.svg', '+1918-05-29'}},
Q34 = {'SWE', {'Flag of Sweden.svg'}},
Q35 = {'DEN', {'Flag of Denmark.svg'
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Denmark.svg', '+1800', '+1980-07-19'}},
Q36 = {'POL', {'Flag of Poland.svg'}},
Q37 = {'LTU', {'Flag of Lithuania.svg', '+2004-09-01'},
{'Flag of Lithuania (1988-2004).svg', '+1990-03-11', '+2004-09-01'}},
Q38 = {'ITA', {'Flag of Italy.svg', '+
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Italy.svg', '+1946-06-19', '+1980-07-19'},
{'Flag of Italy (1861–1946).svg', '+1861', '+1946-06-19'}},
Q39 = {'SUI', {'Flag of Switzerland.svg', '+
{'
{'Flag of Switzerland.svg', '+1879-01-01', '+1980-07-19'}},
Q40 = {'AUT', {'Flag of Austria.svg', '+1945-05-01'},
{'Flag of Austria.svg', '+1919-10-21', '+1938-03-13'}},
Line 1.603 ⟶ 1.607:
Q43 = {'TUR', {'Flag of Turkey.svg'}},
Q45 = {'POR', {'Flag of Portugal.svg', '+1911-06-30'}},
Q55 = {'NED', {'Flag of the Netherlands.svg', '+
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the Netherlands.svg', '+1806', '+1980-07-19'}},
Q77 = {'URU', {'Flag of Uruguay.svg'}},
Q96 = {'MEX', {'Flag of Mexico.svg', '+1968-09-16'},
Line 1.610 ⟶ 1.616:
Q115 = {'ETH', {'Flag of Ethiopia.svg', '+1996-10-31'}},
Q117 = {'GHA', {'Flag of Ghana.svg', '+1966-02-28'}},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of France.svg', '+1794-05-20', '+1980-07-19'}},
Q145 = {'GBR', {'Flag of the United Kingdom (3-5).svg', '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the United Kingdom (3-5).svg', '+1980-07-19'}},
Q148 = {'CHN', {"Flag of the People's Republic of China.svg", '+1985'}},
Q155 = {'BRA', {'Flag of Brazil.svg', '+1992-05-11'},
Line 1.651 ⟶ 1.662:
Q232 = {'KAZ', {'Flag of Kazakhstan.svg'}},
Q235 = {'MON', {'Flag of Monaco.svg'}},
Q238 = {'SMR', {'Flag of San Marino.svg'
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of San Marino.svg', '+1980-07-19'}},
Q241 = {'CUB', {'Flag of Cuba.svg'}},
Q244 = {'BAR', {'Flag of Barbados.svg'}},
Line 1.662 ⟶ 1.675:
Q334 = {'SGP', {'Flag of Singapore.svg'}},
Q347 = {'LIE', {'Flag of Liechtenstein.svg'}},
Q398 = {'BRN ', {'Flag of Bahrain.svg',
{'Flag of Bahrain (1972–2002).svg', '+1972-08-19', '+2002-02-16'}},
Q403 = {'SRB', {'Flag of Serbia.svg', '+2004-08-18'},
{'Flag of Serbia (1992–2004).svg', '+1992-04-27', '+2004-08-17'}},
Q408 = {'AUS', {'Flag of Australia.svg'
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Australia.svg', '+1980-07-19'}},
Q414 = {'ARG', {'Flag of Argentina.svg'}},
Q419 = {'PER', {'Flag of Peru.svg', '+1950'},
Line 1.681 ⟶ 1.697:
Q750 = {'BOL', {'Flag of Bolivia.svg', '+1851-10-31'}},
Q754 = {'TTO', {'Flag of Trinidad and Tobago.svg'}},
Q769 = {'GRN', {'Flag of Grenada.svg'}},
Q774 = {'GUA', {'Flag of Guatemala.svg'}},
Q778 = {'BAH', {'Flag of the Bahamas.svg'}, '+1973-07-10'},
Line 1.701 ⟶ 1.718:
Q881 = {'VIE', {'Flag of Vietnam.svg', '+1976-02-07'}},
Q884 = {'KOR', {'Flag of South Korea.svg', '+1997-10'}},
Q889 = {'AFG', {'Flag of Afghanistan (2013–2021).svg','+2013-08-19'},
{'Flag of Afghanistan (2004-2021, Variant).svg', '+2004-10-09', '+2013-08-18'},
{'Flag of Afghanistan (2002–2004, variant with golden arms).svg', '+2002-06-27', '+2004-10-08'},
{'Flag of Afghanistan (2002–2004).svg', '+2002-01-28', '+2002-06-26'},
{'Flag of Afghanistan (2001–2002).svg', '+2001-11-13', '+2002-01-27'},
{'Flag of Afghanistan (1992–2001).svg', '+1992-12-07', '+2002-01-26'},
{'Flag of Afghanistan (1992).svg', '+1992-04-27', '+1992-12-06'},
{'Flag of Afghanistan (1987–1992).svg', '+1987-11-30', '+1992-04-26'},
{'Flag of Afghanistan (1980–1987).svg', '+1980-04-22', '+1987-11-29'},
{'Flag of Afghanistan (1978–1980).svg', '+1978-10-19', '+1980-04-21'},
{'Flag of Afghanistan (1978).svg', '+1978-04-27', '+1978-10-18'},
{'Flag of Afghanistan (1974–1978).svg', '+1974-05-9', '+19780-4-26'},
{'Flag of Afghanistan (1973–1974).svg', '+1973-03-17', '+1974-05-8'},
{'Flag of Afghanistan (1931–1973).svg', '+1930-03-27', '+1973-03-16'},
{'Flag of Afghanistan (1929–1931).svg', '+1929-01-1', '+1930-03-26'}},
Q902 = {'BAN ', {'Flag of Bangladesh.svg','+1972-01-17'},
{'Flag of Bangladesh (1971).svg', '+1971-03-06', '+1972-01-16'}},
Q916 = {'ANG', {'Flag of Angola.svg', '+1975-11-11'}},
Q917 = {'BHU ', {'Flag of Bhutan.svg','+1972-06-08'},
{'Flag of Bhutan (1956–1969).svg', '+1956-07-01', '+1972-06-07'},
{'Flag of Bhutan (1949–1956).svg', '+1949-01-01', '+1956-06-30'}},
Q921 = {'BRU', {'Flag of Brunei.svg', '+1959-09-29'}},
Q928 = {'PHI', {'Flag of the Philippines.svg', '+1998'}},
Line 1.730 ⟶ 1.767:
Q8646 = {'HKG', {'Flag of Hong Kong.svg'}},
Q25228 = {'AIA', {'Flag of Anguilla.svg'}},
Q29999 = {'NED', {'Flag of the Netherlands.svg', '+
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the Netherlands.svg', '+1690', '+1980-07-19'}},
Q33946 = {'TCH', {'Flag of the Czech Republic.svg', '+1920'}}, -- Czechoslovakia (1918–1992)
Q36704 = {'YUG', {'Flag of Yugoslavia (1992–2003).svg', '+1992-04-27', '+2003-02-04'}, --Yugoslavia
{'Flag of Yugoslavia (1943–1992).svg', '+1946', '+1992-04-27'}},
Q41304 = {'GER', {'Flag of Germany (3-2 aspect ratio).svg', '+1918-11-09'}}, -- Weimar Republic
Q47588 = {'EU', {'Flag_of_the_Basque_Country.svg'}},
Q83286 = {'YUG', {'Flag of Yugoslavia (1943–1992).svg'}}, --Socialist Federal Republic of Yugoslavia
Q172579 = {'ITA', {'Flag of Italy (1861–1946).svg'}}, --Kingdom of Italy (1861-1946)
Line 1.786 ⟶ 1.826:
end
elseif not date then
local p41 =
if p41
result = '[[File:' .. p41
if arwiki_totemplate then
result = '{{flagicon image|' .. p41
end
end
Line 1.800 ⟶ 1.840:
if arwiki_totemplate then
result = '{{flagicon image|' .. p41.mainsnak.datavalue.value .. '}}'
end
end
end
return result .. trackingCategory
Line 1.817 ⟶ 1.857:
--get link, assumed for a country the label is equal to the link, where not correct in the blacklist
--if the black list becomes too long, we could create a second list for the sitelinks
countryName=country_name_from_list(countryID)
countryName = mw.wikibase.getSitelink(countryID)
end
Line 1.842 ⟶ 1.878:
-- 6. item of the Wikipedia article of that jersey
--timeOfRace = '+1968-07-01T00:00:00Z'
timeOfRace = string.match(timeOfRace, "+%d%d%d%d") or ''
for _, v in pairs(item) do
for _, value in pairs(data.stageinfobox_jersey) do
if v == value[1] then
if winner_classification == value[2] then
Line 1.988 ⟶ 1.947:
if p18[1] and p18[1].mainsnak.snaktype == 'value' then
jersey_string = jersey_string .. '[[File:' .. p18[1].mainsnak.datavalue.value .. '|20px'
jersey_name = getLabelFallback(v
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
Line 2.000 ⟶ 1.959:
end -- function end
--=== E) Other (winner
local function isHuman(riderId)
local isHuman = false
Line 2.015 ⟶ 1.974:
end
local function isCountry(
local isCountry = false
if
local p31 = wikibase.getBestStatements(
for _, iOf in pairs (p31) do
-- exception Hong-Kong and Taiwan
Line 2.030 ⟶ 1.989:
end
local function isWomenrace(raceID) --for translation
for _, p2094 in statements(raceID, 'P2094') do
if p2094.mainsnak.datavalue.value.id == "Q1451845" then
return true
end
end
return false
end
local function isWomenteam(teamID, timeOfRace)
if isWomenrace(teamID) then --simplest way
return true
end
--else we can identify with teamCat
local _, catID= getTeamLinkCat(teamID, timeOfRace, false)
if data.womenCats[catID] then
return true
end
return false
Line 2.054 ⟶ 2.025:
end
end
end
end
if wiki=='eu' and (countryID=="Q142" or countryID=="Q29") then --look for people or location in the Basque Country, quite expensive function
local birth_place = firstValue(wID, 'P19','id') --birth place
if data.BasqueTown[birth_place] then
return "Q47588"
end
end
Line 2.083 ⟶ 2.061:
end
local function winner(lf,raceID, winners, timeOfRace, country, WDlink_on, team, ref, winnersId)
local p1346 = wikibase.getAllStatements(raceID, 'P1346') -- P1346 is 'winner'
for _, winner in pairs(p1346) do
Line 2.091 ⟶ 2.069:
if q then
local _, disqualified =isdisqualified(winner,q)
local propertyOf=nil
if q.P2501 and q.P2501[1].snaktype == 'value' then
propertyOf=q.P2501 --result
elseif q.P828 and q.P828[1].snaktype == 'value' then --cause, for cancellation
propertyOf=q.P828
elseif q.P642 and q.P642[1].snaktype == 'value' then
propertyOf=q.P642 --fallback
end
if
for _,
wOf =
if not wOf then
-- Try P1346 (winner) instead
Line 2.107 ⟶ 2.093:
if winners[wOf] then
if wID then
local reference = ref and getReference(lf,winner)
local _, countryID
if isHuman(wID) then
Line 2.138 ⟶ 2.124:
countryID = getNationality(wID, timeOfRace,q)
else
end
end
Line 2.183 ⟶ 2.166:
local function sortAndConcat(t_Body, resultTable)
table.sort(t_Body, function(a, b) return a[
for _, m in ipairs(t_Body) do resultTable:node(m[
return resultTable
end
--------- Definition sub-functions for calendar and victory ------
local function getTimeOfRace(raceID, mandatory, p582_prio)
local timeOfRace
if p582_prio then --for case like UCI Europe Tour 2006 (Q1455600) where most of the competition is in the next year
properties={'P582','P585','P580'}
else
properties={'P580','P585','P582'}
end
for _, prop in ipairs(properties) do
timeOfRace= firstValue(raceID, prop, 'time')
if timeOfRace ~= nil then return timeOfRace end
end
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de','es'}) --language is not important here, it is just to get the year
if link then
local year = string.match(link, '%d%d%d%d')
if year then
return year .. '-01-01T00:00:00Z'
end
end
if
end
if mandatory then
error('> Wikidata is missing data about start time (P580) or point in time (P582)')
end
return nil
end
local function
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
local style1, style2
if functionName=="infobox" then
style1='verylong' --force to display the year
style2='long'
else
style1='small'
style2='small'
end
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime,
if functionName==nil or functionName=='infobox' then --calendar, infobox
else --victory, general classification
return endTime, eTime, true
end
else
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
end
end
return nil
end
local function fn_date(entityID, functionName) --to move as a general function
local tempdate, timeOfRace, _ = get_formatted_date(entityID, functionName) --is there a reason why timeofrace cannot be sTime??
local _, _, y, m, d = string.find(timeOfRace or "", "(%d+)-(%d+)-(%d+)")
if sortkey =='' then sortkey = '0000' end
local tCell = mw.html.create('td'):attr('data-sort-value',sortkey)
:cssText("style=text-align:right;padding:0 0.5em")
:wikitext(tempdate)
return timeOfRace, tostring(tCell), sortkey
end
local function fn_country(entityID, timeOfRace,
-- This function gives countries where the race take place
-- parentID taken from fn_race, optional
local country_str, country_name, country_flag
local cssCell="text-align:" .. textalign .. ";padding:0 0.5em"
local tCell= mw.html.create('td'):cssText(cssCell)
local countryID = getCountryID(entityID, timeOfRace)
if countryID==nil then countryID = getCountryID(parentID, timeOfRace) end
if countryID then
country_flag=flag(countryID, timeOfRace)
country_str=country_flag
country_name = getCountryName(countryID)
if
tCell:attr('data-sort-value',country_name)
country_str=country_str.." "..country_name
end
end
else
country_flag="no flag"
end
if country==false then
tCell:wikitext(country_flag.." "..(raceCell or ''))
country_name=''
else
if
tCell:wikitext(country_str)
end
end
return country_flag, country_name, tCell
end
Line 2.395 ⟶ 2.368:
prefix=''; postfix='' --general classification
listOfProperty={'P2561','P1448'}
--main race link is in the parent --can be improved
instanceOfTemp = p31.mainsnak.datavalue.value.id
if instanceOfTemp ~= "Q27020041" and instanceOfTemp ~= 'Q88903067' and data.class_dic[instanceOfTemp]==nil then --but the main race
instanceOf=instanceOfTemp
end
end
--get information from the parent
if instanceOf then
Line 2.433 ⟶ 2.402:
if label==nil then
label=getLabelFallback(instanceOf,lang_priority) --the case of 'ar' should be handled in lang_priority
if not label then
label
end
end
Line 2.471 ⟶ 2.439:
--affect the label
if label==nil then
label=
end
--look for link to the race if nothing
Line 2.522 ⟶ 2.486:
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
if data.UCI_Circuits[parentCircuitID] then
displayedCircuitID=circuitID
end
Line 2.529 ⟶ 2.493:
else --for instance Flèche wallonne
if q then
if q.
displayedCircuitID = q.
elseif q.P642 and q.P642[1].snaktype == 'value' and q.P642[1].datavalue.value.id then --fallback
displayedCircuitID = q.P642[1].datavalue.value.id
end
end
Line 2.564 ⟶ 2.530:
end
local function getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
local period
if sTime and eTime then
if startTime==endTime then
period=startTime --only (1990)
else
period=startTime .. '-'..endTime
end
elseif sTime then
period=startTime .. '-'
elseif eTime then
period='-'..endTime
else
period=""
end
if brackets and period~="" then
period="("..period..")"
end
return period
end
local function getPeriodSub(sTime, eTime, brackets)
local startTime, endTime, y, m, y2, m2
Line 2.584 ⟶ 2.572:
end
end
return getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
end
local function getPeriodSub_season(sTime, eTime, brackets)
local startTime, endTime
if sTime and eTime then
elseif sTime then
startTime=funcDate(sTime, 'small')
elseif eTime then
endTime=funcDate(eTime, 'small')
end
return getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
end
-- for display period with only year, for instance (2020-2021)
local function getPeriod(q, brackets,season)
local sTime, eTime = getStartEndfromQuali(q)
if season then
return getPeriodSub_season(sTime, eTime, brackets), sTime
else
return getPeriodSub(sTime, eTime, brackets), sTime
end
end
Line 2.635 ⟶ 2.605:
local classID = p279.mainsnak.datavalue.value.id
if data.class_dic[classID]~=nil then
circuitID=classToCircuit(classID, entityID, false, p279.qualifiers)
classLink=classLinkFn(classID,circuitID)
table.insert(classTable, {sTime, classStr, circuitID})
end
Line 2.652 ⟶ 2.622:
if not str then str='' else str=str..'<br>' end
str=str..class[2]
if class[3] then
circuitLink=WPlinkpure(class[3]) end
end
return str, circuitLink, #classTable
Line 2.659 ⟶ 2.631:
local function fn_race(entityID,displayed_class,display_class,timeOfRace, functionName,country)--return link to the race and class
--first function read from victory main
local Sitelink, entity_type, classID, stageID, race_tCell, class_tCell, parentID
for _, p31 in statements(entityID, 'P31') do
if data.stages[p31.mainsnak.datavalue.value.id] then
entity_type = 'stage' --then the class is one stage above!
classID=
stageID= entityID --everything slide from one rank
entityID = parentID
end
end
--Now we have the class and know the type of race it is
Line 2.681 ⟶ 2.646:
Sitelink=getMainRaceLink(entityID,entity_type,stageID, functionName,timeOfRace)
else
classID=firstValue(entityID, 'P279', 'id')
Sitelink=getMainRaceLink(entityID,data.class_dic[classID],nil, functionName,timeOfRace) end
if country~=false then
local tCell=mw.html.create('td'):cssText("text-align:".. textalign ..";padding:0 2.3em"):wikitext(Sitelink)
else
end
Line 2.695 ⟶ 2.661:
local classLink=classLinkFn(classID,circuitID) --return '' worst case
:attr('data-sort-value',data.class_sort[classID]) --sortkey
:cssText("text-align:center;padding:0 0.5em")
:wikitext(classLink)
end
return parentID, race_tCell, class_tCell
end
local function fn_rider(lf,entityID,timeOfRace,display_team,only_winner,country)
local winners, countrytemp, result
local WDlink_on = (wiki == "mk" or wiki == "ja")
Line 2.718 ⟶ 2.682:
end
if country==nil then countrytemp=false else countrytemp=country end
winner(lf,entityID, winners, timeOfRace, countrytemp, WDlink_on, display_team, true)
local tCell=mw.html.create('td'):css("text-align:".. textalign ..";padding:0 0.5em")
Line 2.779 ⟶ 2.743:
local function calculateAge(birthDate, endDate) --test future
local eYear, eMonth, eDay
local longestcontractyears=10
if birthDate then
if not endDate then
Line 2.813 ⟶ 2.778:
if alreadyThisYear then
return eYear-tYear, tYear, eYear+
else
return eYear-tYear-1, tYear, eYear+
end
else
return 0, tYear, eYear+
end
end
Line 2.859 ⟶ 2.824:
end
local function listOfWinners(itemID,t, team,lf, mandatory_prop)
local winners = { Q20882667 = '',}-- Q20882667 is 'overall winner general classification'
local winnersId={ Q20882667 = '',}--to detect disqualification
local WDlink_on, sitelink
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
Line 2.892 ⟶ 2.856:
winners.Q20882667=''
winnersId.Q20882667=''
winner(lf,t.race[num]['raceId'], winners, t.race[num]['raceDate'], false, WDlink_on, nil, nil, winnersId )
if t.race[num]['future']==false then --in the past
if winnersId.Q20882667~="Q30108381" and winnersId.Q20882667~="Q54806642" then --cancelled
numberOfEditions=numberOfEditions+1
lastRunEdition=num
Line 2.903 ⟶ 2.867:
winnerId=winnersId.Q20882667
if winnerId~=nil and winnerId~='' and winnerId~='Q666' and winnerId~='Q30108381' and winnersId.Q20882667~="Q54806642" then --code for disqualification
if not t.vainqueur[winnerId] then
t.vainqueur[winnerId]={}
Line 2.912 ⟶ 2.876:
end
end
else --for team
for num=1,#t.race do
if t.race[num]['future']==false then --in the past
if mandatory_prop==nil then
numberOfEditions=num
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
else
local ss = wikibase.getAllStatements(t.race[num]['raceId'], mandatory_prop)
if #ss >0 then
numberOfEditions=num
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
end
end
end
end
end
local monthId=firstValue(itemID, 'P2922','id')
if monthId then
t.lastEditionMonth=getLabelFallback(monthId
else
t.lastEditionMonth=contentLanguage:formatDate("M", lastEditionDate)
end
t.lastEditionYear=funcDate(lastEditionDate,"onlyyear")
end
t.numberOfEditions=numberOfEditions
if not team then evaluateWinnerMax(t) end
Line 2.932 ⟶ 2.910:
if lastRunEdition then
t.lastWinner=lastWinner or '' --t.vainqueur[lastRunEdition]['link']
sitelink = wikibase.getSitelink(t.lastID)
if sitelink ~= nil then
t.lastLink = "[[" .. sitelink .. "]]"
Line 2.941 ⟶ 2.920:
if nextEdition then
sitelink = wikibase.getSitelink(t.nextID)
if sitelink ~= nil then
t.nextLink = "[[" .. sitelink .. "]]"
Line 2.950 ⟶ 2.930:
end
local function getPeriodicity(itemID, t)
local p = wikibase.getBestStatements(itemID, 'P2257')
if p[1] and p[1].mainsnak.snaktype == 'value' then
Line 2.980 ⟶ 2.960:
end
local function getFormerNames(itemID, PID, season)
local listOfNames={}
local
local kk=1
while #listOfNames == 0 and kk<=#
lang=
kk=kk+1
for _, prop in ipairs({PID}) do
Line 2.999 ⟶ 2.973:
officialname = p1813.mainsnak.datavalue.value.text
if lang==language then --only exact language
local period, sTime=getPeriod(p1813.qualifiers, nil, season)
if not sTime then sTime="+1900-01-01T00:00:00Z" end --first
table.insert(listOfNames,{sTime, period, officialname, language})
Line 3.011 ⟶ 2.985:
local function officialSite(itemID)
local
if url then
return '['..url.." "..translate("raceinfobox",3)..']'
end
return nil
end
Line 3.061 ⟶ 3.004:
end
local function checkm(p, in_cm)
local m, unit, res
if p[1] and p[1].mainsnak.snaktype == 'value' then
m = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11573' then
elseif unit=='http://www.wikidata.org/entity/Q174728' then --cm
end
if res then
if in_cm then
res=res*100
end
return res
end
end
return nil
end
local function checkkmh(p)
if p[1] and p[1].mainsnak.snaktype == 'value' then
kmh = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q180154' then -- Q180154 is 'kilometre per hour'
return kmh
end
end
Line 3.087 ⟶ 3.047:
end
local function
local text
if e then
text = contentLanguage:formatNum(e)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
local t=translate("unit",trans)
if string.find( t," ")==1 then
text = text ..t
else
text = text .. ' ' ..t
end
end
end
return text
end
local function getHeight(entityID, in_cm)
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
return formatNumber(checkm(p, in_cm), true, 11)
else
return formatNumber(checkm(p, in_cm), true, 9)
end
end
local function getWeight(entityID)
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
return formatNumber(checkkg(p), true, 10)
end
local function getDistance(raceID, addUnit)
local p = mw.wikibase.getBestStatements(raceID, 'P3157') -- P3157 is 'event distance'
local km =checkkm(p)
if not km then --for stage race we can sum the distances from each stage
local stagep, tempkm
for _, p527 in statements(raceID,'P527') do
tempkm=checkkm(stagep)
if tempkm then
if not km then km=0 end
end
end
end
return formatNumber(km, addUnit, 8), km
end
local function getElevation(raceID)
local p =mw.wikibase.getBestStatements(raceID, 'P7297')
return formatNumber(checkm(p), true, 9)
end
local function getSpeed(raceID, addUnit,kmdistance, property)
local timeOfRace
local p = mw.wikibase.getBestStatements(raceID, 'P2052') -- P2052 is 'speed'
local kmh
if not kmh and kmdistance then --calculate speed
local p2321= wikibase.getBestStatements(raceID, property) --winner supposed to be first of overall classification
if p2321 and p2321[1] and p2321[1].mainsnak.snaktype == 'value' then
Line 3.211 ⟶ 3.122:
if timeOfRace then
kmh=math.modf(1000*kmdistance/(timeOfRace/3600))/1000
end
end
end
return formatNumber(kmh, addUnit, 5)
end
local function getGenderCode(riderID, default)
local gender=default -- default is for teams, n or f
local
if g == 'Q6581097' then gender = 'm' -- Male
elseif g == 'Q6581072' then gender = 'f' -- Female
end
return gender
end
Line 3.299 ⟶ 3.196:
end
local function func_error_message(x)
local l10nDef = {
["fr"] = {"La propriété <1> est manquante dans l'item <2> (<3>)"},
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
["ar"] = {'الخاصية <1> غير موجودة في العنصر "<2>" (<3>)'},
Line 3.311 ⟶ 3.209:
local function getMissingLabelTrackingCategory()
local l10nDef = {
["
["
["
}
local l10n = l10nDef[
if not l10n then
l10n = ''
Line 3.332 ⟶ 3.230:
end
if inp == "0" then
this_label = translate("func_prologue",1)
else
this_label = stageLink(inp, a, b)
Line 3.414 ⟶ 3.312:
--== Functions for infobox
-- functions for infoboxs
local function get_others_dic()
return {
{ name = translate("infobox",29,w_race)}, -- picture
{ name = translate("infobox",30,w_race)}, -- caption
{ name = translate("infobox",31,w_race)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,w_race)}, -- caption map
{ name = translate("infobox",30,w_race)}, -- caption sectional
}
end
local function infoGetOthers(others, entityID)
if not others[1].content then --picture
Line 3.494 ⟶ 3.403:
if width==nil then width= '320px' end
local tab = mw.html.create('table'):addClass('infobox')
if wiki == "eo" then
tab:cssText(standardtablecss):css('width','23em')
else
cellpadding=tostring(cellpadding or 4)
Line 3.582 ⟶ 3.490:
local function wdDoc(tab, s, translation, ID)
local tCell=tab:tag('tr'):tag('td')
local tC, link
local commons_cat=firstValue(ID, 'P373', 'id')
Line 3.588 ⟶ 3.496:
commons_cat=string.gsub(commons_cat, '%s', '_')
local icon="[[File:Commons-logo.svg|12px|link=https://commons.wikimedia.org/wiki/Category:"..commons_cat.."]]"
tC=tCell:cssText('text-align:left; border-top:3px solid '..backgroundColor..'; font-size:
:wikitext(icon):tag('td')
else
tC=tCell:attr('colspan','2')
end
if wiki == "ar" then
link =
else
link = "[[" .. s .. "|" .. translation .. "]] "..wdLink(ID)
end
tC:cssText('text-align:right; border-top:3px solid '..backgroundColor..'; font-size:
:wikitext(link)
end
Line 3.623 ⟶ 3.531:
--Display in a chronological order fields in a table
local function listWPlinkChrono(details, index, entityID, listOfProperty, option, initialYear, display_flag, comma,season)
local period, sTime, value, ID, temp
local list={}
Line 3.636 ⟶ 3.544:
ID=p.mainsnak.datavalue.value.id
if p.qualifiers then
period, sTime=getPeriod( p.qualifiers, true,season)
end
if not sTime then sTime="+"..initialYear.."-01-01T00:00:00Z" end --first
Line 3.643 ⟶ 3.551:
value=wikibase.getLabelByLang(ID, wiki)
elseif option == 'country' then
value=getCountryName(ID)
if display_flag then
value= flag(ID, sTime).." "..
elseif option=='officialname' then
value=getOfficialName(ID, sTime,false) --official name is necessary because of continental team change in ProTeam
Line 3.694 ⟶ 3.601:
-- == Functions for team roster
local function getReason(riderReason, riderRef, p527,timeOfRace,riderEnd,lf) --reason for end
local listofproperty={'P1642','P1643','P1534'}
local outTable={}
Line 3.714 ⟶ 3.621:
end
if riderReason then
local label =
riderRef = getReference(lf,p527, 1)
riderReason = ', ' .. label
end
Line 3.727 ⟶ 3.634:
for _, q in qualifiers(v, 'P39') do
stagiaire = q.value.id
local label = string.gsub(
Sitelink = wikibase.getSitelink('Q2328847')
if Sitelink then
Line 3.799 ⟶ 3.706:
end
if not done then
names = tostring(c)..' '..tostring(a)..' '..tostring(b)
done = true
end
Line 3.827 ⟶ 3.734:
if wikiIsSlavic and correctlanguage then
local label = wikibase.getLabelByLang(riderID, wiki)
if
local nametable = mw.text.split(label, ",")
if nametable[2] then --there is a coma so the lastname is first
Line 3.838 ⟶ 3.742:
end
end
end
--all other cases
label = getLabelFallback(riderID)
return findLastName(label,wiki)
end
--== V) Main functions ==
--=== A) Function race reference ===
local function race_reference(raceID,lf)
-- Allow to display the reference below the classifications --
local bases={
Line 3.852 ⟶ 3.756:
{"Cycling Quotient", "P2648", "http://www.cqranking.com/men/asp/gen/race.asp?raceid="},
{"Cycling Archives", "P2330", "http://www.cyclingarchives.com/ritfiche.php?ritid="},
{"Cycling Quotient", "P2708", "http://www.cqranking.com/women/asp/gen/race.asp?raceid="},
-- cycling team
{"ProCyclingStats", "P2328", "http://www.procyclingstats.com/team/"},
{"Cycling Quotient", "P2649", ""}, --The entire link is indicated in full
{"Cycling Archives", "P2331", "http://www.cyclingarchives.com/ploegfiche.php?id="}
}
local links = {}
Line 3.860 ⟶ 3.768:
if p[1] and p[1].mainsnak.snaktype == 'value' then
if base[2]=="P2648" and p[1].mainsnak.datavalue.value=="1" then --code for general reference of results
ref=getReference(lf,p[1], 1)
if ref then table.insert(links, ref) end
else
Line 3.879 ⟶ 3.787:
function p.calendarcustom(frame)
local headers={2} --date
local calendarID, lf =get_and_checkID(frame)
local display_numbering=false --default
local country_column=2
if istrue(
display_numbering=true
table.insert(headers, 3)
Line 3.894 ⟶ 3.798:
--no_country modify the way the country is displayed
local no_country={}
if istrue(
no_country={wiki}
end
Line 3.903 ⟶ 3.807:
local display_class=false
if istrue(
display_class=true
table.insert(headers, 6)
Line 3.910 ⟶ 3.814:
table.insert(headers, 7) --winner
local only_winner=1
if istrue(
only_winner =0
table.insert(headers, 8) --second
Line 3.917 ⟶ 3.821:
local display_leader=false
if istrue(
display_leader=true
table.insert(headers, 10)
end
local display_team =false
if istrue(
display_team =true
end
Line 3.931 ⟶ 3.835:
end
local
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 3.944 ⟶ 3.848:
only_winner = only_winner,
display_numbering = display_numbering,
displayed_class =nil,
display_team=display_team,
display_class=display_class,
display_leader= display_leader,
lf=lf
}
return calendar_main(s, tableA(s))
Line 3.959 ⟶ 3.862:
----- based on WWTcalendar function -----
----- author: Mr. Ibrahem -----
local calendarID --determined later
local UCI = data.UCIYearToQ
Line 3.967 ⟶ 3.870:
local header_1_number = 12
local tempdic, year, keyk, yeary
local tempdic1 = {
header_2 = {2, 3,5, 4, 7, 8, 9, 10},
Line 3.986 ⟶ 3.889:
for key, v in pairs(UCI) do
year = get_arg(key,frame) --with lf does not work
if not calendarID and year then
if v[year] then
calendarID = v[year]
header_1_number = header_1_tab[key]
display_code = display_code_tab[key]
keyk=key
yeary=year
end
end
Line 4.007 ⟶ 3.911:
if display_code == 1 then
tempdic=tempdic1
if keyk=="UWT" and tonumber(yeary) > 2018 then
tempdic.display_leader=false --no more leader after 2018
tempdic.header_2 ={2, 3,5, 4, 7, 8, 9}
end
else
tempdic=tempdic2
end
if istrue(
tempdic.display_numbering=true
elseif
tempdic.display_numbering=false
end
local
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 4.028 ⟶ 3.936:
only_winner = tempdic.only_winner,
display_numbering = tempdic.display_numbering,
displayed_class = nil, --all
display_team=tempdic.display_team,
display_class=tempdic.display_class,
display_leader=tempdic.display_leader,
lf=lf
}
return calendar_main(s, tableA(s))
Line 4.040 ⟶ 3.947:
function calendar_main(s, resultTable)--Display the UCI women calendar of one year
local lf = s.lf
local calendarID=s.item
local t_Body ={}
local
local temp=firstValue(calendarID, s.property)
if not temp
s.error_message = 2
if wiki == "ar" then return "" end
end
local country=getCountryBool(s.no_country)
----- Begin of the main part of the code
Line 4.056 ⟶ 3.963:
local RaceID = p527.mainsnak.datavalue.value.id
---- Create a row ----
if
local country_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
--create the table
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
tRow:node(date_tCell)
if s.display_numbering == true then
tRow:tag('td'):cssText("text-align:center;padding:0 0.5em"):wikitext(tostring(kk))
end
tRow:node(country_tCell)
if country then tRow:node(
if
local rider_tCell =fn_rider(lf,RaceID,timeOfRace,s.display_team,s.only_winner)
tRow:node(rider_tCell)
if s.display_leader==true then
tRow:node(leader_tCell)
end
---- Add the row to the table
table.insert(t_Body
end
end
return sortAndConcat(t_Body, resultTable)
end
Line 4.094 ⟶ 3.992:
function p.nationalchampionships(frame)
local calendarroadID, calendarITTID, year
local lf=get_lf(frame)
local listOfCalendar={data.NationalRoadCyclingChampionships,data.NationalITTCyclingChampionships}
for ii, thisCalendar in pairs(listOfCalendar) do --road/ITT
for key, v in pairs(thisCalendar) do --look for the key of the dictionnary, here women/men
year = get_arg(key,frame) --with lf does not work
if ((ii==1 and calendarroadID==nil) or (ii==2 and calendarITTID ==nil)) and year then
if v[year] then
if ii==1 then
Line 4.115 ⟶ 4.010:
end
local
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 4.128 ⟶ 4.023:
year = year,
no_country = {}, --no sense here to hide the country
display_team = true,
display_countrylink =
lf=lf
}
return nationalchampionships_main(s,tableA(s))
Line 4.138 ⟶ 4.032:
function nationalchampionships_main(s, resultTable)--Display the list of national champions for one year
local lf = s.lf
local tableChamp
local timeOfRace ='+'..tostring(s.year).."-01-01T00:00:00Z"
local
local country_flag, country_name, country_tCell
local temp=firstValue(s.calendarroadID, s.property)
if not temp
s.error_message = 2
if wiki == "ar" then return "" end
end
local listOfCalendarID={s.calendarroadID, s.calendarITTID}
Line 4.153 ⟶ 4.051:
for _, p527 in statements(thisCalendarID, 'P527') do
thisID = p527.mainsnak.datavalue.value.id
if country_name == nil then country_name="country not found" end
sortkey=string.gsub(country_name, 'É', 'E') --case États Unis
--create the table
if tableChamp[sortkey]==nil then
tableChamp[sortkey]={}
tableChamp[sortkey]['countryname']=
tableChamp[sortkey]['roadwinner']='<td></td>'
tableChamp[sortkey]['ITTwinner']='<td></td>'
Line 4.172 ⟶ 4.070:
end
tableChamp[sortkey]['sitelink']=sitelink
tableChamp[sortkey]['flag']=
end
--fill the table
if tableChamp[sortkey]['thereisawinner']~=true then --all other cases
tableChamp[sortkey]['thereisawinner']=thereisawinner
Line 4.182 ⟶ 4.080:
if ii==1 then
tableChamp[sortkey]['roadwinner']=
else
tableChamp[sortkey]['ITTwinner']=
end
end
Line 4.201 ⟶ 4.099:
tRow:node(thisRow['roadwinner'])
tRow:node(thisRow['ITTwinner'])
table.insert(t_Body
end --no winner
end --end list of key
Line 4.210 ⟶ 4.108:
--=== C) Victory ===
function p.victories(frame)
local
local
local s = {
Line 4.221 ⟶ 4.119:
country_column = 3,
data_sort_type = {'', 'unsortable', '', '', ''}, -- see https://meta.wikimedia.org/wiki/Help:Sorting
item =
property = 'P2522',
no_country = no_country_victories,
lf=lf,
w_race=w_race
}
return victory_main(s ,tableA(s))
Line 4.232 ⟶ 4.129:
function victory_main(s, resultTable)
local lf = s.lf
local _
_, _, s.item = string.find(s.item, "(%w+)")
local temp=firstValue(s.item, s.property,'id')
if not temp
s.error_message = 2
if wiki == "ar" then return "" end
end
local country=getCountryBool(s.no_country)
local t_Body = {}
Line 4.249 ⟶ 4.146:
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
if
--Build the table
tRow:node(date_tCell)
if country==true then
tRow:node(
end
tRow:node(
tRow:node(
tRow:node(rider_tCell)
table.insert(t_Body, {sortkey=date_sortkey, body=tRow})
end --no winner
end --end list of key
Line 4.276 ⟶ 4.169:
--== D) Stage infobox
function p.stageinfobox(frame)
local
local w_race=isWomenrace(stageID)
local details = {
{ name = translate("stageinfobox",2,
{ name = translate("stageinfobox",2,
{ name = translate("stageinfobox",3,
{ name = translate("stageinfobox",4,
{ name = translate("stageinfobox",6,
{ name = translate("stageinfobox",7,
{ name = translate("stageinfobox",9,
{ name = translate("stageinfobox",10,
{ name = translate("stageinfobox",11,
{ name = translate("stageinfobox",12,
{ name = translate("stageinfobox",13,
{ name = translate("stageinfobox",44,
{ name = translate("infobox",32,
{ name = translate("infobox",33,
}
local others = get_others_dic()
--begin of the function
local
Q20882747={'results', 'first'},
Q20882748={'results', 'second'},
Line 4.346 ⟶ 4.229:
}
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
local timeOfRace
local temp = firstValue(
icon = ''
if temp and temp ~= 'Q18131152' then
Line 4.365 ⟶ 4.241:
icon = " [[File:Cycling (road) pictogram.svg|35px]]"
end
details[3].content = typeofstagelogo(
end
local name = getLabelFallback(
if wiki == 'fr' and name ~= nil then
name= mw.ustring.gsub(name, "^(%d+)([re]+)", "%1<sup>%2</sup> ")
Line 4.374 ⟶ 4.250:
name= mw.ustring.gsub(name, "^(%a)",function (x) return mw.ustring.upper(x) end)
infoGetOthers(others,
--name
local race={}
if course==nil then
temp = firstValue(
if temp then
details[2].content =getStageLabel(temp)
raceId = getParentID(stageID) --for instance Tour de France 2020
if raceId then
details[2].content = (details[2].content or '') .. '، '.. WPlinkpure(raceId)
for k, p31 in statements(raceId, 'P31') do --get Tour de France
race[k] = p31.mainsnak.datavalue.value.id --for the jersey
end
Line 4.393 ⟶ 4.270:
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(
if pTime then
details[4].content = funcDate(pTime, 'long')
Line 4.400 ⟶ 4.277:
local kmdistance
if not details[5].content then details[5].content, kmdistance = getDistance(
infoGetCountry(details,6,
infoGetStartEnd(details,7,
infoGetParticipants(details,9,
if not details[11].content then details[11].content = getSpeed(
if not details[12].content then
local elevation=getElevation(
if elevation ~= nil then details[12].content =elevation else details[12].content = nil end
end --Elevation
Line 4.452 ⟶ 4.329:
--Winner
for _, p1346 in statements(
local id_speed, id_time, id_time_gap, id_points_a, id_points_b, type_ofclas, name_ofclas
local q = p1346.qualifiers
Line 4.466 ⟶ 4.343:
local riderLink,riderTeam = subwinner(riderId, timeOfRace, q) --sub function to avoid code in double
-- looks into race item if the winner has a P642 statement for showing the type of winner(points, mountain, ..)
propertyOf=nil
if q.P2501 and q.P2501[1].snaktype == 'value' then
propertyOf=q.P2501
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
propertyOf=q.P642
end
if propertyOf and propertyOf[1].snaktype == 'value' then
for _, vv in pairs(propertyOf) do
local qual = vv.datavalue.value.id
if qual~=nil and deprecated~='deprecated' and
if qual=="Q21686770" and t_s['results']['winner_fighting'][1] ~= "" then
end
type_ofclas=
name_ofclas=
local v=t_s[type_ofclas][name_ofclas]
Line 4.498 ⟶ 4.382:
end
local rank, deprecated, prop, order, thisorder
-- look into P2417, stage classification, then p2321 gen classification
for ii, thistable in ipairs(
if ii==1 then
prop='P2417'
Line 4.510 ⟶ 4.393:
end
for _, p2417 in statements(
local q = p2417.qualifiers
if q.P1352 and q.P1352[1].snaktype == 'value' then
Line 4.536 ⟶ 4.419:
end
for _, v in ipairs(thistable.order) do --order is the list of all classification names
if thistable[v]['link'] then
Line 4.551 ⟶ 4.432:
if t_s.annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab= infoInitTab(width, name, icon)
infoFillOthersDetails(tab, others, details,translate("stageinfobox",1,
-- ranking table, general and stage
Line 4.561 ⟶ 4.442:
tTab=tCell:tag('table'):attr('cellpadding','0'):attr('cellspacing','0'):css('width','100%')
tCell=tTab:tag('tr'):tag('td'):attr('colspan','3')
:cssText('border-bottom:5px solid
:css('font-weight','bold')
:wikitext(translate("stageinfobox",thistable.header,
for key, value in ipairs(thistable.order) do --value is the name of the class
Line 4.576 ⟶ 4.457:
else
local lang = mw.language.getContentLanguage()
v['speed'] = '('.. lang:formatNum(v['speed'])..translate("unit",5,
end
end
if v['points'] then
if v['points'] > 1 then
temp=translate("unit",7,
else
temp=translate("unit",6,
end
v['points'] = v['points']..temp
end
local title, k = string.gsub(translate("stageinfobox",v['translation'],
if k > 0 then title = string.gsub(title, " ", "<br>", 1) end -- 
Line 4.597 ⟶ 4.478:
tCell:attr('rowspan','2')
end
tCell:cssText("width:1%;background-color:
textalign .. ";padding:0 2px 0 2px;white-space:nowrap")
Line 4.603 ⟶ 4.484:
if v['jersey'] == nil then
if (value_order=='results') and (value=='winner_fighting' or value=='winner_fighting2' or value=='cima_coppi' or value=='cima_pantanii') then
tCell:wikitext(translate("stageinfobox",v['translation'],
else
tCell:wikitext(number(v['genre'], key, wiki))
end
else
temp=''
if jerseyWPID temp="|link="..jerseyWPID
end
Line 4.667 ⟶ 4.547:
infoFillOthersMap(tab, others)
tab:node(getPreviousNextLine(
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox", translate("stageinfobox",39,
return tab
end
Line 4.674 ⟶ 4.554:
--== E) List of teams
function p.listofteams(frame)
local raceID, lf = get_and_checkID(frame
local teams = {} -- values will be {teamLink, teamCat, sortkey, index}
local WDlink_on = (wiki == "mk" or wiki == "ja")
local timeOfRace
local w_race=isWomenrace(raceID)
local teamCats_lot = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
-- Part of the numbering is omitted for the convenience of possible subsequent editing.
-- UCI professional men's teams
["Q6154783"] = {4,5,1}, -- WorldTeam
["
["
["
["
["
["
["
["
-- UCI professional women's teams
["
["
["
["
["
-- other non-road UCI teams
["
["
["
["
-- national teams (partially merged)
["Q54660600"] = {12,13,31}, -- national cycling team "any", without specifying additional parameters"
["Q23726798"] = {12,13,31}, -- national cycling team Elit
["Q99658502"] = {12,13,31}, -- national cycling team "B"
["Q20738667"] = {12,13,31}, -- national cycling team U23
["Q54555994"] = {12,13,31}, -- national cycling team U19
["Q26213387"] = {12,13,31}, -- olympic team
["Q46135307"] = {12,13,31}, -- nation at sport competition in multisport games
["Q28492441"] = {39,40,32}, -- national cycling team with sponsor name
["Q117280678"] = {37,38,33}, -- mixt cycling team
-- Below are two blocks with "non-professional" teams. They differ in the type of output - individually or all together. You can choose any manual setting.
-- amateur, club and region (not merged). Each type of team is output in a separate block
["Q114864716"] = {43,44,41}, -- DCU Elite Team
["Q20652655"] = {18,19,42}, -- amateur cycling team
["Q26849121"] = {30,31,43}, -- Women's amateur cycling team
["Q20639848"] = {14,15,44}, -- club cycling team
["Q20653570"] = {53,54,45}, -- region cycling team
-- amateur, club and region (merged). All types of team are displayed in a common block
-- ["Q114864716"] = {41,42,41}, -- DCU Elite Team
-- ["Q26849121"] = {41,42,41}, -- Women's amateur cycling team
-- ["Q20652655"] = {41,42,41}, -- amateur cycling team
-- ["Q20639848"] = {41,42,41}, -- club cycling team
-- ["Q20653570"] = {41,42,41}, -- region cycling team
}
Line 4.711 ⟶ 4.614:
if v.mainsnak.snaktype == 'value' then
no = no + 1
local teamLink, teamCat, countryID = getTeamLinkCat(v.mainsnak.datavalue.value.id, timeOfRace
local flagImage = countryID and flag(countryID, timeOfRace) or ''
teams[#teams + 1] = {flagImage .. ' ' .. teamLink, teamCat,
end
end
table.sort(teams, function(a,b)
if a[3] < b[3] then return true end -- First sort key: Order from table
if a[3] > b[3] then return false end
return a[4] < b[4] -- Second key is the index to ensure stable sorting
Line 4.726 ⟶ 4.629:
local function getHeader(CatID, count)
local header, sitelink
if
local done=false
if CatID=="Q2466826" then --name changed after 2020
Line 4.732 ⟶ 4.635:
if year and year>2019 then
if count == 1 then
header_label = translate("headoftableIII",32,
else
header_label = translate("headoftableIII",33,
end
done=true
Line 4.742 ⟶ 4.645:
if done==false then
if count == 1 then
header_label = translate("headoftableIII",
else
header_label = translate("headoftableIII",
end
end
Line 4.763 ⟶ 4.666:
if not header then
-- Unknown team category. Get the label for the entity to display if possible
header = (CatID and getLabelFallback(CatID
tHeader:css('text-transform','capitalize')
end
Line 4.825 ⟶ 4.728:
--== F) Classifications
function p.UCIclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 19, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item =tempID,
property = 'P3494', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_team=false,
max_rank_displayed=
lf=lf
}
return new_classification(
end
function p.pointsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 10, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P3494', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.teamsclassificationbytime(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 14, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4}, -- translations 3, 2, 4 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P3497', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong', -- there is no background color for the first row, but the first row is formated strong
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.teamsclassificationbypoints(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 15, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 7}, -- translations 3, 2, 7 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P3496', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong', -- there is no background color for the first row, but the first row is formated strong
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.stageclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P2417', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = false, -- there is no background color for the first row
display_ref =
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.generalclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref =
max_rank_displayed=25,
lf=lf
}
return new_classification(
end
function p.generalclassificationpoint(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref =
max_rank_displayed=25,
lf=lf
}
return new_classification(
end
function p.generalclassificationforttt(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P2321', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = false, -- there is no background color for the first row
display_ref =
max_rank_displayed=
lf=lf
}
return new_classification(
end
function p.teamtimetrialclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
item =
property = 'P2417', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = false, -- there is no background color for the first row
display_ref =
max_rank_displayed=25,
lf=lf
}
return new_classification(
end
function p.mountainsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 11, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4320', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.sprintsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 12, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4322', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.intermediatesprintclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 20, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4958', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
function p.bestyoungclassificationbypoints(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4323', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.bestyoungclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4323', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.u23classification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 18, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4323', -- property to use for this table (same as best young classification)
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.combinationclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 16, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4324', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.combativeclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 17, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.custompointsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=
item = tempID,
property =
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.customtimeclassification(frame)
local tempID, lf=get_and_checkID(frame)
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=
item = tempID,
property =
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(
end
function p.customteamclassificationbypoints(frame)
local tempID, lf=get_and_checkID(frame)
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {3, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=get_arg(3,frame) or '', --with lf does not work
item = tempID,
property = get_arg(2,frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = true, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
function p.customteamclassificationbytime(frame)
local tempID, lf=get_and_checkID(frame)
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {3, 2, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=get_arg(3,frame) or '', --with lf does not work
item = tempID,
property = get_arg(2,frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = true, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
function new_classification(s, frame)
local country = getCountryBool(no_country_classification)
local lf = s.lf
local raceID = s.item
local
--[=[ It is possible to give the classification tables in the article commands to change the standard behaviour. They could look like this:
Line 5.114 ⟶ 5.124:
]=]
local timeOfRace
local plus = ''
if
if
if
end
local tableHeader2_size = #s.header_2
local max_rank_displayed=s.max_rank_displayed
for _, p31 in statements(raceID, 'P31') do
if data.stages[p31.mainsnak.datavalue.value.id] then
max_rank_displayed=10 --limit general ranking to 10 except for not stage
end
end
local temp=get_arg('max_rank_displayed',frame)
if temp and temp~='' and string.find(temp,"{{{")==nil then
max_rank_displayed=tonumber(temp)
end
if s.header_1_text ==nil then s.header_1_text=translate(s.header_function,s.header_1,
local team_translation_index=3
if s.team_title == nil then s.team_title=translate(s.header_function,team_translation_index,
local tableBody = mw.html.create('table')
Line 5.156 ⟶ 5.168:
header= tableBody:tag('tr'):cssText("text-align:center;padding:2px 2px;white-space:nowrap")
for i, k in ipairs(s.header_2) do
if i ~= 2 or
local header_text
if k == team_translation_index then --for team
header_text=s.team_title
else
header_text=translate(s.header_function,k,
end
local head =header:tag('th'):wikitext(header_text)
Line 5.192 ⟶ 5.204:
if q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =translate("startlist",6,
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,
else riderDNF=''
end
Line 5.228 ⟶ 5.240:
teamLink, _, countryID = getTeamLinkCat(riderID, timeOfRace, true)
else
riderLink = getRiderLink(riderID,timeOfRace)..(getReference(lf,m) or '')
teamLink = getTeam(riderID, timeOfRace, q)
countryID = getNationality(riderID, timeOfRace,q)
Line 5.234 ⟶ 5.246:
if countryID then
flagLink = flag(countryID, timeOfRace)
if
countryName = getCountryName(countryID)
end
end
Line 5.255 ⟶ 5.256:
if h.jersey[1] then
for _, jersey in pairs(h.jersey) do
if data.bg_color_table[jersey] then
bg_color = data.bg_color_table[jersey]
break
end
Line 5.280 ⟶ 5.281:
if not s.team_classification then
if
tCell:wikitext(riderLink .. jersey(h.jersey) )
else
tCell:wikitext(flagLink .. ' ' .. riderLink .. jersey(h.jersey))
end
if s.display_team~=false then
tBody:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.2em 0 0.2em")
end
else --team
if
tCell:wikitext(teamLink .. jersey(h.jersey))
tBody:tag('td'):wikitext(flagLink .. ' ' .. countryName)
Line 5.307 ⟶ 5.300:
end
if riderDNF=='' then
if rank == 1 and h.value[2] then
Line 5.330 ⟶ 5.323:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,
else
temp2=translate("unit",6,
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.363 ⟶ 5.356:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,
else
temp2=translate("unit",6,
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.380 ⟶ 5.373:
if type(h.value[4]) == "number" then
tCell:wikitext(mw.ustring.format('%.3f', h.value[4]))
:tag('span'):cssText("font-size:80%"):wikitext(translate("unit",5,
end
end
Line 5.386 ⟶ 5.379:
if rank~='' and rank<=max_rank_displayed then --else no display
if riderDNF=='' then
table.insert(t_Body
else --disqualified should be higher than not disqualified if the ranking was revided
table.insert(t_Body
end
end
Line 5.405 ⟶ 5.398:
:cssText("text-align:right")
tCell:tag('small')
:wikitext(race_reference(raceID,lf))
end
--general table style and last line
local tableStyle, tableNewline
if
tableStyle = "float:" .. floattable .. "; margin-right:0.5em; border:1px solid rgb(200,200,200)"
tableNewline = ''
end
if
tableStyle = "border:1px solid rgb(200,200,200)"
tableNewline = '<br style="clear:left;">'
end
if
if s.property == 'P2417' then --stageclassification
tableStyle = "float:"..floattable.."; margin-right:0.5em; border:1px solid rgb(200,200,200)"
Line 5.440 ⟶ 5.433:
--=== G) Infobox ===
function p.infobox(frame) -- normal infobox
return infobox_main(frame,0)
end
function p.
return infobox_main(frame,1)
end
function p.
return infobox_main(frame,2)
end
function infobox_main(frame, selector)
local WDlink_on = (wiki == "mk" or wiki == "ja")
-- If true, winners will the team of the cyclist
local team = true
local details, others, winners, plural
local entityID, lf =
local w_race=isWomenrace(entityID)
if selector==0 then -- normal infobox
details = {
{ name = translate("infobox",2,
{ name = translate("infobox",3,
{ name = translate("infobox",5,
{ name = translate("infobox",6,
{ name = translate("infobox",8,
{ name = translate("infobox",9,
{ name = translate("infobox",11,
{ name = translate("infobox",12,
{ name = translate("infobox",13,
{ name = translate("infobox",14,
{ name = translate("infobox",15,
{ name = translate("infobox",16,
{ name = translate("infobox",43,
{ name = translate("infobox",17,
{ name = translate("infobox",32,
{ name = translate("infobox",33,
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
elseif selector==1 then -- season infobox
details = {
{ name = translate("infobox",46,
{ name = translate("infobox",3,
{ name = translate("infobox",6,
{ name = translate("infobox",45,
{ name = translate("infobox",47,
{ name = translate("infobox",49,
{ name = translate("infobox",63,
{ name = translate("infobox",32,
{ name = translate("infobox",33,
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
else -- champ infobox
details = {
{ name = translate("infobox",46,
{ name = translate("infobox",6,
{ name = translate("infobox",9,
{ name = translate("infobox",67,
{ name = translate("infobox",61,
{ name = translate("infobox",60,
{ name = translate("infobox",13,
{ name = translate("infobox",49,
{ name = translate("infobox",32,
{ name = translate("infobox",33,
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
end
others = get_others_dic()
if selector==0 then -- normal infobox
winners = {
{ name = translate("infobox",19,
{ name = translate("infobox",20,
{ name = translate("infobox",21,
{ name = translate("infobox",22,
{ name = translate("infobox",23,
{ name = translate("infobox",24,
{ name = translate("infobox",25,
{ name = translate("infobox",26,
{ name = translate("infobox",26,
{ name = translate("infobox",35,
{ name = translate("infobox",36,
{ name = translate("infobox",27,
{ name = translate("infobox",38,
{ name = translate("infobox",39,
{ name = translate("infobox",40,
{ name = translate("infobox",28,
{ name = translate("infobox",37,
{ name = translate("infobox",41,
{ name = translate("infobox",42,
}
elseif selector==1 then -- season infobox
winners = {
{ name = translate("infobox",52,
{ name = translate("infobox",53,
{ name = translate("infobox",54,
{ name = translate("infobox",55,
{ name = translate("infobox",56,
{ name = translate("infobox",57,
{ name = translate("infobox",58,
{ name = translate("infobox",59,
}
end -- Champ infobox has no winners
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
if selector==0 or selector==1 then
getLocalContent(winners,
end
Line 5.573 ⟶ 5.551:
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
local name = getLabelFallback(entityID
infoGetOthers(others, entityID)
Line 5.598 ⟶ 5.576:
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= "Q27020041" and data.class_dic[instanceOf] then
class = classLinkFn(instanceOf)
break
Line 5.609 ⟶ 5.587:
is_a = raceLink(season)
else
--normally there should be only a p31
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= 'Q27968055' and instanceOf ~= 'Q27020041'
is_a = raceLink(instanceOf)
break
Line 5.651 ⟶ 5.630:
end
end
local index_date, index_official_site
if selector==0 then
index_date=4
index_official_site=17
elseif selector==1 then
index_date=3
index_official_site=10
else
index_date=2
index_official_site=11
end
if not details[index_date].content then -- date
details[index_date].content, timeOfRace, plural = get_formatted_date(entityID, 'infobox')
if plural then
details[index_date].name = details[index_date].name_plural
end
end
--from this point the functions differ fundamentally
Line 5.733 ⟶ 5.704:
if stages > 0 then
details[4].content = stages
if stages > 1 then
details[4].name = details[4].name_plural
end
end
end
Line 5.739 ⟶ 5.713:
end
if not details[6].content then -- organizer sitelink
listWPlink(details, 6, entityID,'
end
if not details[7].content then -- organizer sitelink
Line 5.765 ⟶ 5.739:
end
if not details[8].content then -- organizer sitelink
listWPlink(details, 8, entityID,'
end
end
if not details[index_official_site].content then
details[index_official_site].content = officialSite(entityID)
end
tab = infoInitTab("300px", name, icon)
if selector==0 then -- normal infobox
infoFillOthersDetails(tab, others, details,translate("infobox",1,w_race))
elseif selector==1 then -- season infobox
infoFillOthersDetails(tab, others, details,translate("infobox",69,w_race))
else -- champ infobox
infoFillOthersDetails(tab, others, details,translate("infobox",70,w_race))
end
if selector==0 or selector==1 then --no winners for champ
Line 5.780 ⟶ 5.766:
end
end
winner(lf,entityID, win, timeOfRace, false, WDlink_on, team, true)
for _, v in pairs(winners) do
if not v.content then
Line 5.798 ⟶ 5.784:
:cssText('border-bottom:5px solid white; background-color:'..backgroundColor..'; text-align:center')
:css('font-weight','bold')
:wikitext(translate("infobox",18,
tab:wikitext(winRows)
end
Line 5.813 ⟶ 5.799:
tab:node(getPreviousNextLine(entityID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/infobox", translate("infobox",34,
return tab
end
Line 5.819 ⟶ 5.805:
--=== H) race infobox
function p.raceinfobox(frame)
local lang = contentLanguage
local WDlink_on = (wiki == "mk" or wiki == "ja")
Line 5.830 ⟶ 5.814:
},
vainqueur= {},
}
local entityID, lf =
local w_race= isWomenrace(entityID)
local details = {
{ name = translate("raceinfobox",4,
{ name = translate("raceinfobox",5,
{ name = translate("raceinfobox",6,
{ name = translate("raceinfobox",7,
{ name = translate("raceinfobox",8,
{ name = translate("raceinfobox",9,
{ name = translate("raceinfobox",33,
{ name = translate("raceinfobox",10,
{ name = translate("raceinfobox",12,
{ name = translate("raceinfobox",27,
{ name = translate("raceinfobox",
{ name = translate("raceinfobox",
{ name = translate("raceinfobox",
}
local others = get_others_dic()
local name = getLabelFallback(entityID
infoGetOthers(others, entityID)
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
local timeOfRace, class
Line 5.897 ⟶ 5.857:
local creation=firstValue(entityID, 'P571', 'time')
if not details[2].content and creation then
details[2].content = funcDate(creation, "
end
Line 5.903 ⟶ 5.863:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[3].content and disparition then
details[3].content = funcDate(disparition,"
end
--populate tRace
listOfWinners(entityID, tRace,nil,lf)
--number of editions
if not details[4].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[4].content = tostring(tRace.numberOfEditions).." (" .. translate("raceinfobox",31,
end
--periodicity
Line 5.926 ⟶ 5.886:
end
if not details[8].content then
infoGetPlace(details,
end
Line 5.937 ⟶ 5.897:
end
--Class and circuit
local classContent, circuitLink, numberClass= getClass(entityID)
if not details[
details[
if numberClass >1 then
details[
end
end
if not details[
details[
end
--Official web site
if not details[13].content then
details[13].content = officialSite(entityID)
end
--Build the table
Line 5.963 ⟶ 5.924:
end
--picture at the top
infoFillOthersDetails(tab, others, nil,translate("raceinfobox",19,
if not listOfNamesAtBottom then
if listOfNames and #listOfNames>1 then
tab:node(addATitle(translate("raceinfobox",18,
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.973 ⟶ 5.934:
end
infoFillOthersDetails(tab, nil, details,translate("raceinfobox",19,
if listOfNamesAtBottom then
if listOfNames and #listOfNames>0 then -- except for the ru-wiki, no one uses the display of official names at the bottom anyway
tab:node(addATitle(translate("raceinfobox",18,
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.986 ⟶ 5.947:
if (tRace.lastWinner and tRace.lastWinner~='') or
(tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addATitle(translate("raceinfobox",20,
if (tRace.lastWinner and tRace.lastWinner~='') then
tab:node(addARow(translate("raceinfobox",21,
end
if (tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addARow(translate("raceinfobox",22,
end
end
if tRace.nextLink or tRace.lastLink then
tab:node(addATitle(translate("raceinfobox",23,
local outTable
Line 6.003 ⟶ 5.964:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local lastText="[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("raceinfobox",24,
":<br>'''"..
tRace.lastLink.."'''"
Line 6.014 ⟶ 5.975:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local nextText = "[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("raceinfobox",25,
":<br>'''"..
tRace.nextLink.."'''"
Line 6.021 ⟶ 5.982:
end
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,
return tab
end
--=== I) Team roster
function p.
local teamID, lf = get_and_checkID(frame)
local tRace = {race={
raceId,
raceDate,
future,
},
vainqueur= {},
}
listOfWinners(teamID, tRace,true,lf,"P527")
if get_arg(2,frame) ~= nil then
if mw.ustring.find(mw.ustring.lower(get_arg(2,frame)), "sort") or wiki == "lv" or wiki == "mk" or wiki == "ru" then
sort = true
else
sort = false
end
end
local
sort=sort,
seasonID=tRace.lastID,
lf=lf,
year=tRace.lastEditionYear
}
if tRace.lastID then
return teamroster_main(s)
end
end
function p.teamroster(frame)
local seasonID, lf = get_and_checkID(frame)
local sort
--[[
Line 6.051 ⟶ 6.031:
change that in the code. In lv mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
]]
if get_arg(2,frame) ~= nil then
if mw.ustring.find(mw.ustring.lower(get_arg(2,frame)), "sort") or wiki == "lv" or wiki == "mk" or wiki == "ru" then
sort = true
else
sort = false
end
end
local s = {
sort=sort,
seasonID=seasonID,
lf=lf
}
return teamroster_main(s)
end
function teamroster_main(s)
local
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
local riderPosition, riderReason, riderRef, errortext
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
local labelMissing = false
local teamID, stagiaire
local slavicWikis = {mk = true, ru = true}
local wikiIsSlavic = slavicWikis[wiki]
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
local tableEndText = ''
local w_race=isWomenrace(s.seasonID)
local temp = firstValue(s.seasonID, 'P5138', 'id')
if temp then teamID = temp end
local startOfSeason = getTimeOfRace(s.seasonID, true)
if not s.year then
label=getLabelFallback(s.seasonID)
local second_occurrence
local first_occurrence=string.find(label, "%d%d%d%d")
if first_occurrence~=nil then
second_occurrence=string.find(label, "%d%d%d%d",first_occurrence+1)
if second_occurrence~=nil then
s.year=string.match(label, "%d%d%d%d",first_occurrence+1) --case Tartu2024
else
s.year=string.match(label, "%d%d%d%d")
end
end
end
for _, p527 in statements(
--re-init
riderName, riderBirthday, correctlanguage=nil, nil, nil
Line 6.099 ⟶ 6.108:
end
riderPosition=getPosition(riderPosition,p527)
riderReason, riderRef=getReason(riderReason,riderRef,p527, timeOfRace,enddate,s.lf)
local beginYear, beginMonth, beginDay, endYear, endMonth, endDay, beginDate, endDate, endDatefound, endDatetemp
Line 6.119 ⟶ 6.128:
if not endDate then endDatefound=false end
endDate, endYear, endMonth, endDay, _ = parseDate(endDate, beginYear, '12', '31', errortext,'')
riderReason, riderRef=getReason(riderReason,riderRef,v,timeOfRace,endDate,s.lf)
if (beginYear == startOfSeasonYear or endYear == startOfSeasonYear) and ((beginYear == startOfSeasonYear and (beginMonth ~= '01' or beginDay ~= '01')) or (endYear == startOfSeasonYear and (endMonth ~= '12' or endDay ~= '31'))) then
Line 6.197 ⟶ 6.206:
-- sorting names
if #riderTablecorrect~=0 then
table.sort(riderTablecorrect, function(a,b) return a[
end
if #riderTablenotcorrect~=0 then
table.sort(riderTablenotcorrect, function(a,b) return a["sortkey"]<b["sortkey"] end)
end
end
--merge
for _, v in pairs (riderTablecorrect) do
Line 6.209 ⟶ 6.222:
table.insert(riderTable, v)
end
local wd_link = mw.html.create('span'):css('float','left'):wikitext(wdLink(
if arwiki_totemplate then wd_link = wdLink(
local outTable = mw.html.create('table')
:addClass('sortable')
Line 6.219 ⟶ 6.232:
local th_colspan = 4
if wiki == "ar" then th_colspan = 5 end
local tRow=outTable:tag('tr'):css('line-height','1.8em')
:css('background-color',backgroundColor)
:tag('th'):attr('colspan', th_colspan):cssText('text-align:center;white-space:nowrap')
:wikitext(tostring(wd_link))
if s.year then
tRow:wikitext(translate("getSquadTableColumn",7,w_race).." "..s.year)
else
tRow:wikitext(translate("getSquadTableColumn",7,w_race))
end
local header = outTable:tag('tr')
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",1,
local textalign = 'center'
if wiki=='ar' then textalign = 'right' end
header:tag('th'):cssText('text-align:'..textalign..';padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",2,
if
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",6,
end
if wiki == "ar" then
header:tag('th'):attr('colspan', 2):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",3,
else
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",3,
end
local temp
Line 6.243 ⟶ 6.260:
local tCell= tRow:tag('td'):cssText("padding:0 1em 0 0;white-space:nowrap")
if not
tCell:wikitext(temp..v['riderName']):attr('data-sort-value',v['sortkey'])
Line 6.250 ⟶ 6.267:
local note=''
if v['riderReason'] ~= nil then
note = ', [[#tr_'..i..
if wiki == "ar" then note = '، [[#tr_'..i..
end
tCell:wikitext(' ('..(v['riderStart'] or '')..'–'..(v['riderEnd'] or '')
Line 6.257 ⟶ 6.274:
elseif v['riderReason'] then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
:wikitext('([[#tr_'..i..
end
tCell=tRow:tag('td'):cssText("text-align:right;white-space:nowrap")
Line 6.263 ⟶ 6.280:
local _, _, beginYear, beginMonth, beginDay = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, endYear, endMonth, endDay = string.find(v['riderBirthday'] or '',"(%d+)-(%d+)-0*(%d+)")
tCell:wikitext(
else
tCell:wikitext(funcDate(v['riderBirthday'] or '', 'long'))
if l10n["country_name_list"] and wiki ~= 'ar' and wiki ~= 'ru' and wiki ~= 'da' then
tRow:tag('td'):wikitext(v['flags'].. ' '..v['pays'])
end
Line 6.279 ⟶ 6.296:
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
elseif wiki == "ar" then
tCell=tRow:tag('td'):cssText("padding:0 0.5em")
else
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left") end
if v['riderTeam'] then
Line 6.299 ⟶ 6.314:
local temp=(v['riderReason'] or '')..(v['errortext'] or '')
if iii == 1 then
tableEndText = tableEndText.. translate("getSquadTableColumn",5,
else
tableEndText = tableEndText.. '<span style="color:white">'.. translate("getSquadTableColumn",5,
end
iii = iii
if riderRef ~= nil then tableEndText = tableEndText..
tableEndText = tableEndText.. '<br>'
end
Line 6.311 ⟶ 6.326:
if labelMissing then outTable:wikitext(getMissingLabelTrackingCategory()) end
local ref=race_reference(s.seasonID,s.lf)
if
local UCIlink
if wiki=="fr" then
UCIlink="https://www.uci.org/
else
UCIlink="https://www.uci.org/road/teams"
end
ref=translate("race_reference", 1,w_race).."["..UCIlink..' UCI]'
end
Line 6.326 ⟶ 6.345:
:attr('data-sort-value','zzz')
:cssText("text-align:right")
:tag('small'):wikitext(
return tostring(outTable)..tableEndText
Line 6.333 ⟶ 6.352:
--== J) List of winners ==
function p.listofwinners(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(s)
end
function p.listofwinnersyoung(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20883139','Q72099969','Q72099972'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnersChamp(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=false,
raceID=raceID,
shapka=get_arg(4,frame,true),
winnersProperty=winnersProperty,
display_team = false,
custom=false,
lf=lf
}
return listofwinners_main(
end
--listofwinnerssecondpart and so on can be coded with p.listofwinners
function p.listofwinnersnowiki(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(
end
function p.listofwinnersteamofpoint(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q27104269','Q72065970','Q72065977'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnersGSI(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959152','Q98959192','Q98959196'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnersGSII(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959153','Q98959194','Q98959197'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnersGSIII(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959155','Q98959195','Q98959198'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnerscountry(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q72068715','Q72068718','Q72068721'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnerscountryU23(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q72068724','Q72068725','Q72068729'}
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(
end
function p.listofwinnerscustom(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty ={}
if
if istrue(get_arg('podium',frame)) then
table.insert( winnersProperty,'Q20882668')
table.insert( winnersProperty,'Q20882669')
end
if istrue(get_arg('points',frame)) then table.insert( winnersProperty, 'Q20883007' ) end
if
if istrue(get_arg('sprints',frame)) then table.insert( winnersProperty, 'Q20883328' ) end
if
if istrue(get_arg('combativity',frame)) then table.insert( winnersProperty, 'Q101246973' ) table.insert( winnersProperty, 'Q20893983' ) end
if
if istrue(get_arg('regularity',frame)) then table.insert( winnersProperty, 'Q27067170' ) end
if
if istrue(get_arg('breakaway',frame)) then table.insert( winnersProperty, 'Q27907715' ) end
if
if istrue(get_arg('rookie',frame)) then table.insert( winnersProperty, 'Q28092831' ) end
if
if istrue(get_arg('teamspoints',frame)) then table.insert( winnersProperty, 'Q27104269' ) end
if
if istrue(get_arg('nationality',frame)) then table.insert( winnersProperty, 'Q61976872' ) end
if
if istrue(get_arg('countryU23',frame)) then table.insert( winnersProperty, 'Q72068724' ) end
local s = {
countryflag=true,
raceID=raceID,
shapka=get_arg(4,frame,true),
display_team = false,
winnersProperty=winnersProperty,
custom=true,
lf=lf
}
return listofwinners_main(
end
function listofwinners_main(
local lf=s.lf
local raceID=s.raceID
local rows = {}
local WDlink_on = (wiki == "mk") or (wiki == "ja") or (wiki == "ru")
local WPcontent = {
row ={},
Line 6.563 ⟶ 6.579:
local titletable
local
if s.custom then
titletable={
[ 'Q20882667' ]=translate("listofwinners",2,
[ 'Q20882668' ]=translate("listofwinners",3,
[ 'Q20882669' ]=translate("listofwinners",4,
[ 'Q20883007' ]=translate("listofwinners",5,
[ 'Q20883212' ]=translate("listofwinners",6,
[ 'Q20883328' ]=translate("listofwinners",7,
[ 'Q20883139' ]=translate("listofwinners",8,
[ 'Q101246973' ]=translate("listofwinners",9,
[ 'Q20893983' ]=translate("listofwinners",9,
[ 'Q20893979' ]=translate("listofwinners",10,
[ 'Q20882921' ]=translate("listofwinners",11,
[ 'Q27067359' ]=translate("listofwinners",12,
[ 'Q27067170' ]=translate("listofwinners",13,
[ 'Q27104269' ]=translate("listofwinners",14,
[ 'Q27907715' ]=translate("listofwinners",15,
[ 'Q27907747' ]=translate("listofwinners",16,
[ 'Q28092831' ]=translate("listofwinners",17,
[ 'Q61976850' ]=translate("listofwinners",18,
[ 'Q61976872' ]=translate("listofwinners",19,
[ 'Q72068715' ]=translate("listofwinners",23,
[ 'Q72068724' ]=translate("listofwinners",24,
}
else --main
titletable={
-- winner:
[ 'Q20882667' ]=translate("listofwinners",2,
[ 'Q20883007' ]=translate("listofwinners",2,
[ 'Q20883212' ]=translate("listofwinners",2,
[ 'Q20883328' ]=translate("listofwinners",2,
[ 'Q20883139' ]=translate("listofwinners",2,
[ 'Q101246973' ]=translate("listofwinners",2,
[ 'Q20893983' ]=translate("listofwinners",2,
[ 'Q20893979' ]=translate("listofwinners",2,
[ 'Q20882921' ]=translate("listofwinners",2,
[ 'Q27067359' ]=translate("listofwinners",2,
[ 'Q27067170' ]=translate("listofwinners",2,
[ 'Q27104269' ]=translate("listofwinners",2,
[ 'Q27907715' ]=translate("listofwinners",2,
[ 'Q27907747' ]=translate("listofwinners",2,
[ 'Q28092831' ]=translate("listofwinners",2,
[ 'Q61976850' ]=translate("listofwinners",2,
[ 'Q61976872' ]=translate("listofwinners",2,
[ 'Q72068715' ]=translate("listofwinners",2,
[ 'Q72068724' ]=translate("listofwinners",2,
[ 'Q98959152' ]=translate("listofwinners",2,
[ 'Q98959153' ]=translate("listofwinners",2,
[ 'Q98959155' ]=translate("listofwinners",2,
-- 2 place:
[ 'Q20882668' ]=translate("listofwinners",3,
[ 'Q72065970' ]=translate("listofwinners",3,
[ 'Q72099969' ]=translate("listofwinners",3,
[ 'Q72068718' ]=translate("listofwinners",3,
[ 'Q72068725' ]=translate("listofwinners",3,
[ 'Q98959192' ]=translate("listofwinners",3,
[ 'Q98959194' ]=translate("listofwinners",3,
[ 'Q98959195' ]=translate("listofwinners",3,
-- 3 place:
[ 'Q20882669' ]=translate("listofwinners",4,
[ 'Q72065977' ]=translate("listofwinners",4,
[ 'Q72099972' ]=translate("listofwinners",4,
[ 'Q72068721' ]=translate("listofwinners",4,
[ 'Q72068729' ]=translate("listofwinners",4,
[ 'Q98959196' ]=translate("listofwinners",4,
[ 'Q98959197' ]=translate("listofwinners",4,
[ 'Q98959198' ]=translate("listofwinners",4,
}
end
--[=[
It is possible to give the table listofwinners in the article commands. It could look like this:
Line 6.651 ⟶ 6.658:
"above row x" inserts a new row above row x into the table. Content is what is behind the ":".
]=]
if
for num, _ in pairs(
if num > 1 and mw.ustring.find(mw.ustring.lower(
local _, _, kebeginYear, val = mw.ustring.find(
local _, _, key01, kebeginYear1, kebeginYear2 = mw.ustring.find(kebeginYear, "(%a+)%s*(%a+)%s*(%d+)")
kebeginYear2 = tonumber(kebeginYear2) kebeginYear1 = mw.ustring.lower(key01..kebeginYear1)
Line 6.668 ⟶ 6.675:
if part.rank ~= 'deprecated' and part.mainsnak.snaktype == 'value' then
local partID = part.mainsnak.datavalue.value.id
local timeOfRace=getTimeOfRace(partID,true,true) --original P585 and P580 inverted here
local year = timeOfRace and string.sub(timeOfRace, 2, 5) or '?'
local month = timeOfRace and string.sub(timeOfRace, 7, 8) or '01'
Line 6.691 ⟶ 6.698:
local temp=firstValue(partID, 'P1346','id')
if temp and temp=='Q30108381' or temp=='Q54806642' or temp=='Q23023872' then --race cancelled
local cancelledlabel = getLabelFallback(
tCell=mw.html.create('td'):attr('colspan','4')
:cssText('text-align:center; font-style: italic')
Line 6.698 ⟶ 6.705:
tCellstr=tostring(tCell)
else
winner(lf,partID, winners, timeOfRace, not s.countryflag, WDlink_on,s.display_team,true)
for _, property in ipairs(s.winnersProperty) do
tCell=mw.html.create('td'):wikitext(winners[property])
Line 6.732 ⟶ 6.739:
tCell:wikitext(tostring(wd_link))
end
tCell:wikitext(translate("listofwinners",1,
for _, pp in ipairs(s.winnersProperty) do
tTitleRow:tag('th'):wikitext(titletable[pp])
Line 6.784 ⟶ 6.791:
--== K) List of stages
function check_basque_place(sPoint, sPointID)
local eu=false
--check if it is a town
local town=false
for _, p31 in statements(sPointID, 'P31') do
if p31.mainsnak.datavalue.value.id == "Q2074737" or p31.mainsnak.datavalue.value.id == "Q484170" then --Spanish and French towns
town=true
end
end
if not town then --if it not a town look for parent
for _, p131 in statements(sPointID, 'P131') do
if data.BasqueTown[p131.mainsnak.datavalue.value.id] then
eu=true
end
end
else
if data.BasqueTown[sPointID] then
eu=true
end
end
if eu then
sPoint = flag("Q47588", timeOfRace).." "..sPoint
end
return sPoint, eu
end
function p.listofstages(frame)
local WDlink_on = wiki == "mk" or wiki == "ja"
local WPcontent = {}
local raceID, lf = get_and_checkID(frame
local thereiselevation=false
local result, tableBody
local w_race=isWomenrace(raceID)
--[=[ It is possible to give the table listofstages in the article commands which overwrites data from Wikidata.
It could look like this:
Line 6.820 ⟶ 6.843:
end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
]=]
if
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
= 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
Line 6.826 ⟶ 6.849:
local key01, kebeginYear1, kebeginYear2
local key21, key22
for num, var in pairs(
if num > 1 and mw.ustring.find(mw.ustring.lower(var), WProw) then
_, _, kebeginYear, key2, val = mw.ustring.find(var, "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
Line 6.886 ⟶ 6.909:
local WDLink = WDlink_on and wdLink(stageID) or ''
local sitelink = mw.wikibase.getSitelink(stageID)
local timeOfRace =getTimeOfRace(stageID)
local sPointID = firstValue(stageID, 'P1427', 'id')
local sPoint = (sPointID and getPlaceLink(sPointID, timeOfRace)) or ''
local eu=false
if wiki=="eu" and sPointID then
sPoint, eu=check_basque_place(sPoint, sPointID)
end
if sPointID and not onecountry and
local
if startcountryID and firstcountryID ~= startcountryID then
sPoint = flag(startcountryID, timeOfRace).." "..sPoint
end
end
Line 6.905 ⟶ 6.928:
local dPoint = (dPointID and getPlaceLink(dPointID, timeOfRace)) or ''
eu=false
if wiki=="eu" and dPointID then
dPoint, eu=check_basque_place(dPoint, dPointID)
end
if dPointID and not onecountry and not eu then
local dcountryID=getCountryID(dPointID, timeOfRace)
if dcountryID and firstcountryID ~= dcountryID then
dPoint = flag(dcountryID, timeOfRace).." "..dPoint
end
end
Line 6.925 ⟶ 6.949:
Q20882667 = '', -- Q20882667 is 'overall winner' not supposed to be used
}
winner(lf,stageID, winners, timeOfRace, false, WDlink_on)
-- find the type of stage
Line 6.931 ⟶ 6.955:
local label, section_title
if sOrdinal == "0" then
label, section_title = translate("func_prologue",1), "#" .. translate("func_prologue",1)
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.943 ⟶ 6.967:
if winners['Q20882763']~='' then tempoverall=winners['Q20882763'] else tempoverall=winners['Q20882667'] end
rows[#rows + 1] = {
rank=tonumber(sNumber) or 0,
sortkey=sLetter, -- Sort keys sLink=sLink,
sDate=sDate,
WDLink=WDLink,
sPoint=sPoint,
dPoint=dPoint,
sType=sType,
sDistance=sDistance,
sElevation=sElevation,
sSWin=winners['Q20882747'],
sGWin=tempoverall -- Content
}
end
Line 6.950 ⟶ 6.984:
table.sort(rows, function(a, b)
if a[
return a[
end)
local Id = ((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")
Line 6.963 ⟶ 6.997:
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(Id..translate("headoftable",1,
tRow:tag('th'):wikitext(translate("headoftable",2,
tRow:tag('th'):wikitext(translate("headoftable",3,
tRow:tag('th'):css('color',backgroundColor):wikitext("type")
tRow:tag('th'):wikitext(translate("headoftable",4,
if thereiselevation then
tRow:tag('th'):wikitext(translate("headoftable",7,
end
tRow:tag('th'):wikitext(translate("headoftable",5,
tRow:tag('th'):wikitext(translate("headoftable",6,
local header = tostring(tRow)
for num, row in pairs(rows) do
local sPoint=row["sPoint"]
local dPoint=row["dPoint"]
local sType=row["sType"]
local sDistance=row["sDistance"]
local WPc = WPcontent[num]
if WPc then
Line 6.988 ⟶ 7.024:
local tRow = tab:tag('tr')
local tCell= tRow:tag('td'):cssText('text-align:center; white-space:nowrap'):wikitext(row["sLink"])
tCell:tag('span'):css('white-space','nowrap'):wikitext(" ".. row["WDLink
tRow:tag('td'):css('white-space','nowrap'):cssText("text-align:right; padding-right:0px")
:wikitext(row["sDate"])
tCell=tRow:tag('td'):cssText("padding-right:0px"):wikitext( sPoint)
if dPoint ~= '' then
Line 6.999 ⟶ 7.035:
tRow:tag('td'):css('text-align','center'):wikitext( sDistance)
if thereiselevation then
tRow:tag('td'):css('text-align','center'):wikitext(row["sElevation"])
end
Line 7.005 ⟶ 7.041:
tRow:tag('td'):css('text-align',textalign):wikitext( WPc['stage winner'])
else
tRow:tag('td'):wikitext(row["sSWin"])
end
if WPc and WPc['general winner'] then
tRow:tag('td'):css('text-align',textalign):wikitext( WPc['general winner'])
else
tRow:tag('td'):wikitext(row["sGWin"])
end
if WPc and (WPc['date'] or WPc['text'] or WPc['icon (new row)']) then
Line 7.038 ⟶ 7.074:
function p.stagetitle(frame)
local stageID = get_and_checkID(frame)
-- from to
local
local sPoint = sPointID and getPlaceLink(sPointID) or ''
local dPointID =
local dPoint = (dPointID and getPlaceLink(dPointID)) or ''
local sDistance = getDistance(stageID, true) or ''
local sType = typeofstagelogo(stageID) -- find the type of stage
tab=mw.html.create('table')
Line 7.062 ⟶ 7.095:
local road, ITT, result
local hcountry, hnotcountry = {},{}
local
--the jersey for a stage race and the jersey from national championship should be differentiated
Line 7.071 ⟶ 7.104:
roadtemp=false
ITTtemp=false
if data.womenNcRoadtable[v] or data.menNcRoadtable[v] then
road = true
roadtemp=true
elseif data.womenNcITTtable[v] or data.menNcITTtable[v] then
ITT = true
ITTtemp=true
Line 7.114 ⟶ 7.147:
end
--avoid double display of jersey
result = "<small>("..translate("startlist",10,
elseif road then
result = "<small>("..translate("startlist",10,
elseif ITT then
result = "<small>("..translate("startlist",11,
else
result = ""
Line 7.133 ⟶ 7.166:
local q = winner.qualifiers
if q then
if q.
wOf = q.P2501[1].datavalue.value.id -- P642 is 'of'
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
wOf = q.P642[1].datavalue.value.id -- P642 is 'of'
end
if q.P2912 and q.P2912[1].snaktype == 'value' then
thisjersey=q.P2912[1].datavalue.value.id
if data.bg_color_table[thisjersey] then
bg_color = data.bg_color_table[thisjersey]
end
end
Line 7.158 ⟶ 7.193:
local displaytypeofstage = true
local stageinfotable = {}
local raceID, lf = get_and_checkID(frame
local
local sType
--link for Grand Tour
local GTid={['Q33881']=true,['Q33861']=true,['Q33937']=true,['Q1526999']=true}
local thisGT
Line 7.181 ⟶ 7.207:
local Sitelink,overallname, pointsname, mountainname, youngname, teamname, combativityname, supercombativityname, combinedname
if thisGT then
if thisGT=='Q33881' then -- Tour de France
Sitelink = wikibase.getSitelink('Q2267539') -- General
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,
Sitelink = wikibase.getSitelink('Q175399') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,
Sitelink = wikibase.getSitelink('Q927157') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,
Sitelink = wikibase.getSitelink('
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,
Sitelink = wikibase.getSitelink('Q1436680') -- Team by time
if Sitelink then teamname="[["..Sitelink .."|"..translate("infobox",28,
Sitelink = wikibase.getSitelink('Q2094179') -- Combativity award
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2094179') -- Combativity award
if Sitelink then supercombativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q1835362') -- Combination
if Sitelink then combinedname="[["..Sitelink .."|"..translate("infobox",27,w_race).."]]" end
elseif thisGT=='Q33861' then -- Giro d'Italia
Sitelink = wikibase.getSitelink('Q1164275') -- General
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641083') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641060') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641662') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
elseif thisGT=='Q33937' then -- Vuelta a España
Sitelink = wikibase.getSitelink('Q2532554') -- General
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2241695') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q1118296') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q60233927') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2141595') -- Team by time
if Sitelink then teamname="[["..Sitelink .."|"..translate("infobox",28,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q20882672') -- Combativity award
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2330008') -- Combination
if Sitelink then combinedname="[["..Sitelink .."|"..translate("infobox",27,w_race).."]]" end
else -- Giro d'Italia Women
Sitelink = wikibase.getSitelink('
if Sitelink then
Sitelink = wikibase.getSitelink('Q3679673') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q3679712') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q3679695') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
end
end
local winners = {
{ name = translate("infobox",19,
{ name = overallname or translate("headoftableII",9,
{ name = pointsname or translate("infobox",22,
{ name = mountainname or translate("infobox",23,
{ name = translate("infobox",24,
{ name = youngname or translate("infobox",25,
{ name = combativityname or translate("infobox",26,
{ name = supercombativityname or translate("infobox",26,
{ name = translate("infobox",35,
{ name = translate("infobox",36,
{ name = combinedname or translate("infobox",27,
{ name = translate("infobox",38,
{ name = translate("infobox",39,
{ name = translate("infobox",40,
{ name = teamname or translate("infobox",28,
{ name = translate("infobox",37,
{ name = translate("infobox",41,
{ name = translate("infobox",42,
}
Line 7.331 ⟶ 7.371:
local label, section_title
if sOrdinal == "0" then
label, section_title = translate("func_prologue",1), "#" .. translate("func_prologue",1)
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 7.346 ⟶ 7.386:
if ii==1 then jerseytable[v.QID]='' end
end
winner(lf,stageID, win, timeOfRace, false, WDlink_on, false, false) --fill win table
if ii<=
jerseytable, bgcolortable=winnerjersey(stageID, jerseytable)
end
Line 7.368 ⟶ 7.408:
end
columntable[v.QID].used=true
if ii<=
if columntable[v.QID].jersey =
columntable[v.QID].
columntable[v.QID].bg_color=bgcolortable[v.QID]
end
end
end
Line 7.389 ⟶ 7.431:
somewinner = false
jerseytable, bgcolortable=winnerjersey(raceID, jerseytable)
winner(lf,raceID, win, timeOfRace, false, WDlink_on, false, false)
for _, v in pairs(winnersgen) do
if win[v.QID] and win[v.QID] ~= '' then
Line 7.421 ⟶ 7.463:
end
end
table.insert(stageinfotable,{sLink=translate("listofstagesclassification",2,
--build the table
Line 7.432 ⟶ 7.474:
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1,
if displaytypeofstage==true then tRow:tag('th') end
Line 7.480 ⟶ 7.522:
tCell=tRow:tag('td')
if ii~=#stageinfotable and v.somewinner==true then
tCell:wikitext(translate("listofstagesclassification",1,
elseif ii~=#stageinfotable then
--empty
elseif v.somewinner==true then --general row
tCell:cssText('border-top: 2px black solid')
:wikitext(translate("listofstagesclassification",1,
else
tCell:cssText('border-top: 2px black solid') --empty
Line 7.498 ⟶ 7.540:
--M) Start list
function p.startlist(frame)
local tempID, lf=get_and_checkID(frame)
local w_race=isWomenrace(tempID)
local s = {
header_function = "startlist",
header_1 = 1, -- translation 1 in function victories is printed in the upper part of the table header
header_2 = {2, 3,4,5},
item=
title="Start list",
data_sort_type={'unsortable', 'unsortable', 'unsortable'},
property ='P710',
no_roll_startlist=no_roll_startlist,
w_race=w_race,
lf=lf
}
Line 7.520 ⟶ 7.560:
function p.startlisttable(frame)
local tempID, lf=get_and_checkID(frame)
local w_race=isWomenrace(tempID)
local s = {
Line 7.530 ⟶ 7.567:
header_1 = 1, -- translation 1 in function victories is printed in the upper part of the table header
header_2 = {2, 3,4,5},-- translations 2, 3, 4, 5, 6 in function victories are printed in this order
item=
title="Start list", -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
no_country ={'fr'},
Line 7.536 ⟶ 7.573:
property ='P710',
no_roll_startlist=no_roll_startlist,
w_race=w_race,
lf=lf
}
return startlisttable_main(s, tableA(s))
end
local function startlist_sub(p710, timeOfRace, WDlink_on, istable,
--Return a table containing a row for the selected rider and their associated team, link, etc
local h = {}
local tBody = '' --row in our case
local riderID, riderTeamLink, riderTeamID, riderDossard, riderLink, riderRank
Line 7.565 ⟶ 7.604:
if q and q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =translate("startlist",6,
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,
else riderDNF=''
end
Line 7.613 ⟶ 7.652:
end
riderTeamLink, riderTeamID, catID, countryID
riderTeamID=seasonToTeamID(riderTeamID)
riderTeamCode= getTeamCode(riderID, timeOfRace, q)
--Custom display for national selection
if
if riderTeamCode and wikibase.getSitelink(countryID) then --for the refugee case
riderTeamCode='[['..wikibase.getSitelink(countryID)..'|'..riderTeamCode..']]'
Line 7.628 ⟶ 7.667:
riderLink =riderLink..jerseytemp
local sortkey = riderDossard == "" and 0 or tonumber(riderDossard)
Line 7.638 ⟶ 7.676:
if wiki == "ar" then td_css = "text-align:right;padding:0 0.5em" end
if istable then
tBody:tag('td'):cssText(td_css):wikitext(riderTeamLink or "")
end
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(number(gender,riderRank,wiki)..riderDNF)
--table.insert(resultTable, )
return {sortkey=sortkey, riderTeamLink=riderTeamLink,riderTeamID=riderTeamID,riderTeamCode=riderTeamCode, end
Line 7.652 ⟶ 7.690:
local timeOfRace=getTimeOfRace(s.item)
local
for _,p286 in statements(s.item, 'P286') do--look for DS
DSID = p286.mainsnak.datavalue.value.id
DSLink= getRiderLink(DSID, timeOfRace)
DSteamID=nil
q= p286.qualifiers
if q.
DSteamID=q.P54[1].datavalue.value.id
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
DSteamID=q.P642[1].datavalue.value.id
end
if DSteamID then DSteamID=seasonToTeamID(DSteamID) end
table.insert(DStable, {DSLink=DSLink, DSteamID=DSteamID})
end
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
end
table.sort(ridertable, function(a, b) --sort by team and then by bib and then by team
if a['sortkey'] ~= b['sortkey'] then --sort by bib
else
return (a['riderTeamCode'] or 'a') < (b['riderTeamCode'] or 'a') --order does not matter for nil
end
end)
local thisTableRow, thisTeamTable, thisDS, insideTable, test
local tSubtitle, tTitle
Line 7.686 ⟶ 7.723:
tSubtitle:tag('td'):attr('width','30px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",2,
tSubtitle:tag('td'):attr('width','200px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",3,
tSubtitle:tag('td'):attr('width','85px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",4,
else
tSubtitle=mw.html.create('tr')
tSubtitle:tag('td'):attr('width','30px'):wikitext(translate("startlist",2,
tSubtitle:tag('td'):attr('width','250px'):wikitext(translate("startlist",3,
tSubtitle:tag('td'):attr('width','35px'):wikitext(translate("startlist",4,
end
Line 7.708 ⟶ 7.745:
else
for ii=1,#ridertable do
--new team
if not (ii~=1
if thisDS and ii~=1 then
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5,
thisDS=nil
end
Line 7.741 ⟶ 7.776:
:attr('align','center')
local tCell=tTitle:tag('th'):attr('colspan','3')
tCell:tag('big'):wikitext((ridertable[ii].riderTeamLink or translate("startlist",13,w_race)).."<br/>"..(ridertable[ii].riderTeamCode or "___"))
insideTable:node(tTitle)
Line 7.758 ⟶ 7.793:
end
end
--add the rider, also for old team
insideTable:node(ridertable[ii].body)
end
--last DS
Line 7.764 ⟶ 7.800:
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5,
end
tag:node(thisTableRow)
Line 7.771 ⟶ 7.807:
end
end
local KeytoRiderRankingCode={
["women"]= 2,
['WWT']= 3,
['WWC']= 4,
["UWT"]= 5,
["europe"]= 6,
["asia"]= 7,
["oceania"]=8,
["america"]=9,
["africa"]= 10,
["WR"]= 11,
["WC"]= 12,
["UPT"]= 13, --WC is world calendar here
["UCImen"]= 14,
["WCmen"]= 15, --UCImen = UCI ranking 1984-2004, WC= World cup men
["Pernod"]= 16,
["Desgrange"]=17,
}
function startlisttable_main(s, resultTable)
Line 7.779 ⟶ 7.834:
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
end
return sortAndConcat(t_Body, resultTable)
end
Line 7.797 ⟶ 7.852:
function p.riderranking(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
item = tempID,
lf=lf
}
return riderranking_main(
end
local function checkWorldTourTeam(itemID,year)
local thisdate='+'..tostring(year).."-07-01T00:00:00Z"
local catID
for _, s in statements(itemID, 'P54') do
p54 =checktime(s, s.qualifiers, thisdate) --present Team
if p54 then
teamId= p54.mainsnak.datavalue.value.id
_, catID=getTeamLinkCat(teamId, thisdate)
if catID=="Q6154783" or catID=="Q20638319" then
return true
end
end
end
return false
end
local function ranking_legend()
local UCIlink, legend
if wiki=="fr" then
UCIlink="https://www.uci.org/fr/route/classements" --see also https://dataride.uci.org/iframe/Rankings/10/
legend= " Légende : nc = non classé"
else
UCIlink="https://www.uci.org/road/rankings"
legend=""
end
return UCIlink, legend
end
local function riderranking_sub(w_race)
local listofcalendar=data.listofmencalendar
if w_race then
listofcalendar=data.listofwomencalendar
end
local UCIQtoYear={}
for k,v in pairs(data.UCIYearToQ) do
for kk, vv in pairs(v) do
end
end
return listofcalendar, UCIQtoYear
end
function riderranking_main(s)
local lf=s.lf
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local calendarlistpresent={}
local gender=getGenderCode(s.item, 'm')
local
if gender=="f" then
local minmaxyear= { minimum = 0, maximum = 0 }
local listofcalendar, UCIQtoYear=riderranking_sub(w_race)
local resultTable={}
for ii=1900,2100,1 do
resultTable[tostring(ii)]={}
for _, calendar in pairs(listofcalendar) do
resultTable[tostring(ii)][calendar]={}
end
end
Line 7.892 ⟶ 7.928:
for _, p1344 in statements(s.item, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
for _, calendar in pairs(listofcalendar) do
if
thisyear=
minmaxyear=checkminmaxyear(minmaxyear,thisyear)
q = p1344.qualifiers
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
resultTable[thisyear][calendar]["rank"] = tostring(tonumber(q.P1352[1].datavalue.value.amount)) --without the tonumber, there can be +1 instead of 1
resultTable[thisyear][calendar]["DSQ"] = isdisqualified(p1344, q) or ""
calendarlistpresent[calendar]=true
sitelink=mw.wikibase.getSitelink(thisCompetition)
Line 7.923 ⟶ 7.952:
local tRow= finalTable:tag('tr'):tag('th')
:css("background-color",backgroundColor)
:wikitext(wdLin..' '..translate("riderranking",1,
for ii=minmaxyear.minimum,minmaxyear.maximum,1 do
Line 7.935 ⟶ 7.964:
for _, calendar in pairs(listofcalendar) do
if calendarlistpresent[calendar] then
sitelink=mw.wikibase.getSitelink(data.UCImaster[calendar])
local tRow=finalTable:tag('tr')
local tCell = tRow:tag('th'):cssText("text-align:" .. textalign .. ";") -- left
local calendar_name=translate("riderranking",data.KeytoRiderRankingCode[calendar],w_race)
if sitelink then
tCell:wikitext('[['..sitelink..'|'..
else
tCell:wikitext(
end
Line 7.947 ⟶ 7.977:
thisyear=tostring(yy)
color="white"
local impossible=false
--we need to check the impossibility here, as it is impossible even if nothing is in P1344
if data.continental_calendar[calendar] then
--between 2005 and 2015 WorldTour team member cannot score by continental calendars.
if tonumber(thisyear)>=2005 and tonumber(thisyear)<=2015 then
if checkWorldTourTeam(s.item,thisyear) then
end
--between 2016 and 2018 no contradiction
--after 2019, it depends on the nationality
elseif tonumber(thisyear)>=2019 then
local countryID=getNationality(s.item,'+'..tostring(year).."-07-01T00:00:00Z")
if data.continental_calendar[calendar] and not data.continental_calendar[calendar][countryID] then
impossible=true
end
end
elseif calendar=="UWT" then
--non member of World Tour team cannot point in the WT
if tonumber(thisyear)>=2005 and tonumber(thisyear)<=2015 then
if not checkWorldTourTeam(s.item,thisyear) then
impossible=true
end
end
end
if impossible then
tRow:tag('td'):css('background-color',backgroundColorLight)
else
if resultTable[thisyear][calendar]["rank"]=="1" then
color="gold"
elseif (2<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=3) then
color="YellowGreen"
elseif (4<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=10) then
color="silver"
end
tCell=tRow:tag('td'):attr("bgcolor",color):cssText(resultTable[thisyear][calendar]["DSQ"])
local rank=tonumber(resultTable[thisyear][calendar]["rank"])
rank=number(gender,rank,wiki)
if resultTable[thisyear][calendar]["sitelink"] then
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
tCell:wikitext(rank)
end
end
--this ranking exist for this year, but the rider is not ranked
elseif yy>=
(
if wiki=="fr" then
tRow:tag('td'):wikitext(' nc ')
Line 7.979 ⟶ 8.038:
end
end
local tableyearsize=minmaxyear.maximum-minmaxyear.minimum+2
local UCIlink, legend=ranking_legend()
finalTable:tag('tr'):tag('td'):addClass("navigation-only")
Line 8.001 ⟶ 8.052:
:wikitext(legend)
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1,
return finalTable
end
end
function p.teamranking(frame)
local tempID, lf=get_and_checkID(frame)
local calendar_key=get_arg(2,frame)
if not calendar_key or calendar_key == "" then return "" end
local w_race=false
if calendar_key=="women" or calendar_key=="WWT" or calendar_key=="WWC" then
w_race=true
end
local s = {
header_function = "riderranking",
header_1 = data.KeytoRiderRankingCode[calendar_key] or 1,
header_2 = {1, 18, 19},
property="P527",
data_sort_type = {'unsortable', 'unsortable', 'unsortable'},
item = tempID,
calendar_key=calendar_key,
lf=lf,
w_race=w_race
}
return teamranking_main(s,tableA(s))
end
local function get_teamranking(seasonID, w_race, UCIQtoYear,listofcalendar, tTable,gender)
--fill resultTable
local done, thisyear, q, done, rider, riderLink, countryID, rank, thisdate, teamrank
for _, p1344 in statements(seasonID, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
for _, calendar in pairs(listofcalendar) do
if UCIQtoYear[calendar][thisCompetition] then
thisyear=UCIQtoYear[calendar][thisCompetition]
thisdate='+'..tostring(thisyear).."-07-01T00:00:00Z"
rank=nil
if tTable[calendar] then
tTable[calendar][thisyear]={}
else
error("tTable badly initialized")
end
q = p1344.qualifiers
done=false
--get team rank
local suffix=""
if calendar== "UCImen" then --case of GSI (Q20653563), GSII (Q20653564) and GSIII (Q20653566)
propertyOf_id=nil
if q and q.P279 and q.P279[1].snaktype == 'value' then
propertyOf_id=q.P279[1].datavalue.value.id
elseif q and q.P642 and q.P642[1].snaktype == 'value' then
propertyOf_id=q.P642[1].datavalue.value.id
end
if propertyOf_id=="Q20653564" then
suffix=" (GSII)"
elseif propertyOf_id=="Q20653566" then
suffix=" (GSIII)"
end
end
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
teamrank= tonumber(q.P1352[1].datavalue.value.amount)
tTable[calendar][thisyear]["teamrank"]=number(gender,teamrank,wiki)..suffix
done=true
end
--get best rider rank
if q and q.P1545 and q.P1545[1].snaktype == 'value' then --participant
rank = tostring(tonumber(q.P1545[1].datavalue.value))
done=true
end
--get best rider
if q and q.P710 and q.P710[1].snaktype == 'value' then --participant
rider = q.P710[1].datavalue.value.id
riderLink = getRiderLink(rider, thisdate)
countryID = getNationality(rider, thisdate)
if countryID then
riderLink = flag(countryID, thisdate) .. ' ' .. riderLink
end
if rank then
rank=number(gender,tonumber(rank),wiki)
riderLink=riderLink.." ("..rank..")"
end
tTable[calendar][thisyear]["rider"]=riderLink
done=true
end
sitelink=mw.wikibase.getSitelink(thisCompetition)
tTable[calendar][thisyear]["sitelink"]=sitelink
end
end
end
return tTable
end
function teamranking_main(s, resultTable)
local lf=s.lf
local t_Body = {}
local gender="m"
if s.w_race then gender="f" end
--init, reverse UCIQtoYear
local UCIQtoYear={}
UCIQtoYear[s.calendar_key]={}
if data.UCIYearToQ[s.calendar_key] then
local v=data.UCIYearToQ[s.calendar_key]
for kk, vv in pairs(v) do
UCIQtoYear[s.calendar_key][vv]=kk
end
end
local tTable={}
tTable[s.calendar_key]={}
for ii, p527 in statements(s.item, "P527") do
tTable=get_teamranking(p527.mainsnak.datavalue.value.id, w_race,
UCIQtoYear,{s.calendar_key}, tTable,gender)
end
local t=tTable[s.calendar_key]
if t then
for thisyear, v in pairs(t) do
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 0.5em;")
local tCell=tRow:tag('td'):css("text-align",textalign)
if v["sitelink"] then
tCell:wikitext('[['..v["sitelink"]..'|'..thisyear..']]')
else
tCell:wikitext(thisyear)
end
if v["teamrank"] then
tRow:tag('td'):wikitext(v["teamrank"]):css("text-align","center")
else
tRow:tag('td'):wikitext(" - "):css("text-align","center")
end
if v["rider"] then
tRow:tag('td'):wikitext(v["rider"])
else
tRow:tag('td'):wikitext(" - ")
end
table.insert(t_Body, {sortkey=thisyear, body=tRow})
end
end
resultTable=sortAndConcat(t_Body, resultTable)
local UCIlink, _=ranking_legend()
local tRow=resultTable:tag('tr')
tRow:tag('td'):addClass("navigation-only")
:attr('colspan',tostring(3))
:cssText("border-top: 2px "..backgroundColor.." solid; font-size: 80%;")
tRow=resultTable:tag('tr')
local tCell=tRow:tag('td'):attr('colspan',tostring(3)):tag('small')
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1,w_race).."["..UCIlink..' UCI]')
return resultTable
end
Line 8.050 ⟶ 8.259:
local riderteam={}
local stagiaire
--initially initialYear is the birthyear of the rider
--end year is now +10 years, or the death date
--let's reduce the range (note: it may be slightly over-engineered, maybe it can be deleted and just assume 10 years in the future is sufficient)
local today=os.date("*t")
local t1=tonumber(today['year'])
local t2=math.min(finalYear, tonumber(today['year']))
local t_initialYear=t1
local t_finalYear=t2
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
local q = p54.qualifiers
if q then
local sTime, eTime=getStartEndfromQuali(q)
--min/max
if sTime then
y=tonumber(string.sub(sTime, 2, 5))
if y < t_initialYear then
t_initialYear=y
end
if y>t_finalYear then
t_finalYear=y
end
end
if eTime then
y=tonumber(string.sub(eTime, 2, 5))
if y < t_initialYear then
t_initialYear=y
end
if y>t_finalYear then
t_finalYear=y
end
end
end
end
if t_initialYear~=t1 then initialYear=t_initialYear end
if t_finalYear~=t2 then finalYear=t_finalYear end
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
Line 8.071 ⟶ 8.317:
end
end
return riderteam, initialYear, finalYear
end
Line 8.107 ⟶ 8.353:
if managedTeam then
cat=data.nationalcat
else
cat=data.amateurcat
end
Line 8.336 ⟶ 8.582:
local function listOfManagedTeamTable(itemID, initialYear,finalYear)
local managedTeamRider, initialYear, finalYear = listofTeam(itemID, initialYear,finalYear,'P6087')--raw list of team
if not managedTeamRider then
return nil, nil
Line 8.349 ⟶ 8.595:
local function listOfTeamTable(itemID, initialYear,finalYear)
local teamRider, initialYear, finalYear = listofTeam(itemID, initialYear,finalYear,'P54')--raw list of team
if not teamRider then
return nil, nil
Line 8.365 ⟶ 8.611:
end
local function getBirthDeathDate(entityID, display_age)
local birthDate=firstValue(entityID, 'P569', 'time')
local deathDate=firstValue(entityID, 'P570', 'time')
Line 8.371 ⟶ 8.617:
local gender=getGenderCode(entityID, 'm')
local
if gender=="f" then
if birthDate then
Line 8.384 ⟶ 8.630:
local ans
if gen_singular then
ans=translate("riderinfobox",48,
elseif gen_plural then
ans=translate("riderinfobox",49,
else
ans=translate("riderinfobox",50,
end
Line 8.412 ⟶ 8.658:
local ans
if gen_singular then
ans=translate("riderinfobox",48,
elseif gen_plural then
ans=translate("riderinfobox",49,
else
ans=translate("riderinfobox",50,
end
if display_age==false then
Line 8.453 ⟶ 8.699:
teamLinkRoad=teamLink
elseif dis=='mountainBike' then
row=teamLink..' (
elseif dis=='cycloCross' then
row=teamLink..' (
else
row=teamLink..' (
end
if row then
Line 8.500 ⟶ 8.746:
--for wikidata input
local function teamTable(tab, teamAmateur, title_singular, title_plural)
if teamAmateur and #teamAmateur>0 then
if #teamAmateur==1 then
Line 8.515 ⟶ 8.761:
end
if v['stagiaire'] then
local stagiaire = string.gsub(
nametemp=nametemp..' ('..stagiaire..')'
end
Line 8.524 ⟶ 8.770:
--for local data
local function localTeamTable(tab, names, periods, title_singular, title_plural)
if names then
names = mw.text.split(names, '<br />')
Line 8.541 ⟶ 8.787:
function p.riderinfobox(frame)
local WDlink_on = (wiki == "mk" or wiki == "ja")
local entityID, lf = get_and_checkID(frame)
local gender=getGenderCode(entityID, 'm')
local
if gender=="f" then
local details = {
{ name = translate("riderinfobox",1,
{ name = translate("riderinfobox",3,
{ name = translate("riderinfobox",5,
{ name = translate("riderinfobox",7,
{ name = translate("riderinfobox",9,
{ name = translate("riderinfobox",10,
{ name = translate("riderinfobox",11,
{ name = translate("riderinfobox",13,
{ name = translate("riderinfobox",15,
{ name = translate("riderinfobox",17,
{ name = translate("riderinfobox",18,
{ name = translate("riderinfobox",19,
{ name = translate("riderinfobox",20,
{ name = translate("riderinfobox",21,
}
local teams = {
{ name = translate("riderinfobox",23,
{ name = translate("riderinfobox",25,
{ name = translate("riderinfobox",26,
{ name = translate("riderinfobox",28,
{ name = translate("riderinfobox",29,
{ name = translate("riderinfobox",31,
{ name = translate("riderinfobox",32,
{ name = translate("riderinfobox",34,
{ name = translate("riderinfobox",35,
{ name = translate("riderinfobox",37,
{ name = translate("riderinfobox",52,
{ name = translate("riderinfobox",54,
}
--separated to have a title
local subtitle = {
{ name = translate("riderinfobox",51,
}
--separated to have a title
local victories = {
{ name = translate("riderinfobox",38,
}
--separated to have a title
local medals = {
{ name = translate("riderinfobox",47,
}
local others = get_others_dic()
local
local display_birthnameastitle=false
Line 8.624 ⟶ 8.848:
if value == wiki then display_birthnameastitle=true end
end
getLocalContent(subtitle,
if not subtitle[1].content and display_birthnameastitle then
Line 8.643 ⟶ 8.867:
infoGetOthers(others, entityID)
getLocalContent(details,
getLocalContent(teams,
getLocalContent(others,
getLocalContent(victories,
getLocalContent(medals,
local listOfBirthNames, listOfNickNames, listOfOfficialNames, listOfShortNames
Line 8.662 ⟶ 8.886:
if value == wiki then display_age=false end
end
local display_nickname=true
for _, value in pairs(display_nonickname_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_nickname=false end
end
local display_cm=false
for _, value in pairs(display_cm_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_cm=true end
end
-- getSomeNames(details, entityID, 'P1477', 1, display_language) --birthname
--less prio than P1477
if display_nickname then
getSomeNames(details, entityID, 'P1449', 2, display_language) --nick name
end
getSomeNames(details, entityID, 'P1448', 3, display_language) --official name
if display_nickname then
getSomeNames(details, entityID, 'P1813', 4, display_language) --short name
end
local birth, death, initialYear, finalYear=getBirthDeathDate(entityID, display_age)
Line 8.705 ⟶ 8.944:
--height
if not details[12].content then
details[12].content=getHeight(entityID, display_cm)
end
Line 8.727 ⟶ 8.966:
local proWD=true
local managedWD=true
local teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack=listOfTeamTable(entityID, initialYear, finalYear)
local nationalTeam, managedTeam=listOfManagedTeamTable(entityID, initialYear, finalYear)
Line 8.778 ⟶ 9.018:
end
infoFillOthersDetails(tab, others, details,translate("riderinfobox",55,
if amateurWD then
teamTable(tab, teamAmateur, translate("riderinfobox",26,
else
localTeamTable(tab,amateurTeam_names, amateurTeam_periods, translate("riderinfobox",26,
localTeamTable(tab,nonUCITeam_names, nonUCITeam_periods, translate("riderinfobox",29,
end
if proWD then
teamTable(tab, teamPro, translate("riderinfobox",45,
teamTable(tab, teamMountainBike, translate("riderinfobox",39,
teamTable(tab, teamCycloCross, translate("riderinfobox",41,
teamTable(tab, teamTrack, translate("riderinfobox",43,
else
localTeamTable(tab,proTeam_names, proTeam_periods,translate("riderinfobox",45,
localTeamTable(tab,UCITeam_names, UCITeam_periods, translate("riderinfobox",35,
end
--managed teams
if managedWD then
teamTable(tab, nationalTeam, translate("riderinfobox",52,
teamTable(tab, managedTeam, translate("riderinfobox",23,
else
localTeamTable(tab,managedTeam_names, managedTeam_periods,translate("riderinfobox",23,
end
if victories[1].content then
tab:node(addATitle(translate("riderinfobox",38,
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
Line 8.812 ⟶ 9.052:
if medals[1].content then
tab:node(addATitle(translate("riderinfobox",47,
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
:wikitext(medals[1].content)
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/riderinfobox", translate("raceinfobox",26,
return tab
end
--=== P) Team infobox
local function get_rider_number(entityID, details, index)
if not details[index].content then
local riders = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if riders > 0 then
local stagiaire = string.gsub(getLabelFallback('Q2328847'), "%b()", "")
local nb_stagiaires=0
for ii, p527 in statements(entityID, 'P527') do
local q = p527.qualifiers
if q and q.P39 and q.P39[1] and q.P39[1].snaktype == 'value' and
q.P39[1].datavalue.value=='Q2328847'then
nb_stagiaires=nb_stagiaires+1
end
end
if nb_stagiaires>0 then
details[index].content = riders ..' ('.. tostring(nb_stagiaires).." "..stagiaire..')'
else
details[index].content = riders
end
end
end
end
function p.teamseasoninfobox(frame)
local WDlink_on = (wiki == "mk" or wiki == "ja")
local seasonID, lf = get_and_checkID(frame)
local w_race=isWomenteam(seasonID)
local gender="m"
if w_race then gender="f" end
local details = {
{ name = translate("teaminfobox",2,w_race)}, -- sport
{ name = translate("headoftableII",3,w_race)}, -- team
{ name = translate("teaminfobox",3,w_race), name_plural = translate("teaminfobox",4,w_race)}, -- type
{ name = translate("teaminfobox",5,w_race), name_plural = translate("teaminfobox",6,w_race)}, -- UCI-cod
{ name = translate("teaminfobox",7,w_race), name_plural = translate("teaminfobox",8,w_race)}, -- сountry
{ name = translate("getSquadTableColumn",7,w_race)}, --team size
{ name = translate("teaminfobox",13,w_race)}, -- official web site
{ name = translate("teaminfobox",27,w_race), name_plural = translate("teaminfobox",28,w_race)}, --sponsor
{ name = translate("teaminfobox",24,w_race), name_plural = translate("teaminfobox",25,w_race) }, -- bike
{ name = translate("teaminfobox",26,w_race)}, -- budget
}
local managers ={
{ name = translate("teaminfobox",14,w_race), name_plural = translate("teaminfobox",15,w_race)}, -- manager --country
{ name = translate("teaminfobox",16,w_race), name_plural = translate("teaminfobox",17,w_race)}, -- sports director
}
local others=get_others_dic()
infoGetOthers(others, seasonID)
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
local sport_id=firstValue(seasonID, 'P641', 'id')
local icon = (sport_id == "Q3609") and -- P641 is 'sport', Q3609 is 'road bicycle racing'
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
local name = getLabelFallback(seasonID) or ''
local listOfNames=getFormerNames(seasonID, 'P1448',true)
--1st ist sport
if not details[1].content and sport_id then
details[1].content = WPlinkpure(sport_id)
end
local timeOfRace=getTimeOfRace(seasonID)
local initialYear
if timeOfRace then
initialYear=string.sub(timeOfRace,2,5)
else
error("no timeOfRace found for "..seasonID)
end
local sitelink, catID, _=getTeamLinkCat(seasonID, timeOfRace, nil, true)
--team
if not details[2].content then
details[2].content=sitelink
end
--type
listWPlinkChrono(details, 3, seasonID, {'P2094'}, 'rider', initialYear, nil, nil, true)
if not details[3].content then --fallback
if catID then
details[3].content=getRiderLink(catID, timeOfRace) --it is not a rider, but it gives the correct result
end
end
listWPlinkChrono(details, 4, seasonID, {'P1998'}, 'UCIcode', initialYear, nil, true,true)
local display_flag=true
listWPlinkChrono(details, 5, seasonID, {'P1532','P17'}, 'country', initialYear, display_flag,nil,true)
-- number of riders
get_rider_number(seasonID, details, 6)
-- official site
if not details[7].content then
details[7].content = officialSite(seasonID)
end
--Sponsor
listWPlinkChrono(details, 8, seasonID, {'P859'}, 'rider', initialYear, nil, nil, true)
--bike
listWPlinkChrono(details, 9, seasonID, {'P1876'}, 'rider', initialYear, nil, nil, true)
--budget
if not details[10].content then
p=firstValue(seasonID,'P2769')
if p and p.mainsnak.snaktype == 'value' then
local amount=p.mainsnak.datavalue.value.amount
local unit=p.mainsnak.datavalue.value.unit
details[10].content=dispmoney(amount, unit)
end
end
local listofcalendar, UCIQtoYear=riderranking_sub(w_race)
local tTable={} --no need for year, it is clear
for _, calendar in pairs(listofcalendar) do
tTable[calendar]={}
end
--not over-writable presently
tTable=get_teamranking(seasonID, w_race, UCIQtoYear,listofcalendar, tTable,gender)
--Staff, there can be several
-- manager
listWPlinkChrono(managers, 1, seasonID, {'P505'}, 'rider', initialYear, nil, nil, true)
-- sports director
listWPlinkChrono(managers, 2, seasonID, {'P286'}, 'rider', initialYear, nil, nil, true)
--Build the table
tab = infoInitTab("300px", name, icon, 2)
infoFillOthersDetails(tab, others, details, translate("teaminfobox",1,w_race))
--in case there are several names
if listOfNames and #listOfNames>1 then --Always display a list of names
tab:node(addATitle(translate("teaminfobox",19,w_race)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
end
end
if managers[1].content or managers[2].content then
tab:node(addATitle(translate("teaminfobox",18,w_race)))
for _, row in ipairs(managers) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
end
end
--Palmares
tab:node(addATitle(translate("raceinfobox",20,w_race)))
local wins = #wikibase.getAllStatements(seasonID, 'P2522')
if wins then
tab:node(addARow(translate("victories",2,w_race),tostring(wins)))
end
for calendar, v_calendar in pairs(tTable) do
if v_calendar[initialYear] then
local v=v_calendar[initialYear]
local calendar_name=translate("riderranking",KeytoRiderRankingCode[calendar],w_race)
if v["sitelink"] then
tab:node(addATitle('[['..v["sitelink"]..'|'..calendar_name..']]'))
else
tab:node(addATitle(calendar_name))
end
if v["teamrank"] then
tab:node(addARow(translate("riderranking",20,w_race),v["teamrank"]))
end
if v["rider"] then
tab:node(addARow(translate("riderranking",21,w_race),v["rider"]))
end
end
end
-- an empty line with a title under the form in the form of an image or third-party template
if get_arg('jersey',lf) then -- if the jersey is not specified, then the JERSEY header is not displayed
tab:node(addATitle(translate("teaminfobox",20,w_race)))
local outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','3'):css('text-align','center')
tCell:wikitext(get_arg('jersey',lf)) -- adding a form via "argument 2" by an image or an extraneous template
tab:node(outTable)
end
-- adding a link to articles about the last and current seasons (the same as for the race)
tab:node(getPreviousNextLine(seasonID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,w_race), seasonID)
return tab
end
function p.teaminfobox(frame)
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
local entityID, lf =
local w_race=isWomenrace(entityID)
local tRace = {race={
Line 8.838 ⟶ 9.263:
future,
},
}
local details = {
{ name = translate("teaminfobox",2,
{ name = translate("teaminfobox",3,
{ name = translate("teaminfobox",5,
{ name = translate("teaminfobox",7,
{ name = translate("teaminfobox",9,
{ name = translate("teaminfobox",10,
{ name = translate("teaminfobox",11,
{ name = translate("teaminfobox",13,
{ name = translate("teaminfobox",
{ name = translate("teaminfobox",
{ name = translate("teaminfobox",26,w_race)}, -- budget
}
local others
local managers ={
{ name = translate("
{ name = translate("
}
local
{ name = translate("teaminfobox",14,
{ name = translate("teaminfobox",16,
}
local details_season = {
{ name = translate("getSquadTableColumn",7,w_race)}, --team size
{ name = translate("victories",2,w_race)} --number of victories
}
local name = getLabelFallback(entityID,
infoGetOthers(others, entityID)
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
getLocalContent(managers, lf.args)
local listOfNames=getFormerNames(entityID, 'P1448')
Line 8.911 ⟶ 9.328:
--creation date
if not details[5].content and creation then
details[5].content = funcDate(creation, "
end
Line 8.917 ⟶ 9.334:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[6].content and disparition then
details[6].content = funcDate(disparition,"
end
--populate tRace
listOfWinners(entityID, tRace,true,lf)
-- number of season
if not details[7].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[7].content = tostring(tRace.numberOfEditions).." (" .. translate("teaminfobox",12,
end
Line 8.933 ⟶ 9.350:
end
--9 is
listWPlinkChrono(details, 9, entityID, {'P859'}, 'rider', initialYear)
--10 is bike
listWPlinkChrono(details, 10, entityID, {'P1876'}, 'rider', initialYear)
--11 budget
listWPlinkChrono(details, 11, entityID, {'P2769'}, 'money', initialYear)
-- manager
Line 8.953 ⟶ 9.374:
end
--picture at the top
infoFillOthersDetails(tab, others, details, translate("teaminfobox",1,
if managers[1].content or managers[2].content then
tab:node(addATitle(translate("teaminfobox",18,
for _, row in ipairs(managers) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
Line 8.963 ⟶ 9.384:
if listOfNames and #listOfNames>0 then --Always display a list of names
tab:node(addATitle(translate("teaminfobox",19,
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 8.970 ⟶ 9.391:
-- an empty line with a title under the form in the form of an image or third-party template
if
tab:node(addATitle(translate("teaminfobox",20,
local outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','3'):css('text-align','center')
tCell:wikitext(
tab:node(outTable)
end
-- adding a link to articles about the last and current seasons (the same as for the race)
if tRace.
-- manager
listWPlinkChrono(managers_season, 1, tRace.lastID, {'P505'}, 'rider', tRace.lastEditionYear, nil, nil, true)
-- sports director
listWPlinkChrono(managers_season, 2, tRace.lastID, {'P286'}, 'rider', tRace.lastEditionYear, nil, nil, true)
get_rider_number(tRace.lastID, details_season, 1)
local wins = #wikibase.getAllStatements(tRace.lastID, 'P2522')
local today=os.date("*t")
if wins and tonumber(tRace.lastEditionYear)==tonumber(today['year']) then --display only if the season if for this year
details_season[2].content=tostring(wins)
end
infoFillOthersDetails(tab, nil, managers_season, translate("teaminfobox",21,w_race),"260px")
infoFillOthersDetails(tab, nil, details_season, nil,"260px")
local outTable
if tRace.lastLink then
outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local lastText="[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("teaminfobox",22,
":<br>'''"..
tRace.lastLink.."'''"
Line 8.998 ⟶ 9.433:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local nextText = "[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("teaminfobox",23,
":<br>'''"..
tRace.nextLink.."'''"
Line 9.006 ⟶ 9.441:
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,
return tab
end
--== teamriderCompetitionranking
function p.teamriderCompetitionranking(frame)
local tempID, lf=get_and_checkID(frame)
local calendarID
local timeOfRace=getTimeOfRace(tempID)
local initialYear
if timeOfRace then
year=string.sub(timeOfRace,2,5)
end
local header_1_tab = {["UWT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1, ["Pro"]=22}
local header_1_number = 12
local key=get_arg(2,frame)
if key and year then
calendarID=data.UCIYearToQ[key][year]
header_1_number = header_1_tab[key]
end
local w_race=isWomenteam(calendarID)
if not calendarID or calendarID == "" then return "" end
local s = {
header_function = "calendar",
header_1 =header_1_number,
header_2 = {2, 3, 5, 4, 24, 23},
data_sort_type = {'', '','', 'unsortable', '', ''},
property="P1344",
calendarID=calendarID,
item = tempID, --should be called item for tableA
lf=lf,
w_race=w_race
}
return teamriderCompetitionranking_main(s,tableA(s))
end
local function get_competition_bestrider(RaceID, seasonID, gender)
local riderLink, rank, disqualified, cancelled, q
local bold=false
for _, p1344 in statements(seasonID, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
if thisCompetition and thisCompetition==RaceID then
q = p1344.qualifiers
if q then
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
rank= tonumber(q.P1352[1].datavalue.value.amount)
if rank==1 then
bold=true
end
rank=number(gender,rank,wiki)
end
--get best rider
if q and q.P710 and q.P710[1].snaktype == 'value' then --participant
rider = q.P710[1].datavalue.value.id
riderLink = getRiderLink(rider, thisdate)
countryID = getNationality(rider, thisdate)
if countryID then
riderLink = flag(countryID, thisdate) .. ' ' .. riderLink
end
end
_,disqualified=isdisqualified(p1344, q)
if riderLink and disqualified==true then
riderLink='<s>'..riderLink..'</s>'
end
end
end
end
return riderLink, rank, bold
end
function teamriderCompetitionranking_main(s, resultTable)--Display the UCI women calendar of one year
local best_rider, rank
local lf = s.lf
local calendarID=s.calendarID
local seasonID= s.item
local t_Body ={}
local w_race=s.w_race
local gender="m"
if w_race then gender="f" end
local temp=firstValue(calendarID, s.property)
if not temp or temp=="" then
s.error_message = 2
if wiki == "ar" then return "" end
end
local country=getCountryBool(s.no_country)
----- Begin of the main part of the code
local ind=0
for _, p527 in statements(calendarID, 'P527') do
local RaceID = p527.mainsnak.datavalue.value.id
local temp=firstValue(RaceID, 'P1346','id')
local cancelled=false
if temp and temp=='Q30108381' or temp=='Q54806642' or temp=='Q23023872' then --race cancelled
cancelled=true
else
ind=ind+1
end
if not cancelled then
---- Create a row ----
local timeOfRace, date_tCell, date_sortkey = fn_date(RaceID)
local future=compareDate(timeOfRace)
local parentID, race_tCell, _= fn_race(RaceID,nil,false,timeOfRace,nil,country)
if race_tCell~=nil then --otherwise the class is not display
local country_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
--create the table
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
tRow:node(date_tCell)
tRow:tag('td'):cssText("text-align:center;padding:0 0.5em"):wikitext(tostring(ind)) --correct only if the races are sorted correctly in wikidata
tRow:node(country_tCell)
if country then tRow:node(race_tCell) end
--logic to get the best rider||ranking
riderLink, rank, bold=get_competition_bestrider(RaceID, seasonID, gender)
local tCell=tRow:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.5em")
if riderLink then
tCell:wikitext(riderLink)
elseif future then
tCell:wikitext("")
else
tCell:wikitext(" - ")
end
tCell=tRow:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.5em")
if bold then
tCell:cssText("font-weight:bold;")
end
if rank then
tCell:wikitext(rank)
elseif future then
tCell:wikitext("")
else
tCell:wikitext(" - ")
end
---- Add the row to the table
table.insert(t_Body, {sortkey=date_sortkey, body=tRow})
end
end
end
return sortAndConcat(t_Body, resultTable)
end
Line 9.055 ⟶ 9.634:
end
elseif function_name=='getTeamLinkCat' then
temp=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4
if temp then return temp else return 'nil' end
elseif function_name=='getTeamLinkCat2' then
temp, temp2=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4]))
if temp2 then return temp2 else return 'nil' end
elseif function_name=='getPlaceLink' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
Line 9.095 ⟶ 9.677:
elseif function_name=='isWomenrace' then
return tostring(isWomenrace(argu[2]))
elseif function_name=='isWomenteam' then
return tostring(isWomenteam(argu[2]))
elseif function_name=='commaStage' then
temp =commaStage(argu[2],argu[3])
Line 9.181 ⟶ 9.765:
elseif function_name=='getNationality' then
return getNationality(argu[2], argu[3])
elseif function_name=='
return
elseif function_name=='get_formatted_date1' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
temp, temp2= get_formatted_date(argu[2], arg3)
if temp then return temp end
elseif function_name=='get_formatted_date2' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
temp, temp2= get_formatted_date(argu[2], arg3)
if temp2 then return temp2 end
elseif function_name=="getSpeed" then
if argu[4]=="nil" then arg4=nil else arg4=tonumber(argu[4]) end
return tostring(getSpeed(argu[2], toboolean(argu[3]),arg4, argu[5]))
elseif function_name=="formatNumber" then
return formatNumber(tonumber(argu[2]), toboolean(argu[3]),tonumber(argu[4]))
end
end
Line 9.192 ⟶ 9.788:
if function_name=='class_dic' then
return tostring(data.class_dic[argu[2]])
elseif function_name=="class_sort" then
return tostring(data.class_sort[argu[2]])
elseif function_name=='bg_color_table' then
local temp = data.bg_color_table[argu[2]]
temp=string.gsub(temp,'#',"")
return temp
|