Modul:Cycling race: Forskelle mellem versioner
Content deleted Content added
Hejsa (diskussion | bidrag) m fjerner skjul/vis |
Hejsa (diskussion | bidrag) opdatering fra Wikidata |
||
Linje 4:
wiki = "fr"
end
--import translation
local l10n = mw.loadData("Module:Cycling race/l10n")
--import data
local data = mw.loadData("Module:Cycling race/data")
local contentLanguage = mw.getContentLanguage()
Line 12 ⟶ 17:
-- == Structure of the code ==
-- I) Constant
-- II)
-- III) Basic functions
-- IV) Functions less basic called from other functions -----A) Time functions
-----B) Link functions
Line 19 ⟶ 25:
-----D) Jersey, flag functions
-----E) Other (winner)
-- V) Main functions
----- A) Function race reference
Line 29 ⟶ 34:
----- F) Classifications
----- G) Infobox
----- H)
----- I) Team roster
----- J) Function list of winners (palmarès) -----
-----
-----
-----
----- O) Rider infobox
--Tip: search "--==" to navigate between the sections
--== I) Classes declared as global ==
-- Class of a cycling race. Class is: 1.UWT, 2.UWT, 1.HC, ... add new classes, no problem
--Data that requires # functions and cannot be called with mw.loadData
local class = {
"Q60669124", -- Am (Q60669124)
"Q23015458", -- CDM (Q23015458)
"Q22231119", -- CN (Q22231119)
"Q60181400", -- NE (Q60181400)
"Q23005601", -- 1.WWT (Q23005601)
"Q23005603", -- 2.WWT (Q23005603)
"Q22231106", -- 1.UWT (Q22231106)
"Q22231107", -- 2.UWT (Q22231107)
"Q74275170", -- 1.Pro (Q74275170)
"Q74275176", -- 2.Pro (Q74275176)
"Q101069484", -- 1.PT (Q101069484)
"Q101052547", -- 2.PT (Q101052547)
"Q22231108", -- 1.HC (Q22231108)
"Q22231109", -- 2.HC (Q22231109)
"Q22231110", -- 1.1 (Q22231110)
"Q22231111", -- 1.2 (Q22231111)
"Q30336909", -- 1.3 (Q30336909)
"Q30339152", -- 1.4 (Q30339152)
"Q98686837", -- 1.5 (Q98686837)
"Q60669131", -- 1.7.1 (Q60669131)
"Q22231112", -- 2.1 (Q22231112)
"Q22231113", -- 2.2 (Q22231113)
"Q101052391", -- 2.3 (Q101052391)
"Q101052353", -- 2.4 (Q101052353)
"Q29866603", -- 2.5 (Q29866603)
"Q101049923", -- 2.6 (Q101049923)
"Q22231116", -- 1.2U (Q22231116)
"Q22231117", -- 2.2U (Q22231117)
"Q22231114", -- 1.Ncup (Q22231114)
"Q22231115" -- 2.Ncup (Q22231115)
}
local class_without2x = {
"Q23005601", -- 1.WWT (Q23005601)
"Q22231106", -- 1.UWT (Q22231106)
"Q74275170", -- 1.Pro (Q74275170)
"Q101069484", -- 1.PT (Q101069484)
"Q22231108", -- 1.HC (Q22231108)
"Q22231110", -- 1.1 (Q22231110)
"Q22231111", -- 1.2 (Q22231111)
"Q30336909", -- 1.3 (Q30336909)
"Q30339152", -- 1.4 (Q30339152)
"Q98686837", -- 1.5 (Q98686837)
"Q60669131", -- 1.7.1 (Q60669131)
"Q22231116", -- 1.2U (Q22231116)
"Q22231114" -- 1.Ncup (Q22231114)
}
local class_champ = { "Q22231118", "Q22231119", "Q23015458"}
local stages = {'Q18131152', 'Q20646667', 'Q20646670', 'Q20680270', 'Q20646668', 'Q20679712', 'Q2348250', 'Q2266066', 'Q485321'}
local UCI_Circuits = {
'Q1194340', -- Europa
'Q1063423', -- Asia
'Q1063430', -- America
'Q268357', -- Africa
'Q1039648', -- Oceania
'Q1329578', -- ProTour
'Q12270097', -- World Calendar
'Q635366', -- World Tour
'Q21075974', -- Wonen World Tour
'Q1693153', -- Women's Road World Rankings
"Q71580493"-- ProSeries
}
local class_2x = {
"Q23005603", -- 2.WWT (Q23005603)
"Q22231107", -- 2.UWT (Q22231107)
"Q74275176", -- 2.Pro (Q74275176)
"Q101052547", -- 2.PT (Q101052547)
"Q22231109", -- 2.HC (Q22231109)
"Q22231112", -- 2.1 (Q22231112)
"Q22231113", -- 2.2 (Q22231113)
"Q101052391", -- 2.3 (Q101052391)
"Q101052353", -- 2.4 (Q101052353)
"Q29866603", -- 2.5 (Q29866603)
"Q101049923", -- 2.6 (Q101049923)
"Q22231117", -- 2.2U (Q22231117)
"Q22231115" -- 2.Ncup (Q22231115)
}
--dictionnaries
local classes=data.classes
local class_sort=data.class_sort
local bg_color_table = data.bg_color_table
local available, translations = pcall(require, "Module:Cycling race/lang")
Line 75 ⟶ 148:
end
local standardtablecss=data.standardtablecss_part1..textalign..data.standardtablecss_part2
local no_country_calendar={'ru'}
Line 83 ⟶ 154:
local no_country_classification={'es','da','no','ru'}
local no_roll_startlist={'fr','da','no','ar'}
local display_language_in_riderinfobox={'ru'}
local display_flag_in_riderinfobox={'ru'}
local display_birthnameastitle_in_riderinfobox={'ru'}
local display_noweight_in_riderinfobox={'fr','pl'}
local
local backgroundColor="#FFDF80"
local backgroundColorLight="#FFF7DF"
for _, value in pairs(silver_theme_countries) do -- get data if country should be printed in this wiki
if value == wiki then
backgroundColor="#EAECF0"
backgroundColorLight="#EFEFEF"
end
end
--== II) Translation ==
local function translate(func_name_short, index, title)
if index == nil then index=1 end -- for prologue
if index==1000 then --code for some custom function
return title
else
if func_name_short then
local func_name=func_name_short.."_translate"
if l10n[func_name][index] then
return l10n[func_name][index]
end
else
return "error: no func_name found"
end
end
end
function plural(num)
local plural=false --latin language
local gen_singular=false --for slavic language
local gen_plural=false --for slavic language
if num then
if num > 1 then
plural=true
if num < 5 then -- 2, 3 and 4
gen_singular = true
elseif num > 20 then
local modulo = math.fmod( num, 10)
--modulo==1 --> nothing, it is singular
if modulo>1 and modulo<5 then
gen_singular = true
elseif modulo>4 then
gen_plural=true
end
else
gen_plural=true
end
end
end
return plural, gen_singular, gen_plural
end
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
as text "black" in the tables, not "blue" or "red". This way there will be no false wikilinks at the WhatLinksHere entry.
List should be updated maybe once a year. ]]
return black_list[Label]
end
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local l10nDef = {["fr"]="étape", ["en"]="stage", ["ar"]="مرحلة", ["br"]="Tennad", ["ca"]="etapa", ["cs"]="etapa", ["de"]="Etappe", ["da"]="etape", ["eo"]="Etapo",
["es"]="etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="teinur", ["hu"]="szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="Etapp",
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
["sv"]="Etapp", ["ast"]="etapa" }
local word1, word2
word2=l10nDef[wiki]
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
-- fr: {{1re}} étape, {{2e}} étape
if wiki=="fr" then
if b == "" then -- series_ordinal without character
if a == "1" then word1 = "1<sup>re</sup> "..word else word1 = a.."<sup>e</sup> "..word end -- table text = {{1re}} étape, {{2ae}} étape,
if a == "1" then word2 = "#1re "..word else word2 = "#"..a.."e "..word end --text of section header = #1re étape, #2e étape
return word1, word2
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if a == "1" then word1 = "1<sup>re</sup> "..b.." "..word else word1 = a.."<sup>e</sup> "..b.." "..word end -- table text = {{1re}} étape, {{2ae}} étape,
if a == "1" then word2 = "#1re "..b.." "..word else word2 = "#"..a.."e"..b.." "..word end --text of section header = #1re étape, #2e étape
return word1, word2
end
end
if wiki=="hu" then
if b == "" then return a..". "..word, "#"..a..". "..word
else return a..b.." "..word, "#"..a..b.." "..word end
end
if wiki=="de" or wiki=="da" or wiki=="fo" or wiki=="lb" or wiki=="no" then return a..". "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="ca" then return a.."a "..b.." "..word, "#"..a..". "..b.." "..word end
if wiki=="es" then return a..".ª "..word.." "..b, "#"..a..".ª "..word.." "..b end
if wiki=="ast" then
if b == "" then -- series_ordinal without character
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..word else word1 = a.."ª "..word end -- table text = 1ᵉʳ etapa, 2ª etapa, 3ᵉʳ etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..word else word2 = "#"..a.."ª "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa, #3ᵉʳ etapa
return word1, word2
end
if b ~= "" then -- series_ordinal with character: instead of eg "1a re" it is "1re a"
if a == "1" or a == "3" then word1 = a.."ᵉʳ "..b.." "..word else word1 = a.."ª "..b.." "..word end -- table text = {{1ᵉʳ}} etapa, {{2ª}} etapa,
if a == "1" or a == "3" then word2 = "#"..a.."ᵉʳ "..b.." "..word else word2 = "#"..a.."ª"..b.." "..word end --text of section header = #1ᵉʳ etapa, #2ª etapa
return word1, word2
end
end
-- default
word1 = x -- table text = 1, 2a, 3
word2 = "#"..word.." ".. x -- text of section header = #Etappe 2a, #Stage 4
return word1, word2
end
local function typeofstage(x, typ, noborder)
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = {
["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق ضد الساعة', time_team='مرحلة سباق الفرق ضد الساعة', time_indiv='مرحلة سباق فردي ضد الساعة', uphill='مرحلة تسلق الجبل ضد الساعة', rest='يوم راحة'},
["ast"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de mediu monte', mount='etapa de monte', time_prologue='prólogu', time_team='contrarreló per equipos', time_indiv='contrarreló individual', uphill='cronoescalada', rest='xornada de descansu'},
["fr"] = {plain = "étape de plaine", hilly="étape vallonnée", inter='étape de moyenne montagne', mount='étape de montagne', time_prologue='prologue', time_team='contre-la-montre par équipes', time_indiv='contre-la-montre individuel', uphill='contre-la-montre en côte', rest='étape de repos'},
["en"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'},
["br"] = {plain = "tennad plaen", hilly="tennad digompez", inter='tennad damveneziek', mount='tennad meneziek', time_prologue='prolog', time_team='ABEU a-skipailhoù', time_indiv='ABEU', uphill='', rest='devezh diskuizh'},
["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'},
["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''},
["da"] = {plain = "flad etape", hilly="kuperet etape", inter='middel bjergetape', mount='bjergetape', time_prologue='prolog', time_team='holdtidskørsel', time_indiv='enkeltstart', uphill='bjergenkeltstart', rest='hviledag'},
["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'},
["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'},
["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'},
["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'},
["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'},
["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'},
["hu"] = {plain = "sík szakasz", hilly="dombos szakasz", inter='közepes hegyi szakasz', mount='hegyi szakasz', time_prologue='prolog', time_team='csapat időfutam', time_indiv='egyéni időfutam', uphill='hegyi időfutam', rest=''},
["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'},
["lb"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Ekipp)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'},
["lv"] = {plain = "līdzenuma posms", hilly="paugurains posms", inter='vidēju kalnu posms', mount='kalnu posms', time_prologue='individuālais brauciens', time_team='komandu brauciens', time_indiv='individuālais brauciens', uphill='individuālais brauciens kalnā', rest='atpūtas diena'},
["mk"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'},
["nl"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'},
["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'},
["pl"] = {plain = "płaski", hilly="pagórkowaty", inter='górzysty', mount='górski', time_prologue='prolog', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='jazda indywidualna na czas pod górę', rest='dzień przerwy'},
["pt"] = {plain = "etapa plana", hilly="etapa escarpada", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='cronoescalada', rest='jornada de descanso'},
["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'},
["ru"] = {plain = "равнинный", hilly="холмистый", inter='среднегорный', mount='горный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'},
["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
local border
if noborder then border="" else border="|border|right" end
if x=='plain stage' then return "[[File:Plainstage.svg"..border.."|20px|"..l10n.plain.."]]" end
if x=='hilly stage' then return "[[File:Hillystage.svg"..border.."|20px|"..l10n.hilly.."]]" end
if x=='intermediate stage' then return "[[File:Mediummountainstage.svg"..border.."|20px|"..l10n.inter.."]]" end
if x=='mountain stage' then return "[[File:Mountainstage.svg"..border.."|20px|"..l10n.mount.."]]" end
if x=='uphill time trial stage' then return "[[File:Mountain Time Trial Stage.svg"..border.."|20px|"..l10n.uphill.."]]" end
if x=='rest day' then return "[[File:Stage rest day.svg"..border.."|20px|"..l10n.rest.."]]" end
if x=='time trial stage' then
if noborder then border="" else border="|right" end
if typ==2348250 then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_team.."]]" end
if typ==2266066 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_indiv.."]]" end
if typ==485321 then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologue.."]]" end
end
end
local function typeofstagelogo(stageID, noborder)
local sType
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
for _,t in pairs(p) do
if t.mainsnak.snaktype == 'value' then
local iOf = t.mainsnak.datavalue.value['numeric-id']
if iOf == 20646667 then sType = typeofstage('plain stage', nil, noborder) break end
if iOf == 20646670 then sType = typeofstage('hilly stage', nil,moborder) break end
if iOf == 20680270 then sType = typeofstage('intermediate stage', nil,noborder) break end
if iOf == 20646668 then sType = typeofstage('mountain stage',nil, noborder) break end
if iOf == 485321 then sType = typeofstage('time trial stage', 485321, noborder) break end -- prologue
if iOf == 2266066 then sType = typeofstage('time trial stage', 2266066, noborder) break end -- individual time trial
if iOf == 2348250 then sType = typeofstage('time trial stage', 2348250, noborder) break end -- team time trial
if iOf == 20679712 then sType = typeofstage('uphill time trial stage', nil, noborder) break end
end
end
return sType or ''
end
--== III) basic functions
--[[ Get any value for a property which is not deprecated ]]
local function firstValue(QID, PID, field)
if QID then
local ss = wikibase.getAllStatements(QID, PID) if s.rank ~= 'deprecated' and s.mainsnak.snaktype == 'value' then
return field and s.mainsnak.datavalue.value[field] or s.mainsnak.datavalue.value
end
end
else
return nil
end
end
Line 194 ⟶ 360:
--[[ Go from season of a team to the team ]]
local function getParentID(teamID)
return firstValue(teamID, '
or firstValue(teamID, '
end
Line 260 ⟶ 426:
end
--==
--=== A) Time functions ===
--[[ 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
if not q then
return s
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
Line 287 ⟶ 456:
END = string.sub(END, 1, 9) .. '32' -- Set day to 32
end
if END >= time then
return s
end
Line 295 ⟶ 464:
local function getStatementForTime(ID, property, time)
local temp
for _, s in statements(ID, property) do
temp =checktime(s, s.qualifiers, time)
if temp then return temp end
end
return nil
end
--[[ Get start time of race as a timevalue ('+2016-01-01T00:00:00Z') or nil ]]
local function
local timeOfRace
local p580 = mw.wikibase.getBestStatements(raceID, "P580") -- P580 is start time
Line 353 ⟶ 496:
local function getStartEndTime(sTime, eTime, mode)
-- Note: Add the
local lang = contentLanguage
local starttime, endtime
Line 406 ⟶ 549:
else starttime = lang:formatDate( "j", sTime )
end
elseif wiki == "de" or wiki == "da" or wiki == "fo" or wiki == "lb" or wiki == "no" then
if y ~= y2 then starttime = lang:formatDate( "j. F Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j. F", sTime )
Line 474 ⟶ 617:
end
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 y ~= y2 then
endtime = lang:formatDate( "j. F Y", eTime )
Line 509 ⟶ 652:
end
local formats =
local function
-- local date = '+2016-05-20'
-- local mode = 'small'
local format = formats[wiki] or formats['']
local lang = contentLanguage
--handle problems with lack of precision
local daycorrect=true
local monthcorrect=true
if string.sub(date,7,8)=='00' then monthcorrect=false end
if
end
if daycorrect and monthcorrect then
return contentLanguage:formatDate(format[mode], date)
else
if daycorrect or (monthcorrect==false and daycorrect==false) then --no month
if mode=='long' then
return string.sub(date,2,5) --only year, note: contentLanguage:formatDate("Y", date) returns the wrong year
else --otherwise we don't know
return '-'
end
else --month correct, but day incorrect
if mode=='onlyday' then
return '-'
else
local newdate=string.sub(date,1,9).."01"..string.sub(date,12)
return string.sub(contentLanguage:formatDate(format[mode], newdate), 3) --cut the day
end
end
end
end
Line 583 ⟶ 724:
--return officialName, isLocal
local slavicWikis = {mk = true, ru = true}
local
local p1448 = getStatementForTime(teamID, 'P1448', timeOfRace) -- P1448 is official name
Line 606 ⟶ 747:
if name then return name, true end
end
lang=p1448.mainsnak.datavalue.value.language
if not wikiIsSlavic and slavicWikis[lang]==nil then
return p1448.mainsnak.datavalue.value.text, false --then prefer label
end
Line 627 ⟶ 769:
end
-- RiderID --> RiderLink
local function getRiderLink(riderID, startOfSeason) --startOfSeason optional
--Priority order
Line 636 ⟶ 779:
local slavicWikis = {mk = true, ru = true}
local sitelink = wikibase.getSitelink(riderID)
local officialname,officialnametemp, language, name
local
local correctlanguage=true
local listOfProperty={'P1813','P1448'}
Line 645 ⟶ 788:
if not officialname then
language = p1813.mainsnak.datavalue.value.language
officialnametemp = p1813.mainsnak.datavalue.value.text
if wikiIsSlavic then
if wiki==language then
name=officialnametemp --only exact language
end
if wiki==language then --exact language --> ok
elseif slavicWikis[language]==nil then
--normally all "latin" languages use the same name, except for cyrillic translation
local russianLabel= wikibase.getLabelByLang(riderID, "ru")
if russianLabel then
local russianEnd=string.sub(russianLabel, -3)
if russianEnd~="вна" and russianEnd~="вич" then --otherwise rejected
name=officialnametemp
end
else -- no russian label, it is most probably not a cyrillic translation
name=officialnametemp --any language latin
end
end
end
if startOfSeason~= nil then
local q = p1813.qualifiers
if q then
local temp = checktime(name,q,startOfSeason)
if temp then officialname = name end--if the time is correct than it is finished
else
officialname = name
end
end
Line 698 ⟶ 858:
end
if black_list(
link = label
else
Line 768 ⟶ 928:
Q20738667 = true, Q28492441 = true, Q20639848 = true, Q20639847 = true, Q20652655 = true,
Q20653563 = true, Q20653564 = true, Q20653566 = true, Q2466826 = true, Q26849121 = true,
Q78464255 = true, Q80425135=true, Q54660600=true, Q54555994=true, Q99658502=true,
Q20653570=true
}
for _, p31 in statements(teamID, 'P31') do
if checktime(p31, p31.qualifiers, timeOfRace) then
local natureID = p31.mainsnak.datavalue.value.id
catID = natureID
break
end
end
end
if not catID then
parentID = getParentID(teamID)
Line 787 ⟶ 951:
-- Find country if needed
local countryID
if country or catID == 'Q23726798' or catID == 'Q20738667' or catID == 'Q54555994' then
countryID = firstValue(teamID, 'P1532', 'id') -- P17 is country for sport
if countryID == nil then
Line 793 ⟶ 957:
end
end
if countryID and (catID == 'Q23726798' or catID == 'Q20738667'
or catID == 'Q54660600' or catID == 'Q54555994' or catID == 'Q99658502') then
-- It is a national cycling team
name = getCountryName(countryID)
Line 805 ⟶ 970:
end
name = name .. s
elseif catID == 'Q54555994' then -- national cycling team U19
local s
if wiki == 'fr' then s = ' juniors'
elseif wiki == 'mk' then s = ' под 19 години'
elseif wiki == 'ar' then s = ' تحت 19'
elseif wiki == 'es' then s = ' sub-19'
else s = ' U19'
end
name = name .. s
elseif catID == 'Q99658502' then -- national cycling team "B"
local s
if wiki == 'fr' then s = ' "B"'
elseif wiki == 'mk' then s = ' "B"'
elseif wiki == 'ar' then s = ' "B"'
elseif wiki == 'es' then s = ' "B"'
else s = ' "B"'
end
name = name .. s
end
sitelink = getRawTeamLink(teamID)
else
Line 877 ⟶ 1.060:
return contentLanguage:formatDate("F Y", string.sub(date, 2, 8))
elseif precision >= 11 then -- Precision is day (or less)
return
end
end
Line 946 ⟶ 1.129:
end
local function
local p18 = wikibase.getBestStatements(QID, PID) -- P18 is 'image'
local first
for _, image in pairs(p18) do
Line 991 ⟶ 1.148:
end
return first
end
local function getLogo(QID)
return getImageOrMap(QID, 'P154')
end
local function getImage(QID)
return getImageOrMap(QID, 'P18')
end
local function getMap(QID)
return getImageOrMap(QID, 'P242')
end
local function getSectionalView(QID)
return getImageOrMap(QID, 'P2713')
end
Line 996 ⟶ 1.169:
local function raceLink(QID)
local sitelink = wikibase.getSitelink(QID)
local instanceOf = firstValue(QID, '
if instanceOf == nil then
instanceOf = firstValue(QID, 'P31', 'id') -- P31 is 'instance of'
end
if instanceOf == 'Q1137352' then -- Q1137352 is 'French Road Cycling Cup'
local label2 = wikibase.getLabel(instanceOf)
Line 1.011 ⟶ 1.187:
end
local function getPlaceLink(placeID,timeOfRace)
local sitelink = wikibase.getSitelink(placeID)
local name = ''
if available_list then
name = translations.list(placeID)
end
if not name then
local temp=getOfficialName(placeID, timeOfRace)
if temp then name=temp.."Oui" end
end
if sitelink then
-- Delete " (...)" form e.g. "Unley (South Australia)"
if name ~='' then
return '[[' .. sitelink .. '|' .. name .. ']]'
else
return '[[' .. sitelink .. '|' .. string.gsub(sitelink, ' %b()', '') .. ']]'
end
end
local label = wikibase.getLabel(placeID) or ''
Line 1.023 ⟶ 1.212:
end
return contentLanguage:ucfirst(label)
end
-- ClassID --> ClassLink
-- some WPs use a unique article for this case
local function classLinkFn(class)
local link
if wiki~="fr" then --not used
link= wikibase.getSitelink('Q22348500') -- Q22348500 is 'cycling race class'
end
local label = getLabelFallback(class, {wikilang, 'en', 'fr', 'de'})
if label and link then
Line 1.048 ⟶ 1.242:
local name = content.name
local nameNoShy = string.gsub(name, '­', '') -- filter soft hyphen out
local nameNoShyLow, name_pluralNoShyLow
if nameNoShy then
nameNoShyLow = mw.ustring.lower(nameNoShy)
end
local name_plural = content.name_plural
local name_pluralNoShy = name_plural and string.gsub(name_plural, '­', '') -- filter soft hyphen out
if name_pluralNoShy then
name_pluralNoShyLow = mw.ustring.lower(name_pluralNoShy)
end
if args[nameNoShy] and args[nameNoShy] ~= '' then
if content.special then
Line 1.059 ⟶ 1.261:
else
content.content = mw.text.trim(args[nameNoShy])
end
elseif nameNoShyLow and args[nameNoShyLow] and args[nameNoShyLow] ~= '' then
if content.special then
local newname, value = string.match(args[nameNoShyLow], '([^:]+):(.*)')
if value and mw.text.trim(value) ~= '' then
content.name = mw.text.trim(newname)
content.content = mw.text.trim(value)
end
else
content.content = mw.text.trim(args[nameNoShyLow])
end
elseif args[name_pluralNoShy] and args[name_pluralNoShy] ~= '' then
content.name = content.name_plural
content.content = mw.text.trim(args[name_pluralNoShy])
elseif name_pluralNoShyLow and args[name_pluralNoShyLow] and args[name_pluralNoShyLow] ~= '' then
content.name = content.name_plural
content.content = mw.text.trim(args[name_pluralNoShyLow])
end
end
end
local function checkDis(q)
dis="road"
if q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then
if q.P642[1].datavalue.value.id == 'Q520611' or q.P642[1].datavalue.value.id =='Q1031445' then
onlyRoad=false
dis="mountainBike"
elseif q.P642[1].datavalue.value.id == 'Q335638' then
onlyRoad=false
dis="cycloCross"
elseif q.P642[1].datavalue.value.id == 'Q221635' then
onlyRoad=false
dis="track"
end
end
return dis
end
-- Rider --> Team link
local function getTeam(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
Line 1.074 ⟶ 1.307:
link = getTeamLinkCat(teamID, timeOfRace)
else
if
p54 =checktime(s, s.qualifiers, timeOfRace)
if p54 then
dis=checkDis(p54.qualifiers)
if dis=='road' then --by default
teamID = p54.mainsnak.datavalue.value.id
link = getTeamLinkCat(teamID, timeOfRace)
end
end
end
end
end
return link, teamID
end
--RiderID --> UCI code
local function getTeamCode(riderID, timeOfRace, q)
-- q: qualifiers of statement in race entity where the rider is the value
Line 1.097 ⟶ 1.338:
end
return code
end
local function seasonToTeamID(teamID)
if teamID then
local parentID=getParentID(teamID)
if parentID then--season was used
return parentID
else
return teamID
end
else
return nil
end
end
Line 1.118 ⟶ 1.372:
--=== C) Function for the output ===
local function
local country = true
for _, value in pairs(no_country_list) do -- get data if country should be printed in this wiki
Line 1.130 ⟶ 1.384:
if wiki == "ar" and s.item == "" or not s.item then return "" end
if s.error_message == 1 then
error_message = func_error_message(
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
error_message = mw.ustring.gsub(error_message, "<2>", mw.wikibase.label( s.item ))
Line 1.144 ⟶ 1.398:
:css('padding', '3px')
local title =
if s.header_1 == 19 and wiki == "ar" then title = title .. " " .. s.year end
local caption = table:tag('tr'):tag('th'):attr('colspan', tostring(#s.header_2 + 1))
:cssText('padding:2px; text-align:center :css('background-color',backgroundColor)
caption:tag('span'):cssText('float:left; margin: 0 5px'):wikitext('[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']] '.. error_message)
caption:wikitext(title)
local country=
local header = table:tag('tr')
Line 1.159 ⟶ 1.415:
header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function
end
end
Line 1.165 ⟶ 1.421:
local column = header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function
if s.data_sort_type[i] == 'unsortable' then
column:addClass('unsortable')
Line 1.179 ⟶ 1.435:
if wiki == "ar" and s.item == "" or not s.item then return "" end
if s.error_message == 1 then
error_message = func_error_message(
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
error_message = mw.ustring.gsub(error_message, "<2>", mw.wikibase.label( s.item ))
Line 1.191 ⟶ 1.447:
end
local cssTable= "border: 1px solid rgb(200,200,200); margin: 0 0 0
"background-color: rgb(255, 255, 255); padding:
"clear: left; ; text-align: left; vertical-align: top; font-size: 85%; line-height: 1.8em;"
local wdLink = '[[File:Wikidata-logo S.svg|12px|link=d:'.. s.item.. '#'.. s.property..']] '.. error_message
Line 1.200 ⟶ 1.456:
:cssText('center = margin: 0 0.5em 0;clear:both; border: 1px solid rgb(200,200,200);' ..
'cellpadding="4" cellspacing="0" style="width:100%; background-color: rgb(255, 255, 255);padding: 5px;'..
'margin-bottom:1em; background-color:
:attr('title','['..
local tDiv= rollTable1:tag('div'):addClass("NavHead")
:cssText('text-align:'.. textalign .." =;height:1.8em
:css('background-color',backgroundColor)
tDiv:tag('span')
local tSpan=tDiv:tag('span'):cssText('float:' .. floattable):wikitext(wdLink)
tSpan:wikitext(title)
tDiv:wikitext(
tDiv = rollTable1:tag('div'):addClass("NavContent"):cssText("margin:0; background:white; display:block; text-align:left;")
Line 1.224 ⟶ 1.481:
local tTable =tCell:tag('table')
:attr('cellpadding','
:cssText(cssTable)
tCell = tTable:tag('tr'):tag('th')
: :attr('colspan','3'):attr('align','center') tCell:tag('span'):cssText('float:left'):wikitext(wdLink)
tCell:wikitext(
local tRow=tCell:tag('tr')
Line 1.333 ⟶ 1.592:
Q419 = {'PER', {'Flag of Peru.svg', '+1950'},
{'Flag of Peru (1825-1950).svg', '+1825-02-25', '+1950'}},
Q424 = {'CAM', {'Flag of Cambodia.svg', '+1993-06-30'},
{'Flag of Cambodia.svg', '+1948-10-20', '+1970-10-09'}},
Q664 = {'NZL', {'Flag of New Zealand.svg'}},
Q711 = {'MGL', {'Flag of Mongolia.svg'}},
Line 1.457 ⟶ 1.718:
end
-- countryID --> shape ([[France|FRA]])
local function uciCodeCountry(countryID)
local uciCode, countryName
local blacklist={Q736=true}
if countryID then
--get UCI code
if flags[countryID] then
end
--get link, assumed for a country the label is equal to the link, where not correct in the blacklist
Line 1.475 ⟶ 1.737:
countryName = mw.wikibase.getSitelink(countryID)
end
if
return ' <small>([['..countryName..'|'..
else
return ''
Line 1.485 ⟶ 1.747:
end
local function jersey_infobox(
local jersey, jersey_name = '', ''
local jerseyWPID = ''
Line 1.539 ⟶ 1.801:
{'Q33937', 'jeune', '+2019', '+2500', 'Q24645383', 'Q60233927'}, -- Jersey white.svg
{'Q2091354', 'leader', '+2011', '+2500', 'Q24257871
{'Q2091354', 'sprints', '+2011', '+2011', 'Q26806427
{'Q2091354', 'points', '+2012', '+2017', 'Q24645209
{'Q2091354', 'points', '+2018', '+2018', 'Q28820618
{'Q2091354', 'points', '+2019', '+2500', 'Q47945989
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958
{'Q2091354', 'montagne', '+2016', '+2017', 'Q27670174
{'Q2091354', 'montagne', '+2018', '+2500', 'Q25265958
{'Q2091354', 'jeune', '+2011', '+2500', 'Q24645383
{'Q2091354', 'winner_fighting', '+2017', '+2017', 'Q29957114
{'Q128713', 'leader', '+2013', '+2017', 'Q24257871
{'Q128713', 'leader', '+2018', '+2018', 'Q29594434
{'Q128713', 'points', '+2013', '+2014', 'Q24645209
{'Q128713', 'points', '+2015', '+2017', 'Q24687409
{'Q128713', 'points', '+2018', '+2018', 'Q25265938
{'Q128713', 'montagne', '+2013', '+2018', 'Q25265958
{'Q128713', 'jeune', '+2013', '+2018', 'Q24645383
{'Q128713', 'winner_fighting', '+2015', '+2015', 'Q30035038
{'Q128713', 'winner_fighting', '+2016', '+2017', 'Q30035039
{'Q128961', 'leader', '+2013', '+2500', 'Q24687408
{'Q128961', 'points', '+2013', '+2500', 'Q24645209
{'Q128961', 'montagne', '+2013', '+2014', 'Q27670178
{'Q128961', 'montagne', '+2015', '+2500', 'Q27670174
{'Q128961', 'jeune', '+2013', '+2500', 'Q24645383
{'Q128961', 'winner_fighting', '+2014', '+2500', 'Q27644113
{'Q17619325', 'leader', '+2014', '+2014', 'Q24257871
{'Q17619325', 'leader', '+2015', '+2016', 'Q26945272
{'Q17619325', 'leader', '+2017', '+2500', 'Q24257871
{'Q17619325', 'points', '+2014', '+2500', 'Q24645209
{'Q17619325', 'montagne', '+2014', '+2500', 'Q25265958
{'Q17619325', 'jeune', '+2014', '+2500', 'Q24645383
{'Q17619325', 'winner_fighting', '+2016', '+2500', 'Q30035039
}
--timeOfRace = '+1968-07-01T00:00:00Z'
Line 1.684 ⟶ 1.946:
local function subwinner(riderId, timeOfRace, q)
local
local riderTeam, riderLink, countryID
Line 1.709 ⟶ 1.971:
end
local function winner(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 1.791 ⟶ 2.053:
if disqualified==true then
riderLink='<s>'..riderLink..'</s>'
end
if winnersId and winnersId[wOf] then
if disqualified or ((not wID) and wCriterion) then
winnersId[wOf]= 'Q666' --to identify disqualification
else
winnersId[wOf]= wID --identify cancelled
end
end
if winners[wOf] == '' then
Line 1.804 ⟶ 2.073:
end
local function
table.sort(t_Body, function(a, b) return a[1] < b[1] end)
for _, m in ipairs(t_Body) do
return
end
Line 1.813 ⟶ 2.082:
local function fn_date(entityID, functionName) --to move as a general function
local tempdate, timeOfRace, sortkey, sortkeyDate
local
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
Line 1.830 ⟶ 2.099:
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
tempdate =
timeOfRace = pTime
sortkeyDate = pTime
end
end
local _, _, y, m, d = string.find(sortkeyDate or "", "(%d+)-(%d+)-(%d+)")
if y~= nil and m~= nil and d~=nil then
sortkey = y..m..d
Line 1.849 ⟶ 2.118:
:wikitext(tempdate)
return
end
Line 1.859 ⟶ 2.128:
-- parentID taken from fn_race, optional
--
--
--
local country, countryname,
local countryID, parentID, raceSitelink
Line 1.888 ⟶ 2.157:
country[#country + 1]=flag(countryID, timeOfRace).." "..countryname[#countryname]
end
end
end
Line 1.895 ⟶ 2.164:
end
if countryID == nil then
if countryname[1] then tCell:attr('data-sort-value',countryname[1]) end
if countrybool==false then
tCell:wikitext(country[1].." "..(raceSitelink or ''))
else
if countryname[1] then
if country[1] then tCell:wikitext(country[1]) end
else
end
end
return
end
local function
local
local
local
local
local temp=firstValue(stageID, 'P1545')
if temp then
if
stageNumber= translate("victories",9)
else
if
stageNumber= translate("victories",8)
else
--look for
local i,j = string.find(
if i ~= nil then --we have to do something
local k,l = string.find(
stageNumber=stageNumberonly
if
end
if wiki == 'ar' then
else
end
end
Line 1.972 ⟶ 2.239:
for _, v in ipairs(correpondance) do
if string.find(
comma = v.article
break
Line 1.979 ⟶ 2.246:
end
if wiki == 'fr'
else
--if wiki=="de" or wiki=="da" or wiki=="fo" or wiki == "lb" or wiki=="no" or wiki=="ru" or wiki=="ar" or wiki=="lv" or wiki=="pl" then
outTable[2]=comma..stageNumber
end
return
end
local function getMainRaceLink(entityID,entity_type,stageID, functionName,timeOfRace) --the link to the edition but with a general name
local instanceOf, instanceOfTemp, label, Sitelink, isclass, prefix, postfix
Sitelink=wikibase.getSitelink(entityID)
prefix=''; postfix='' --general classification
listOfProperty={'P2561','P1448'}
--system with P3450 and P2094
instanceOf=firstValue(entityID, 'P3450', 'id')
if instanceOf==nil then
for _, p31 in statements(entityID, 'P31') do
instanceOfTemp = p31.mainsnak.datavalue.value.id
isclass=false
for _,thisClass in ipairs(class) do--we don't want the class, but the main race
if instanceOfTemp == thisClass then isclass=true end
end
if isclass==false then
instanceOf=instanceOfTemp
end
end
end
--get information from the parent
--look for
for _, prop in ipairs(listOfProperty) do
for _, p2561 in statements(instanceOf, prop) do --name for championship
if timeOfRace~= nil then
local temp = checktime(nametemp,q,timeOfRace)
if temp then label = nametemp end--if the time is correct than it is finished
else
label = nametemp
end
end
Line 2.020 ⟶ 2.298:
end
end
end
end
end
if Sitelink==nil then --only if no link to the race direct
Sitelink=wikibase.getSitelink(instanceOf)
end
if Sitelink==nil and entity_type=='champ' then --only for champ
local temp=firstValue(instanceOf, 'P361','id')
if temp then Sitelink= wikibase.getSitelink(temp) end
end
end
Line 2.047 ⟶ 2.325:
if entity_type=='2' then
if functionName~=nil then --calendar=nil
if wiki == 'fr' then prefix=
elseif wiki == 'ar' then postfix ='، '..
else postfix = ', '..
end
end
elseif entity_type=='stage' then
--how to write "stage, " is concentrated in one function
local
prefix=
postfix=
end
Line 2.066 ⟶ 2.344:
end
local function fn_getClassInfo(entityID,instanceOf, displayed_class) --get the class of the race
--with only P31, it is necessary to check if the entityID is a class, with P2094, it is not necessary
local display=false
local
local entity_type,
if displayed_class==nil then
display=true
else
for _, thisClass in ipairs(displayed_class) do
if
display=true break end end
end
Line 2.081 ⟶ 2.363:
listOfClassesName = {'champ', '2','1'}
classID=firstValue(entityID, 'P2094', 'id')
classIDs={instanceOf}
else
classIDs={classID, instanceOf} --try the first and then the second
end
for _, class_id in ipairs(classIDs) do
for ii, thisClassesList in ipairs(listOfClassesList) do
if entity_type==nil then --break
for _, thisClass in ipairs(thisClassesList) do
if class_id == thisClass then
entity_type = listOfClassesName[ii]
classText = mw.wikibase.label(thisClass)
sortkey_class = class_sort[thisClass]
end
end
end
end
end
if entity_type==nil then entity_type = 'nada' end--to allow display of race without class...
if display~=false then
end
return
end
--look for the circuitID to create a link as [[World Tour|1.UWT]]
--a bit redundant with classLink which needs less computation
--for infobox classLink gives enough info
local function classToCircuit(classID, entityID, classText, child, q)
local displayedCircuitID, circuitID, classLink, circuitLink, circuitLinkFull
if classID then
if classID=='Q23005601' or classID=='Q23005603' then --1WWT 2WWT clear
displayedCircuitID = 'Q21075974'
elseif classID=='Q22231106' or classID=='Q22231107' then --1UWT 2UWT clear
displayedCircuitID = 'Q635366'
else --we have to look in the item
if child then --for instance Flèche wallonne 2020
for _, p361 in statements(entityID, 'P361') do
circuitID = p361.mainsnak.datavalue.value.id
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
for i=1,#UCI_Circuits do
if parentCircuitID == UCI_Circuits[i] then --Yes it is
displayedCircuitID=circuitID
break
end
end
end
end
else --for instance Flèche wallonne
if q then
if q.P642 and q.P642[1].snaktype == 'value' and q.P642[1].datavalue.value.id then
displayedCircuitID = q.P642[1].datavalue.value.id
end
end
end
end
if wikibase.getSitelink('Q22348500') and wiki~="fr" then --for the WP that use this element
classLink = classLinkFn(classID)
end
end
if displayedCircuitID~=nil then
circuitLink = wikibase.getSitelink(displayedCircuitID) --we display the circuit of the year
circuitLinkFull=WPlinkpure(displayedCircuitID)
if circuitLink ~= nil and not classLink then --do not erase Q22348500
if classText ~= nil then
classLink = '[['..circuitLink..'|'..classText..']]'
else
classLink = '[['..circuitLink .. ']]'
end
end
elseif not classLink and classText~=nil then
classLink=classText
end
return classLink, circuitLinkFull
end
local function getStartEndfromQuali(q) --return sTime and eTime as date
local sTime, eTime
if q then
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
sTime = q.P580[1].datavalue.value.time
end
if q.P582 and q.P582[1] and q.P582[1].snaktype == 'value' then -- P582 is end time
eTime = q.P582[1].datavalue.value.time
end
end
return sTime, eTime
end
local function getPeriod(q, brackets)
local sTime, startTime, eTime, endTime
sTime, eTime = getStartEndfromQuali(q)
if sTime then startTime= funcDate(sTime,'Y') end
if eTime then endTime =funcDate(eTime,'Y') end
local period
if sTime and eTime then
period=startTime .. '-'..endTime
elseif sTime then
period=startTime .. '-'
elseif eTime then
period='-'..endTime
else
period=""
end
if brackets and period~="" then
period="("..period..")"
end
return period, sTime
end
local function getClass(entityID)
local classLink, circuitLink, SiteLink
local classTable={}
for ii, p279 in statements(entityID, 'P279') do
if p279 and p279.mainsnak.snaktype == 'value' then
temp = p279.mainsnak.datavalue.value.id
classID=nil
for jj=1,#class do -- #class = number of elements in class
if temp == class[jj] then
classID=temp
classText = wikibase.label(temp)
break
end
end
if classID then
classLink, circuitLink=classToCircuit(classID, entityID, classText, false,p279.qualifiers)
if classLink then
local period, sTime=getPeriod(p279.qualifiers, true)
local classStr = classLink .. " <small>"..period.."</small>"
table.insert(classTable, {sTime, classStr, circuitLink})
end
end
end
end
table.sort(classTable, function(a, b) return a[1] < b[1] end)
for _, class in pairs(classTable) do
if not str then str='' else str=str..'<br>' end
str=str..class[2]
circuitLink=class[3]
end
return str, circuitLink, #classTable
end
Line 2.106 ⟶ 2.526:
--first function read from victory main
--
--
local Sitelink,instanceOf,instanceOfTemp,circuitID,parentCircuitID
local
local inputtable,
local display=true -- should be true to work, bypassed
local sortkey_class = ''
Line 2.123 ⟶ 2.543:
local parentID = getParentID(entityID)
entityID = parentID
display = true
for _, p31bis in statements(parentID, 'P31') do
local instanceOfbis = p31bis.mainsnak.datavalue.value.id
inputtable=fn_getClassInfo(parentID, instanceOfbis,displayed_class)
if inputtable[1]~=nil and inputtable[1]~='nada' then
sortkey_class=inputtable[3]
classID=inputtable[4]
Line 2.136 ⟶ 2.556:
end
end
if entity_type==nil then --bypass if stage
inputtable=fn_getClassInfo(entityID,instanceOf,displayed_class) --if a P2094 is present, the instanceOf does not matter
if inputtable[1]==nil then
elseif inputtable[1]=='nada' then --no display="inputtable[1]==nil" inputtable[1]=='nada'--> display but empty
Line 2.144 ⟶ 2.565:
display=true
entity_type=inputtable[1]
sortkey_class=inputtable[3]
classID=inputtable[4]
Line 2.151 ⟶ 2.572:
end
--Now we have the class and know the type of race it is
if display then
if entity_type == 'stage' then
Line 2.162 ⟶ 2.580:
if country~=false then
local tCell=mw.html.create('td'):cssText("text-align:".. textalign ..";padding:0 2.3em"):wikitext(Sitelink)
else
end
if displayclass == true then
classLink, _ =classToCircuit(classID, entityID, classText, true, nil)
if not classLink then classLink="" end
local tCell=mw.html.create('td')
:attr('data-sort-value',sortkey_class)
:cssText("text-align:center;padding:0 0.5em")
:wikitext(
end
end
return outTable
end
Line 2.245 ⟶ 2.639:
return tCell:wikitext(tempwinner), thereisawinner
end
end
local function compareDate(tdate) --test future
if tdate then
local today=os.date("*t")
local _, _, y, m, d = string.find(tdate, "(%d+)%p(%d+)%p(%d+)")
local tYear=tonumber(y)
local tMonth=tonumber(m)
local tDay=tonumber(d)
if tYear>today['year'] then
return true
elseif tYear<today['year'] then
return false --the last race is the future
else
if tMonth>today['month'] then
return true
elseif tMonth<today['month'] then
return false
else
if tDay>today['day'] then
return true
elseif tDay<today['day'] then
return false
else
return false --arbitrary
end
end
end
else
return false --arbitrary
end
end
local function calculateAge(birthDate, endDate) --test future
local eYear, eMonth, eDay
if birthDate then
if not endDate then
local today=os.date("*t")
eYear=today['year']
eMonth=today['month']
eDay=today['day']
else
local _, _, y, m, d = string.find(endDate, "(%d+)%p(%d+)%p(%d+)")
eYear=tonumber(y)
eMonth=tonumber(m)
eDay=tonumber(d)
end
local _, _, y, m, d = string.find(birthDate, "(%d+)%p(%d+)%p(%d+)")
local tYear=tonumber(y)
local tMonth=tonumber(m)
local tDay=tonumber(d)
local alreadyThisYear
if eMonth>tMonth then
alreadyThisYear=true
elseif eMonth<tMonth then
alreadyThisYear=false
else
if eDay>tDay then
alreadyThisYear=true
elseif eDay<tDay then
alreadyThisYear=false
else
alreadyThisYear=true
end
end
if alreadyThisYear then
return eYear-tYear, tYear, eYear+1
else
return eYear-tYear-1, tYear, eYear+1
end
else
return 0, tYear, eYear+1
end
end
local function evaluateWinnerMax(t)
local winners = t.vainqueur
local result
local most_wins = 0
local most_wins_ID = {}
for winnerID, winner in pairs(winners) do
if winner.count > most_wins then
most_wins = winner.count
most_wins_ID = { winnerID }
elseif winner.count == most_wins then
most_wins_ID[#most_wins_ID + 1] = winnerID
end
end
if most_wins > 1 then
for _, id in pairs(most_wins_ID) do
if not result then
result=winners[id].link
else
result=result.."<br>"..winners[id].link
end
end
local _, gen_singular, gen_plural=plural(most_wins)
if gen_singular then --slavic plural, 1 victory is not displayed
word_victory=translate("raceinfobox",29)
elseif gen_plural then
word_victory=translate("raceinfobox",30)
else
word_victory=translate("raceinfobox",32) --singular
end
result=result.."<br>("..tostring(most_wins).." "..word_victory..")"
end
t.maxWinner=result
end
local function listOfWinners(itemID,t)
local winners = { Q20882667 = '',}-- Q20882667 is 'overall winner general classification'
local winnersId={ Q20882667 = '',}--to detect disqualification
local WDlink_on, sitelink
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
-- Get the date to sort the editions
for _, p527 in statements(itemID, 'P527') do --_, p527
local raceDate, year, raceID, entity_race, a, b
raceId = 'Q'..p527.mainsnak.datavalue.value['numeric-id'] -- Qnumbers of the parts of a tour
raceDate=getTimeOfRace(raceId)
table.insert(t.race, { raceId=raceId, raceDate=raceDate, future=compareDate(raceDate)} ) --check if future
table.sort(t.race, function(a,b) return a['raceDate'] < b['raceDate'] end) -- t.race is sorted after year
end
--look for the next race
local lastRunEdition, lastEditionDate, nextEdition
for num, race in ipairs(t.race) do
if race['future'] then
nextEdition=num
break
end
end
--Get the winners
local numberOfEditions=0
local lastWinner, winnerId
for num=1,#t.race do
winners.Q20882667=''
winnersId.Q20882667=''
winner(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" then --cancelled
numberOfEditions=numberOfEditions+1
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
lastWinner=winners.Q20882667
end
end
winnerId=winnersId.Q20882667
if winnerId~=nil and winnerId~='' and winnerId~='Q666' then --code for disqualification
if not t.vainqueur[winnerId] then
t.vainqueur[winnerId]={}
t.vainqueur[winnerId].link=winners.Q20882667
t.vainqueur[winnerId].count=0
end
t.vainqueur[winnerId].count=t.vainqueur[winnerId].count+1
end
end
local monthId=firstValue(itemID, 'P2922','id')
if monthId then
t.lastEditionMonth=getLabelFallback(monthId, {wikilang, 'en', 'fr', 'de'}) or ''
else
t.lastEditionMonth=contentLanguage:formatDate("M", lastEditionDate)
end
t.lastEditionYear=contentLanguage:formatDate("Y", lastEditionDate)
t.numberOfEditions=numberOfEditions
evaluateWinnerMax(t)
if lastRunEdition then
t.lastWinner=lastWinner or '' --t.vainqueur[lastRunEdition]['link']
sitelink = wikibase.getSitelink(t.race[lastRunEdition]['raceId'])
if sitelink ~= nil then
t.lastLink = "[[" .. sitelink .. "]]"
else
t.lastLink = nil
end
end
if nextEdition then
sitelink = wikibase.getSitelink(t.race[nextEdition]['raceId'])
if sitelink ~= nil then
t.nextLink = "[[" .. sitelink .. "]]"
else
t.nextLink = nil
end
end
end
function getPeriodicity(itemID, t)
local p = wikibase.getBestStatements(itemID, 'P2257')
if p[1] and p[1].mainsnak.snaktype == 'value' then
local period=p[1].mainsnak.datavalue.value.amount
local periodunit=p[1].mainsnak.datavalue.value.unit
if tonumber(period)==1 and periodunit == 'http://www.wikidata.org/entity/Q577' then
return translate("raceinfobox",1).." ("..t.lastEditionMonth ..")"
elseif tonumber(period)==1 and periodunit == 'http://www.wikidata.org/entity/Q5151' then
return translate("raceinfobox",2)
else
return nil
end
else
return nil
end
end
local function getType(itemID)
local result, typeID
typeID =firstValue(itemID, 'P31', 'id')
if typeID ~= nil then
if typeID=="Q2912397" and wiki=="fr" then
result="[[Cyclisme_sur_route#Épreuve_d'un_jour|Course d'un jour]]"
else
result=WPlinkpure(typeID)
end
end --else result=nil
return result
end
local function getFormerNames(itemID, PID)
local listOfNames={}
local slavicWikis = {mk = true, ru = true}
local officialname,officialnametemp, language
local wikiIsSlavic = slavicWikis[wiki]
local correctlanguage=true
local listOfProperty={PID}
for _, prop in ipairs(listOfProperty) do
for _, p1813 in statements(itemID, prop) do
officialname=nil
language = p1813.mainsnak.datavalue.value.language
officialnametemp = p1813.mainsnak.datavalue.value.text
if wikiIsSlavic then
if wiki==language then
officialname=officialnametemp --only exact language
end
else
if slavicWikis[language]==nil then
officialname=officialnametemp --any language latin
end
end
local period, sTime=getPeriod( p1813.qualifiers)
if officialname then
table.insert(listOfNames,{sTime, period, officialname, language})
end
end
end
table.sort(listOfNames, function(a, b) return a[1] < b[1] end)
return listOfNames
end
local function officialSite(itemID)
local p856 = wikibase.getBestStatements(itemID, 'P856')
if p856[1] and p856[1].mainsnak.snaktype == 'value' then
local url = p856[1].mainsnak.datavalue.value
return '['..url.." "..translate("raceinfobox",3)..']'
end
return nil
end
Line 2.255 ⟶ 2.920:
else km = 'km' end
return km
end
local function getm(wiki)
local m
if wiki == "ar" then m = 'م'
elseif wiki == "mk" then m = 'м'
elseif wiki == "ru" then m = 'м'
elseif wiki == "ja" then m = ''
else m = 'm' end
return m
end
local function getKg(wiki)
local kg
if wiki == "ar" then kg = 'كجم'
elseif wiki == "mk" then kg = 'kg'
elseif wiki == "ru" then kg = 'kg'
elseif wiki == "ja" then kg = ''
else kg = 'kg' end
return kg
end
Line 2.267 ⟶ 2.952:
end
return nil
end
local function checkm(p)
local m, unit
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
return m
elseif unit=='http://www.wikidata.org/entity/Q174728' then --cm
return m*0.01
end
end
return nil
end
local function checkkg(p)
local kg, unit
if p[1] and p[1].mainsnak.snaktype == 'value' then
kg = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11570' then
return kg
end
end
return nil
end
local function getHeight(entityID)
local m
local text
local lang = contentLanguage
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
m= checkm(p)
if m then
text = lang:formatNum(m)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
text = text .. ' ' .. getm(wiki)
end
return text
end
local function getWeight(entityID)
local kg
local text
local lang = contentLanguage
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
kg = checkkg(p)
if kg then
text = lang:formatNum(kg)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
text = text .. ' ' .. getKg(wiki)
end
return text
end
Line 2.374 ⟶ 3.120:
end
local function
local gender
local p21 = mw.wikibase.getBestStatements(riderID, 'P21') -- P21 is gender
Line 2.425 ⟶ 3.171:
end
local function
local time = tonumber(t)
local h, m, s = 0, 0, 0
Line 2.436 ⟶ 3.182:
end
if h>0 then str = str..mw.ustring.format ('%i'..
if m>=0 and h>0 then str = str.. mw.ustring.format('%02i'..
if m>0 and h==0 then str = str.. mw.ustring.format('%i'..
if s>=0 and (h>0 or m>0) then str = str.. mw.ustring.format('%02i'..
if s>=0 and h==0 and m==0 then str = str.. mw.ustring.format('%i'..
return str --time..': '..h..' '..m..' '..s
end
function func_error_message(
local l10nDef = {
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
Line 2.465 ⟶ 3.211:
end
return l10n
end
Line 3.264 ⟶ 3.223:
end
if inp == "0" then
this_label =
else
this_label = stageLink(inp, a, b)
Line 3.325 ⟶ 3.284:
local direction = contentLanguage:getDir()
local
local tCell=
tCell:cssText("text-align:" .. ((direction == 'ltr') and 'left' or 'right')):wikitext(previousText)
if stage ~= nil and wiki=="ar" then
tCell:css('width','50%')
end
tCell=
:cssText("text-align:" .. ((direction == 'ltr') and 'right' or 'left')):wikitext( nextText)
if stage ~= nil and wiki=="ar" then
tCell:css('width','50%')
end
return
end
--==
-- functions for infoboxs
local function infoGetOthers(others, entityID)
if not others[1].content then --picture
others[1].content, others[2].content = getLogo(entityID)
if not others[1].content then
others[1].content, others[2].content = getImage(entityID) -- picture, caption
end
end
if not others[3].content then -- map
others[3].content, others[5].content = getMap(entityID) -- P242 is 'locator map image'
end
if not others[4].content then -- map
others[4].content, others[6].content = getSectionalView(entityID) -- sectional_view
end
end
local function infoGetPlaceOrCountry(details,index, entityID, timeOfRace, PID) --generalized infoGetCountry
if not details[index].content then -- country
-- This function gives countries where the race take place
local place = {}
if not place[1] then
for _, p17 in statements(entityID, PID) do -- P17 is 'country'
local countryID = p17.mainsnak.datavalue.value.id
if PID=='P17' then
place[#place + 1] = flag(countryID, timeOfRace) .. ' ' .. getCountryName(countryID)
else
place[#place + 1] = wikibase.getLabel(countryID)
end
end
end
if place[1] then
if #place > 1 then
details[index].name = details[index].name_plural
end
details[index].content = table.concat(place, '<br/>')
end
end
end
local function infoGetPlace(details,index, entityID, timeOfRace)
infoGetPlaceOrCountry(details,index, entityID, timeOfRace, "P276")
end
local function infoGetCountry(details,index, entityID, timeOfRace)
infoGetPlaceOrCountry(details,index, entityID, timeOfRace, "P17")
end
local function infoGetStartEnd(details,index, entityID)
if not details[index].content then -- start place
local place = firstValue(entityID, 'P1427', 'id') -- P1427 is 'start point'
details[index].content = place and getPlaceLink(place)
end
if not details[index+1].content then -- end place
local place = firstValue(entityID, 'P1444', 'id') -- P1444 is 'destination point'
details[index+1].content = place and getPlaceLink(place)
end
end
local function infoGetParticipants(details,index, entityID)
-- Function that give the number of cyclists at the beginning and at the finishing of a race
for _, p1132 in statements(entityID, 'P1132') do -- P1132 is 'number of participants'
local amount = tonumber(p1132.mainsnak.datavalue.value.amount) -- tonumber to remove starting '+'
for _, q in qualifiers(p1132, 'P276') do -- P276 is 'location'
local location = q.value['numeric-id']
if location == 529711 then -- Q529711 is 'beginning'
if not details[index].content then details[index].content = amount end -- participants at start
elseif location == 12769393 then -- Q12769393 is 'end'
if not details[index+1].content then details[index+1].content = amount end -- participants at end
end
end
end
end
local function infoInitTab(width, name, icon, cellpadding)
if width==nil then width= '320px' end
local tab = mw.html.create('table')
if wiki == "eo" then
tab:cssText(standardtablecss):css('width','23em')
:addClass('infobox')
else
if cellpadding then
cellpadding=tostring(cellpadding)
else
cellpadding='4'
end
tab:attr('cellpadding',cellpadding)
:attr('cellspacing','0')
:cssText(standardtablecss)
:cssText("float:"..floatinfobox.."; max-width:"..width)
end
local tCell=tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('border-bottom:5px solid white; font-size:175%; text-align:center')
:css('background-color',backgroundColor)
local topTable = tCell:tag('table')
:cssText('width:100%')
local tRow=topTable:tag('tr')
tRow:tag('td'):wikitext(name or '')
tRow:tag('td'):wikitext(icon or '')
return tab
end
local function addARow(name, content)
local tRow
if content then
tRow= mw.html.create('tr'):css('vertical-align','top')
tRow:tag('td'):css('width','40%'):css('font-weight','bold')
:wikitext(name)
tRow:tag('td'):wikitext(content)
end
return tRow
end
local function addATitle(title)
local tRow
if title then
tRow= mw.html.create('tr'):tag('td'):attr('colspan','2')
:css('text-align','center')
:css('background-color',backgroundColor)
:css('font-weight','bold')
:wikitext(title)
end
return tRow
end
local function infoFillOthersDetails(tab, others, details,title, pxmax)
if not pxmax then
pxmax="300px"
end
if others and others[1].content then -- picture
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:" .. others[1].content .."|center|"..pxmax.."]]")
if others and others[2].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[2].content)
end
end
if details then
tab:node(addATitle(title))
for _, row in ipairs(details) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
end
end
end
local function infoFillOthersMap(tab, others)
if others[3].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[3].content .. "|center|300px]]")
if others[5].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[5].content)
end
end
if others[4].content then -- map
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[4].content .. "|center|300px]]")
if others[6].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[6].content)
end
end
end
local function wdDoc(tab, s, translation, ID, commons_cat)
local tCell=tab:tag('tr'):tag('td')
local tC
if commons_cat then
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:75%')
:wikitext(icon):tag('td')
else
tC=tCell:attr('colspan','2')
end
tC:cssText('text-align:right; border-top:3px solid '..backgroundColor..'; font-size:75%')
:wikitext("[[" .. s .. "|" .. translation .. "]] [[File:Wikidata-logo S.svg|12px|link=d:".. ID .."]]")
end
local function listWPlink(details, index, entityID, PID)
local org={}
for _, p in statements(entityID, PID) do
if p and p.mainsnak.snaktype == 'value' then
table.insert(org,WPlinkpure(p.mainsnak.datavalue.value.id))
end
end
if org[1] then
if #org > 1 then
details[index].name = details[index].name_plural
end
details[index].content = table.concat(org, '<br/>')
end
end
-- == Functions for team roster
local function getReason(riderReason, riderRef, p527,timeOfRace,riderEnd) --reason for end
local listofproperty={'P1642','P1643','P1534'}
local outTable={}
local seasonYear, endYear
if timeOfRace then
seasonYear=tonumber(string.sub(timeOfRace, 2, 5))
end
if riderEnd then
endYear=tonumber(string.sub(riderEnd, 2, 5))
end
--if not the last season, do not display the reason for end
if (riderReason == nil and (not endYear or
(seasonYear and endYear and (seasonYear== endYear)))) then --if no riderReason before then look for it, otherwise don't touch it
for _,v in ipairs(listofproperty) do
for _, q in qualifiers(p527, v) do
riderReason = q.value.id
end
end
if riderReason then
local label = string.gsub(wikibase.label(riderReason), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
riderRef = getReference(p527, 1)
riderReason = ', ' .. label
end
end
return riderReason, riderRef
end
local function getPosition(riderPosition,v)
local stagiaire
if riderPosition == nil then -- find the 'position' (P39) of a rider
for _, q in qualifiers(v, 'P39') do
stagiaire = q.value.id
local label = string.gsub(wikibase.label(stagiaire), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
Sitelink = wikibase.getSitelink('Q2328847')
if Sitelink then
riderPosition=', ' .. "[["..Sitelink .."|"..label.."]]"
else
riderPosition =', ' .. label
end
end
end
return riderPosition
end
local function trans(date, month, day)
if date ~= '' and date~=nil then
local _, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if m == '00' then m = month end
if d == '00' then d = day end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
return date
end
return nil
end
local function parseDate(date, defaultYear, defaultMonth, defaultDay, errortext, etext)
local y, m, d
local date=trans(date, defaultMonth, defaultDay)
if not date then
date = '+'..defaultYear..'-'..defaultMonth..'-'..defaultDay..'T00:00:00Z'
y=defaultYear
m=defaultMonth
d=defaultDay
errortext=errortext..etext
else
_, _, y, m, d = string.find(date, "(%d+)-(%d+)-(%d+)")
if not y or y=="0000" then
y=defaultYear
errortext=errortext..etext
end
date = '+'..y..'-'..m..'-'..d..'T00:00:00Z'
end
return date, y, m, d, errortext
end
local function findLastName(label,wiki)
if not label then label = '' end
local _, count = string.gsub(label, " ", " ")
local names
local a,b,c,d = '', '', '', ''
local done = false
if count ~= nil then count = count + 1 else count = 1 end
if count > 1 then
if count == 2 then
if label ~= '' then
a, b = string.match(label, "(%S+)%s+(%S+)")
names = b..' '..a
end
else
local name_parts_mk = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts_ru = {'да', 'ди', 'де', 'Де', 'ла', 'Ле', 'тен', 'ван', 'Ван'}
local name_parts = {'da', 'de', 'di', 'De', 'la', 'Le', 'ten', 'van', 'Van'}
if count == 3 and label ~= '' then
a, b, c = string.match(label, "(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..a done = true break end end
elseif wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..a done = true break end end
else
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..a done = true break end end
end
if not done then
names = c..' '..a..' '..b
done = true
end
end
if count > 3 and label ~= '' then
a, b, c, d = string.match(label, "(%S+)%s+(%S+)%s+(%S+)%s+(%S+)")
if wiki == 'mk' then
for _,v in ipairs(name_parts_mk) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_mk) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
elseif wiki == 'ru' then
for _,v in ipairs(name_parts_ru) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts_ru) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
else
for _,v in ipairs(name_parts) do if c == v then names = c..' '..d..' '..a..' '..b done = true break end end
for _,v in ipairs(name_parts) do if b == v then names = b..' '..c..' '..d..' '..a done = true break end end
end
if not done then names = label.."%"..b end --b..' '..c..' '..d..' '..a end
end
end
end
return names or ''
end
local function findSortKey(riderID, correctlanguage, wikiIsSlavic)
--find the last name to sort
if wikiIsSlavic and correctlanguage then
local label = wikibase.getLabelByLang(riderID, wiki)
if not label then
label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
else
local nametable = mw.text.split(label, ",")
if nametable[2] then --there is a coma so the lastname is first
return nametable[1]..nametable[2]
else --no coma
return findLastName(label,wiki)
end
end
else
local label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
end
end
--== V) Main functions ==
--=== A) Function race reference ===
local function race_reference(raceID)
Line 3.350 ⟶ 3.662:
}
local links = {}
local ref
for _, base in pairs(bases) do
local p = mw.wikibase.getBestStatements(raceID, base[2])
if p[1] and p[1].mainsnak.snaktype == 'value' then
ref=getReference(p[1], 1)
if ref then table.insert(links, ref) end
else
table.insert(links, ' [' .. base[3] .. p[1].mainsnak.datavalue.value .. " " .. base[1] ..']')
end
end
end
if #links == 1 then
return
elseif #links > 1 then
return
else
return ''
Line 3.423 ⟶ 3.741:
local s = {
header_function =
header_1 = 1000, -- translation 1 in function
header_2 = headertemp,-- translations 2, 3, 4, 5, 6 in function
title=wikibase.getLabel(calendarID), -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
country_column = countrycolumn,
Line 3.450 ⟶ 3.768:
local calendarID
if wiki == "ar" then frame = frame:getParent() end
local UCI =
local header_1_tab = {["UWT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1, ["Pro"]=22}
local display_code_tab= {["UWT"]=1 ,["europe"]=2 ,["asia"]=2,["america"]=2 ,["africa"]=2 ,["oceania"]=2, ["WWT"]=1, ["women"]=2, ["Pro"]=2}
local header_1_number = 12
Line 3.561 ⟶ 3.817:
local s = {
header_function =
header_1 = header_1_number, -- t
header_2 = tempdic.header_2,
Line 3.597 ⟶ 3.853:
end
function calendar_main(s,
localframe=s.frame
local calendarID=s.item
Line 3.607 ⟶ 3.863:
if not temp then s.error_message = 2 return '' end
local country=
if available_list==false then country=false end --otherwise the display put no "country" column...
Line 3.642 ⟶ 3.898:
end
return
end
Line 3.653 ⟶ 3.909:
UCIroad["women"] = {
['2021']= 'Q104304845', ['2020']='Q78466304', ['2019'] = 'Q66362617',
['2018'] = 'Q66762475', ['2017'] = 'Q66762546', ['2016'] = 'Q66762540',
['2015'] = 'Q66762534', ['2014'] = 'Q66762524', ['2013'] = 'Q66762521',
Line 3.660 ⟶ 3.916:
UCIITT["women"] = {
['2021']= 'Q104305086', ['2020'] = 'Q78466572', ['2019'] = 'Q66736271',
['2018'] = 'Q66762631', ['2017'] = 'Q66762614', ['2016'] = 'Q66762604',
['2015'] = 'Q66762597', ['2014'] = 'Q66762592', ['2013'] = 'Q66762584',
Line 3.688 ⟶ 3.944:
local s = {
header_function =
header_1 = 19, --
header_2 = {5, 20, 21},
Line 3.707 ⟶ 3.963:
end
function nationalchampionships_main(s,
localframe=s.frame
local tableChamp, fn_countrytable, t_Body = {}, {}, {}
Line 3.775 ⟶ 4.031:
end --end list of key
return
end
Line 3.781 ⟶ 4.037:
function p.victories(frame)
local s = {
header_function =
header_1 = 2, -- translation 1 in function
header_2 = {3, 4, 5, 6, 7},-- translations 2, 3, 4, 5, 6 in function
-- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
data_type = {'date', 'race', 'country', 'class', 'rider'},
Line 3.797 ⟶ 4.053:
end
function victory_main(s,
localframe=s.frame
local _
Line 3.805 ⟶ 4.061:
if temp then else s.error_message = 2 return '' end
local country=
if available_list==false then country=false end
Line 3.835 ⟶ 4.091:
end --end list of key
return
end
Line 3.964 ⟶ 4.097:
function p.stageinfobox(frame)
local details = {
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
}
local others = {
{ name =
{ name =
{ name =
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
--begin of the function
Line 4.026 ⟶ 4.161:
local entityID = mw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error
local localframe
Line 4.079 ⟶ 4.213:
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[4].content =
timeOfRace = pTime
end
Line 4.149 ⟶ 4.283:
if riderId ~= nil then
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
if q.P642 and q.P642[1].snaktype == 'value' then
for _, vv in pairs(q.P642) do
Line 4.175 ⟶ 4.309:
t_s.annex.equipe['link']=riderId
end
v['genre'] =
end
end
Line 4.214 ⟶ 4.348:
end
v['speed'] = qualifieramount(p2417, 'P2052')
v['genre'] =
end
end
Line 4.235 ⟶ 4.369:
if t_s.annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab= infoInitTab(width, name, icon)
infoFillOthersDetails(tab, others, details,
-- ranking table, general and stage
Line 4.245 ⟶ 4.379:
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(
for key, value in ipairs(thistable.order) do --value is the name of the class
Line 4.253 ⟶ 4.387:
if v['link'] then
local a1
a1, jersey_name, jerseyWPID = jersey_infobox(
if a1~='' then v['jersey'] = a1 end
if v['speed'] then
Line 4.260 ⟶ 4.394:
else
local lang = mw.language.getContentLanguage()
v['speed'] = '('.. lang:formatNum(v['speed'])..
end
end
if v['points'] then
if v['points'] > 1 then
temp=
else
temp=
end
v['points'] = v['points']..temp
end
local title, k = string.gsub(
if k > 0 then title = string.gsub(title, " ", "<br>", 1) end -- 
Line 4.281 ⟶ 4.415:
tCell:attr('rowspan','2')
end
tCell:cssText("width:1%;background-color:#
textalign .. ";padding:0 2px 0 2px;white-space:nowrap")
Line 4.287 ⟶ 4.421:
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(
else
tCell:wikitext(number(v['genre'], key, wiki))
Line 4.321 ⟶ 4.455:
if v['time'] then
tCell:wikitext(
end
if v['gap'] then
tCell:wikitext('+ '..
end
tCell:wikitext(v['points'])
Line 4.352 ⟶ 4.486:
infoFillOthersMap(tab, others)
tab:node(getPreviousNextLine(entityID,true))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox",
return tab
end
Line 4.362 ⟶ 4.496:
local WDlink_on = (wiki == "mk" or wiki == "ja")
local timeOfRace, errorMessage =
if not timeOfRace then return errorMessage end
local teamCats = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
["Q6154783"] = {4,5,1}, -- WorldTeam
["
["
["Q78464255"] = {6,7,
["
["
["
["
["
["
["
["
["
["
["
["
["
["Q26849121"] = {30,31,14}, -- Women's amateur cycling team
["Q20639848"] = {14,15,15}, -- club and region cycling team
["Q20653570"] = {14,15,15}, -- club and region cycling team
}
Line 4.406 ⟶ 4.543:
local header, sitelink
if teamCats[CatID] then
local done=false
if CatID=="Q2466826" then --name changed after 2020
local year = timeOfRace and tonumber(string.sub(timeOfRace, 2, 5))
if year and year>2019 then
if count == 1 then
header_label = translate("headoftableIII",32) -- singular name
else
header_label = translate("headoftableIII",33) -- plural name
end
done=true
end
end
if done==false then
if count == 1 then
header_label = translate("headoftableIII",teamCats[CatID][1]) -- singular name
else
header_label = translate("headoftableIII",teamCats[CatID][2]) -- plural name
end
end
if CatID=='Q78464255' then
Line 4.447 ⟶ 4.599:
local header
local
:cssText("max-width:95%; padding:0.5em; margin-right:1em; border:1px solid rgb(200,200,200)")
local tCell =
for _, team in ipairs(teams) do
Line 4.461 ⟶ 4.613:
count = 1
oldOrder = order
tOl = mw.html.create('
else
count = count + 1
Line 4.467 ⟶ 4.619:
oldCatID = team[2]
tOl:tag('li')
:cssText("
:wikitext(team[1])
end
Line 4.479 ⟶ 4.631:
:addClass('navigation-only')
:attr('colspan',2)
:cssText('border-top: 2px
tCell:tag('span'):css("float",floattable)
:wikitext('[[File:Wikidata-logo S.svg|12px|link=d:' ..raceID .. '#P1923]]')
return
end
Line 4.490 ⟶ 4.642:
function p.UCIclassification(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
Line 4.504 ⟶ 4.656:
function p.pointsclassification(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
Line 4.517 ⟶ 4.669:
function p.teamsclassificationbytime(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
Line 4.530 ⟶ 4.682:
function p.teamsclassificationbypoints(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
Line 4.543 ⟶ 4.695:
function p.stageclassification(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
Line 4.557 ⟶ 4.709:
function p.generalclassification(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
Line 4.568 ⟶ 4.720:
return new_classification(frame, s)
end
function p.generalclassificationpoint(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 = frame.args[1],
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 = tonumber(frame.args[2]) == 0 and 0 or 1
}
return new_classification(frame, s)
end
function p.generalclassificationforttt(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
Line 4.585 ⟶ 4.751:
function p.teamtimetrialclassification(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
Line 4.599 ⟶ 4.765:
function p.mountainsclassification(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
Line 4.612 ⟶ 4.778:
function p.sprintsclassification(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
Line 4.625 ⟶ 4.791:
function p.bestyoungclassificationbypoints(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
Line 4.638 ⟶ 4.804:
function p.bestyoungclassification(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
Line 4.651 ⟶ 4.817:
function p.u23classification(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
Line 4.664 ⟶ 4.830:
function p.combinationclassification(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
Line 4.677 ⟶ 4.843:
function p.combativeclassification(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
Line 4.690 ⟶ 4.856:
function p.custompointsclassification(frame)
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=string.gsub(frame.args[3], "%c", ""),
Line 4.703 ⟶ 4.869:
function p.customtimeclassification(frame)
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=string.gsub(frame.args[3], "%c", ""),
Line 4.737 ⟶ 4.903:
]=]
local timeOfRace, errorMessage =
if not timeOfRace then return errorMessage end
Line 4.751 ⟶ 4.917:
local tableHeader2_size = #s.header_2
if s.header_1_text ==nil then s.header_1_text=translate(s.header_function
local tableBody = mw.html.create('table')
Line 4.761 ⟶ 4.927:
local thisspan= mw.html.create('span'):cssText('float:left;'):wikitext('[[File:Wikidata-logo S.svg|12px|link=d:'.. raceID .. '#' .. s.property..']]')
tableBody:tag('tr'):tag('th')
:attr('colspan', tostring(tableHeader2_size + 1)):cssText("padding:2px 2px; text-align:center; background-color:
:wikitext(tostring(thisspan)..s.header_1_text)
Line 4.767 ⟶ 4.933:
for i, k in ipairs(s.header_2) do
if i ~= 2 or (country and available_list) then
local head=header:tag('th'):wikitext(translate(s.header_function
if i == 1 then
head:attr('colspan','2')
Line 4.792 ⟶ 4.958:
else
rank = ''
end
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)--"HD","NP","DQ"
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
else
riderDNF=''
end
Line 4.798 ⟶ 4.976:
if wiki == 'es' or wiki == 'fr' or wiki == 'ast' then
--[[ These wikis need the gender to display the rank correct. Other wikis can skip this. ]]
gender =
end
Line 4.903 ⟶ 5.081:
end
if s.header_2[4] == 4 then -- for table stageclassification, generalclassification, adds time and time gap
if
temp=calculateTime(h.value[2])
elseif rank == 1 and h.value[3]==nil then --avoid a plus with nothing temp=''
else
temp=plus .. calculateTime(h.value[3])
end
else
temp=
end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp)
Line 4.916 ⟶ 5.098:
if s.header_2[4] == 7 or (s.header_2[3] == 7 and s.header_2[1] == 1) then -- for table pointsclassification, adds points
--trick for UCI classification
if riderDNF=='' then
if h.value[1] then temp=h.value[1] else temp='' end tCell=tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em")
:wikitext(temp)
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=
else
temp2=
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
end
else
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(riderDNF)
end
end
Line 4.933 ⟶ 5.119:
-- for tables teamtimetrialclassification or generaltttclassification, adds time
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em")
:wikitext(
end
end
Line 4.939 ⟶ 5.125:
if s.property == 'P3497' then -- for table teambytimeclassification, adds time and time gap
if rank == 1 then
temp=
else
temp=
end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp)
Line 4.951 ⟶ 5.137:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=
else
temp2=
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 4.961 ⟶ 5.147:
if s.header_2[4] == 5 then -- for table teamtimetrialclassification, adds time gap
if l > 1 then temp= plus else temp='' end
tBody:tag('td'):cssText("text-align:right;padding:0 0.2em 0 0.2em"):wikitext(temp..
end
Line 4.968 ⟶ 5.154:
if type(h.value[4]) == "number" then
tCell:wikitext(mw.ustring.format('%.3f', h.value[4]))
:tag('span'):cssText("font-size:80%"):wikitext(
end
end
if riderDNF=='' then
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank or 999, tostring(tBody)}
else --disqualified should be higher than not disqualified if the ranking was revided
t_Body[#t_Body + 1] = {(type(rank) == 'number') and rank-0.1 or 999, tostring(tBody)}
end
end
end
tableBody=
local tableFooter1,tableFooter2
if s.display_ref == 1 then
Line 4.982 ⟶ 5.172:
:addClass('navigation-only')
:attr('colspan',tostring(tableHeader2_size + 1))
:cssText('border-top: 2px
tableFooter2=mw.html.create('tr')
tCell=tableFooter2:tag('td')
Line 5.024 ⟶ 5.214:
--=== G) Infobox ===
function p.infobox(frame)
return infobox_main(frame,0)
end
function p.infoboxseason(frame)
return infobox_main(frame,1)
end
function p.infoboxChamp(frame)
return infobox_main(frame,2)
end
function infobox_main(frame, selector)
localframe = frame
-- If true, winners will have Wikidata logos with link to Wikidata
Line 5.030 ⟶ 5.232:
-- If true, winners will the team of the cyclist
local team = true
local details, others, winners
if selector==0 then --normal infobox
details = {
{ name =
{ name =
{ name =
{ name =
{ name =
{ name = translate("infobox",9), name_plural = translate("infobox",10)}, -- country
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name = translate("infobox",32), special = true}, -- special 1
{ name = translate("infobox",33), special = true}, -- special 2
}
elseif selector==1 then --season infobox
details = {
{ name =
{ name = translate("infobox",3), name_plural = translate("infobox",4)}, -- competition (2)
{ name = translate("infobox",6), name_plural = translate("infobox",7)}, -- date (3)
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
}
else --champ
details = {
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name =
{ name = translate("infobox",33), special = true}, -- special 2
}
end
others = { --same for 3 infobox
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
if selector==0 then
winners = {
{ name = translate("infobox",19), QID = 'Q20882667' }, -- first
{ name = translate("infobox",20), QID = 'Q20882668' }, -- second
{ name = translate("infobox",21), QID = 'Q20882669' }, -- third
{ name = translate("infobox",22), QID = 'Q20883007' }, -- points
{ name = translate("infobox",23), QID = 'Q20883212' }, -- mountains
{ name = translate("infobox",24), QID = 'Q20883328' }, -- sprints
{ name = translate("infobox",25), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",26), QID = 'Q20893983' }, -- combativity
{ name = translate("infobox",35), QID = 'Q27067359' }, -- volantes
{ name = translate("infobox",36), QID = 'Q27067170' }, -- regularity
{ name = translate("infobox",27), QID = 'Q20893979' }, -- combination
{ name = translate("infobox",38), QID = 'Q27907715' }, -- breakaway
{ name = translate("infobox",39), QID = 'Q27907747' }, -- azzurri
{ name = translate("infobox",40), QID = 'Q28092831' }, -- rookie
{ name = translate("infobox",28), QID = 'Q20882921' }, -- teams
{ name = translate("infobox",37), QID = 'Q27104269' }, -- teamspoints
{ name = translate("infobox",41), QID ='Q61976850' },-- amateur
{ name = translate("infobox",42), QID ='Q61976872' } --nationality
}
elseif selector==1 then
winners = {
{ name = translate("infobox",52), QID = 'Q20882667' }, -- individual (first)
{ name = translate("infobox",53), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",54), QID = 'Q27104269' }, -- team (teamspoints)
{ name = translate("infobox",55), QID = 'Q98959152' }, -- team GS-I
{ name = translate("infobox",56), QID = 'Q98959153' }, -- team GS-II
{ name = translate("infobox",57), QID = 'Q98959155' }, -- team GS-III
{ name = translate("infobox",58), QID = 'Q72068715' }, -- country
{ name = translate("infobox",59), QID = 'Q72068724' } -- country U23
}
end --Champ has no winners
local entityID = mw.text.trim(frame.args[1])
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
Line 5.089 ⟶ 5.335:
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
if selector==0 or selector==1 then
getLocalContent(winners, localframe.args)
end
local timeOfRace, class
Line 5.100 ⟶ 5.349:
if not details[1].content then -- course
-- For FR Wiki and Wikidata, exception that permit to display 1er, 2e... for the edition number ;
-- for RU
local nr = firstValue(entityID, 'P393') -- P393 is 'edition number'
if nr then
Line 5.112 ⟶ 5.361:
end
local is_a
--system with P2094 and P3450
if classID then
class = classLinkFn(classID)
else
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if classes[instanceOf] then
class = classLinkFn(instanceOf)
break
end
end
end
local season = firstValue(entityID, 'P3450', 'id') -- P3450 is 'sports season of league or competition'
if season then
is_a = raceLink(season)
else
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= 'Q27968055' and classes[instanceOf] == nil then -- Q27020041 is 'sports season'
is_a = raceLink(instanceOf)
break
end
end
end
if nr and is_a then
details[1].content = nr .. ' ' .. is_a
Line 5.132 ⟶ 5.393:
end
if selector==0 or selector==1 then
if not details[2].content then -- competition
--
-- Competition of the cycling race : UCI World Tour 2016, UCI Europe Tour 2016...
local tours = {}
for _, p361 in statements(entityID, 'P361') do -- P361 is 'part of'
tours[#tours + 1] = raceLink(p361.mainsnak.datavalue.value.id)
end
if
if #tours
details[2].name = details[2].name_plural
end
if class then
tours[1] = tours[1] .. ' ' .. class
end
details[2].content = table.concat(tours, '<br/>')
end
end
end
if selector==0 then
if not details[3].content then -- stages local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[3].content = stages
end
end
end
local index_date
if selector==0 then
index_date=4
elseif selector==1 then
index_date=3
else
index_date=2
end
if
if not details[index_date].content then -- date
local
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime) details[
details[
timeOfRace = eTime
else
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[
timeOfRace = pTime
end
end
end
end
--from this point the functions differ fundamentally
if selector==0 then
local kmdistance
if not details[5].content then details[5].content, kmdistance = getDistance(entityID, true) end -- distance
infoGetCountry(details,6, entityID, timeOfRace)
infoGetStartEnd(details,7, entityID)
if
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
if teams > 0 then
details[9].content = teams
end
end
infoGetParticipants(details,10, entityID)
if not details[10].content or not details[11].content then
local Allp710= wikibase.getAllStatements(entityID, 'P710')
if Allp710 and #Allp710~=0 then
if
if not details[
local maxrank=1
for _, p710 in pairs(Allp710) do -- look into all statements
local q = p710.qualifiers
if q and q.P1352 and q.P1352[1].snaktype == 'value' then -- P1352 is ranking
end
end
if maxrank~=1 then details[11].content=maxrank end
end
end
end
if not details[13].content then
local elevation=getElevation(entityID)
if elevation then details[13].content =elevation else details[13].content = nil end
end --Elevation
local cost = firstValue(entityID, 'P2130') -- P2130 is cost
if cost then
local unit = cost.unit
cost = contentLanguage:formatNum(tonumber(cost.amount))
if wiki == 'fo' then cost = string.gsub(cost, "%.", ",") end
if unit == "http://www.wikidata.org/entity/Q4916" then cost = cost .. ' €'
elseif unit == "http://www.wikidata.org/entity/Q4917" then cost = cost .. ' $'
end
details[14].content = cost
end
end
elseif selector==1 then
if not details[4].content then -- racing
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[4].content = stages
end
end
if not details[5].content then -- location
infoGetPlace(details,5, entityID, timeOfRace) --in GAN version, the separator is , not <br />
end
if not details[6].content then -- organizer sitelink
listWPlink(details, 6, entityID,'P644') --org
end
if not details[7].content then -- organizer sitelink
listWPlink(details, 7, entityID,'P2670') --team ????
end
else --champ
infoGetCountry(details,3, entityID, timeOfRace)
if not details[4].content then -- location
infoGetPlace(details,4, entityID, timeOfRace) --in GAN version, the separator is , not <br />
end
if not details[5].content then -- arena / stadion
listWPlink(details, 5, entityID,'P115')
end
if not details[6].content then -- racing
local stages = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if stages > 0 then
details[6].content = stages
end
end
if not details[7].content then -- teams
local teams = #wikibase.getBestStatements(entityID, 'P1923') -- P1923 is 'participating teams'
if teams > 0 then
details[7].content = teams
end
end
if not details[8].content then -- organizer sitelink
listWPlink(details, 8, entityID,'P644') --org
end
end
tab = infoInitTab("300px", name, icon)
infoFillOthersDetails(tab, others, details,
if selector==0 or selector==1 then --no winners for champ
local win = {}
for _, v in pairs(winners) do
win[v.QID] = ''
end
end
winner(entityID, win, timeOfRace, false, WDlink_on, team, true)
for _, v in pairs(winners) do
if not v.content then
if
end
end
if v.content then
tRow= mw.html.create('tr') :css('vertical-align','top')
tRow:tag('td'):css('font-weight','bold'):wikitext(v.name)
tRow:tag('td'):wikitext(v.content)
winRows=winRows..tostring(tRow) --not elegant
end
end
if
:cssText('border-bottom:5px solid white; background-color:'..backgroundColor..'; text-align:center')
:css('font-weight','bold')
:wikitext(translate("infobox",18))
tab:wikitext(winRows)
end
end
Line 5.261 ⟶ 5.582:
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center')
:wikitext("[[File:".. others[3].content .. "|center|300px]]")
if others[5].content then -- caption
tab:tag('tr'):tag('td'):attr('colspan','2'):css('text-align','center'):css('font-size','80%')
:wikitext(others[5].content)
end
end
tab:node(getPreviousNextLine(entityID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/infobox",
return tab
end
--=== H)
function p.
localframe = frame
local
-- If true, winners will have Wikidata logos with link to Wikidata
local
local tRace = {race={
raceId,
raceDate,
future,
},
vainqueur= {},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
lastWinner,
maxWinner,
}
local details = {
{ name = translate("raceinfobox",4)}, -- sport
{ name = translate("raceinfobox",5)}, -- creation date
{ name = translate("raceinfobox",6)}, -- disparition date
{ name = translate("raceinfobox",7)}, -- number of editions
{ name = translate("raceinfobox",8)}, -- periodicity
{ name = translate("raceinfobox",9)}, -- type , name_plural = translate("infobox",10)
{ name = translate("victories",5)}, --country
{ name = translate("raceinfobox",10), name_plural = translate("raceinfobox",11)}, -- place
{ name = translate("raceinfobox",12), name_plural = translate("raceinfobox",13)}, --org
{ name = translate("raceinfobox",27), name_plural = translate("raceinfobox",28)}, --race director
{ name = translate("raceinfobox",14)}, -- official web site
{ name = translate("raceinfobox",15), name_plural = translate("raceinfobox",16)}, -- Cat
{ name = translate("raceinfobox",17)}, -- circuit
}
local others = {
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
local
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
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
local timeOfRace, class
local listOfNames=getFormerNames(entityID, 'P1448')
local sport_id=firstValue(entityID, 'P641', 'id')
local icon = (sport_id == "Q3609") and -- P641 is 'sport', Q3609 is 'road bicycle racing'
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
--1st ist sport
if not details[1].content and sport_id then
details[1].content = WPlinkpure(sport_id)
end
--creation
local creation=firstValue(entityID, 'P571', 'time')
if not details[2].content and creation then
details[2].content = funcDate(creation, "Y" )
end
--disparition
local disparition=firstValue(entityID, 'P576', 'time')
if not details[3].content and disparition then
details[3].content = funcDate(disparition,"Y")
--populate tRace
listOfWinners(entityID, tRace)
--number of editions
if not details[4].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[4].content = tostring(tRace.numberOfEditions).." (" .. translate("raceinfobox",31) .. " "..tostring(tRace.lastEditionYear)..")"
end
--periodicity
if not details[5].content then
details[5].content = getPeriodicity(entityID, tRace)
end
--type
if not details[6].content then
details[6].content = getType(entityID)
end
timeOfRace=nil --could be from last edition
if not details[7].content then
infoGetCountry(details,7, entityID, timeOfRace)
end
if not details[8].content then
infoGetPlace(details,7, entityID, timeOfRace)
end
if not details[9].content then
listWPlink(details, 9, entityID,'P644') --organiser
end
if not details[10].content then
listWPlink(details, 10, entityID,'P488') --race dir
end
if not details[11].content then
details[11].content = officialSite(entityID)
end
--Class and circuit
local classContent, circuitLink, numberClass= getClass(entityID)
if not details[12].content then
details[12].content = classContent
if numberClass >1 then
details[12].name = details[12].name_plural
end
end
if not details[13].content then
details[13].content = circuitLink
end
--Build the table
tab = infoInitTab("300px", name, icon)
--former names
wiki_listOfNamesAtBottom={'ru'}
local listOfNamesAtBottom = false
for _, value in pairs(wiki_listOfNamesAtBottom) do --
if value == wiki then listOfNamesAtBottom = true end
end
--picture at the top
infoFillOthersDetails(tab, others, nil,translate("raceinfobox",19),"260px")
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
end
end
end
infoFillOthersDetails(tab, nil, details,translate("raceinfobox",19),"260px")
if listOfNamesAtBottom then
if listOfNames and #listOfNames>1 then
tab:node(addATitle(translate("raceinfobox",18)))
for _,
tab:node(addARow(v[2],v[3])) --period, name
end
end
end
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),tRace.lastWinner))
end
if (tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addARow(translate("raceinfobox",22),tRace.maxWinner))
end
end
if tRace.nextLink or tRace.lastLink then
tab:node(addATitle(translate("raceinfobox",23)))
local outTable
if
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("raceinfobox",24)..
":<br>'''"..
tRace.lastLink.."'''"
tCell:wikitext(lastText)
tab:node(outTable)
end
if tRace.nextLink then
outTable = mw.html.create('tr')
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.."'''"
tCell:cssText("text-align:center"):wikitext(nextText)
tab:node(outTable)
end
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26), entityID)
return tab
end
--=== I) Team roster
function p.teamroster(frame)
localframe=frame
local squadID
if frame.args[1] then squadID = string.gsub(frame.args[1], "%c", "") end
local flags, pays = {}, {}
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
local riderPosition, riderReason, riderRef, errortext
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
local labelMissing = false
local teamID, startOfSeason, 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 sort
Line 5.407 ⟶ 5.824:
}}
A rider called 'Laurens De Vreese' is sorted after 'De Vreese Laurens'. If you want to sort after 'Vreese Laurens De'
change that in the code. In
]]
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
Line 5.435 ⟶ 5.852:
riderStart, riderEnd=nil, nil
local riderID = p527.mainsnak.datavalue.value.id
riderName, correctlanguage =getRiderLink(riderID, startOfSeason) --label
if WDlink_on==true then riderName=riderName..wdLink(riderID) end
local timeOfRace = startOfSeason
_, startOfSeasonYear, startOfSeasonMonth, startOfSeasonDay, _=parseDate(startOfSeason, '2040', '12', '31', '','')
riderBirthday=firstValue(riderID, 'P569','time')
if not
local sortkey =
for _, q in qualifiers(p527, 'P580') do
local startdate = q.value['time']
timeOfRace = startdate
riderStart =
end
for _, q in qualifiers(p527, 'P582') do
local enddate=q.value['time']
riderEnd =
end
riderPosition=
riderReason, riderRef=getReason(riderReason,riderRef,p527, timeOfRace,enddate)
local
local changedTime = '+0000-00-00'
Line 5.467 ⟶ 5.883:
else
for _, v in statements(riderID, 'P54') do -- look into all P54 teams
errortext=''
local thisteamID = v.mainsnak.datavalue.value.id
if thisteamID == teamID then
endDatefound=true
beginDate, endDate = getStartEndfromQuali(v.qualifiers)
beginDate, beginYear, beginMonth, beginDay, errortext = parseDate(beginDate, '2040', '01', '01', errortext, ' missing qualifiers by rider')
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)
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
-- riders who start after 1 January or end earlier then 31 December in the season
riderStart =
if
riderEnd = funcDate(endDate, 'small')
else
riderEnd =
end
riderPosition=
end
else
Line 5.502 ⟶ 5.910:
end
if not stagiaire then
endDatefound=true
if not endDatetemp then endDatefound=false end
beginDate, beginYear, beginMonth, beginDay, errortext = parseDate(beginDate, '2040', '01', '01', errortext, ' missing qualifiers by rider')
endDate, endYear, endMonth, endDay, _ = parseDate(endDatetemp, beginYear, '12', '31', errortext, '')
if beginYear < startOfSeasonYear or (beginYear == startOfSeasonYear and beginMonth < startOfSeasonMonth) or
(beginYear == startOfSeasonYear and beginMonth == startOfSeasonMonth and beginDay < startOfSeasonDay) then -- start time < season time
if (endDate or '') >= changedTime then -- find maximum end time
-- Case Pierre-Roger Latour: Chambéry CF (2012 - 2014), time season at 2013
-- Task: changedTime should be after start time, but before startOfSeason
else
changedTime = endDate or ''
end
end
end
Line 5.530 ⟶ 5.932:
if changedTime ~= '+0000-00-00' then
riderTeam = getTeam(riderID, changedTime, nil)
local _, _,
timeTeam = ' ('..
end
end
end
end
Line 5.553 ⟶ 5.950:
end
--save
local tRider={
sortkey=sortkey,
riderName=riderName,
riderBirthday=riderBirthday,
riderTeam=riderTeam,
timeTeam=timeTeam,
riderStart=riderStart,
riderEnd=riderEnd,
riderPosition=riderPosition,
riderReason=riderReason,
riderRef=riderRef,
errortext=errortext,
pays=pays,
flags=flags
}
if correctlanguage == true then
table.insert(riderTablecorrect,tRider )
else
table.insert(riderTablenotcorrect,
end
end
Line 5.573 ⟶ 5.986:
end
local
:addClass('sortable')
:attr('cellpadding', '2')
Line 5.579 ⟶ 5.992:
:css('border' , '1px solid rgb(200,200,200)')
:css('padding', '3px')
:css('background-color',backgroundColor)
:tag('th'):attr('colspan', 4):cssText('text-align:center;white-space:nowrap')
:wikitext('<span style="float:left">[[File:Wikidata-logo S.svg|12px|link=d:'.. frame.args[1].. '#P527]]</span>')
:wikitext(
local header =
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(
if available_list and wiki ~= 'lv' then
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(
end
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(
local temp
local iii = 1
for i, v in pairs (riderTable) do
local tRow=outTable:tag('tr'):css('line-height','1.8em')
local tCell= tRow:tag('td'):cssText("padding:0 1em 0 0;white-space:nowrap")
if not available_list or wiki == 'lv' then temp=v['flags']..' ' else temp='' end
tCell:wikitext(temp..v['riderName']):attr('data-sort-value',v['sortkey'])
if v['riderStart']~=nil or v['riderEnd']~=nil then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
local note=''
if v['riderReason'] ~= nil then
note = ', [[#tr_'..i..frame.args[1]..'|'..
if wiki == "ar" then note = '، [[#tr_'..i..frame.args[1]..'|'..
end
tCell:wikitext(' ('..(v['riderStart'] or '')..'–'..(v['riderEnd'] or '')
.. (v['riderPosition'] or '')..note..')')
elseif v['riderReason'] then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
:wikitext('([[#tr_'..i..frame.args[1]..'|'..
end
tCell=tRow:tag('td'):cssText("text-align:right;white-space:nowrap")
if wiki == 'lv' then
local _, _,
local _, _,
tCell:wikitext(frame:expandTemplate{ title = 'Template:Birth date and age2', args = {
else
tCell:wikitext(
if available_list then
tRow:tag('td'):wikitext(v['flags'].. ' '..v['pays'])
end
end
if wiki =='he' then
local isRtl = (mw.ustring.find(v['riderTeam'], '|.*[א-ת]') or (not mw.ustring.find(v['riderTeam'], '|') and mw.ustring.find(riderTeam, '[א-ת]')))
if isRtl then
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:right")
Line 5.658 ⟶ 6.050:
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
if v['riderTeam'] then
tCell:wikitext(v['riderTeam'].. v['timeTeam']..v['errortext'])
end
--tableEndText is not a table
if v['riderReason'] ~= nil or v['errortext'] ~= '' then
local temp=(v['riderReason'] or '')..(v['errortext'] or '')
if iii == 1 then
tableEndText = tableEndText..
else
tableEndText = tableEndText.. '<span style="color:white">'..
end
iii = iii + 1
if riderRef ~= nil then tableEndText = tableEndText..
frame:extensionTag{name='ref', content=v['riderRef'], args = {name='tr_'..iii..frame.args[1]}} end
tableEndText = tableEndText.. '<br>'
end
end
if labelMissing then
local UCIlink
Line 5.689 ⟶ 6.076:
end
:attr('data-sort-value','zz')
:attr('colspan',4)
:cssText("border-top: 2px
:tag('tr')
:tag('td'):attr('colspan',4)
:attr('data-sort-value','zzz')
:cssText("text-align:right")
:tag('small'):wikitext(
return tostring(
end
--==
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp,
winnersProperty=winnersProperty,
custom=false
return listofwinners_main(frame, s)
end
function p.listofwinnersyoung(frame)
local winnersProperty = {'Q20883139','Q72099969','Q72099972'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[4]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=tonumber(frame.args[5]), -- since the answer is "args[4]"
winnersProperty=winnersProperty,
}
return listofwinners_main(frame, s)
Line 5.757 ⟶ 6.126:
local s = {
countryflag=false,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
winnersProperty=winnersProperty,
displayteam = false,
custom=false
}
return listofwinners_main(frame, s)
end
function p.listofwinnersnowiki(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(frame, s)}
end
function p.listofwinnersteamofpoint(frame)
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
}
return
end
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
}
return listofwinners_main(frame, s)
end
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
end
function p.
local winnersProperty = {'
local displayteamtemp = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then displayteamtemp = true end -- display of the rider with the team
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam=displayteamtemp, -- since the answer is "args[4]"
winnersProperty=winnersProperty,
custom=false
}
return listofwinners_main(frame, s)
Line 5.876 ⟶ 6.252:
local winnersProperty ={}
--general
if frame.args[
--podium
if frame.args[
table.insert( winnersProperty,'Q20882668')
table.insert( winnersProperty,'Q20882669')
end
--points
if frame.args[
--mounstain
if frame.args[
-- sprints
if frame.args[
-- youth
if frame.args[
-- combativity
if frame.args[
-- volante
if frame.args[
-- regularity
if frame.args[
-- combination
if frame.args[
-- breakaway
if frame.args[
-- azzurri
if frame.args[
-- rookie
if frame.args[
-- teams
if frame.args[
-- teamspoints
if frame.args[
-- amateur
if frame.args[
--nationality
if frame.args[
-- country
if frame.args[22] ~= nil and tonumber(frame.args[22]) ==1 then table.insert( winnersProperty, 'Q72068715' ) end
-- country U-23
if frame.args[23] ~= nil and tonumber(frame.args[23]) ==1 then table.insert( winnersProperty, 'Q72068724' ) end
local s = {
countryflag=true,
beginyear=tonumber(frame.args[2]),
endyear=tonumber(frame.args[3]),
shapka=tonumber(frame.args[4]),
displayteam = false,
winnersProperty=winnersProperty,
custom=true
}
return listofwinners_main(frame, s)
Line 5.934 ⟶ 6.316:
local beginyear=s.beginyear or 0
local endyear=s.endyear or 0
local shapka=s.shapka or 0
local titletable
if s.custom then
titletable={
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ '
[ 'Q27907715' ]=translate("listofwinners",15), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",16), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",17), -- rookie
[ 'Q61976850' ]=translate("listofwinners",18), -- amateur
[ 'Q61976872' ]=translate("listofwinners",19), -- nationality
[ 'Q72068715' ]=translate("listofwinners",23), -- winner country
[ 'Q72068724' ]=translate("listofwinners",24), -- winner countryU23
}
else --main
titletable={
-- winner:
[ 'Q20882667' ]=translate("listofwinners",2), -- winner
[ 'Q20883007' ]=translate("listofwinners",2), -- points
[ 'Q20883212' ]=translate("listofwinners",2), -- mountains
[ 'Q20883328' ]=translate("listofwinners",2), -- sprints
[ 'Q20883139' ]=translate("listofwinners",2), -- youth (time or point)
[ 'Q20893983' ]=translate("listofwinners",2), -- combativity
[ 'Q20893979' ]=translate("listofwinners",2), -- combination
[ 'Q20882921' ]=translate("listofwinners",2), -- team (time)
[ 'Q27067359' ]=translate("listofwinners",2), -- volantes
[ 'Q27067170' ]=translate("listofwinners",2), -- regularity
[ 'Q27104269' ]=translate("listofwinners",2), -- teampoints
[ 'Q27907715' ]=translate("listofwinners",2), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",2), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",2), -- rookie
[ 'Q61976850' ]=translate("listofwinners",2), -- amateur
[ 'Q61976872' ]=translate("listofwinners",2), -- nationality
[ 'Q72068715' ]=translate("listofwinners",2), -- winner country
[ 'Q72068724' ]=translate("listofwinners",2), -- winner countryU23
[ 'Q98959152' ]=translate("listofwinners",2), -- winner team GS-I
[ 'Q98959153' ]=translate("listofwinners",2), -- winner team GS-II
[ 'Q98959155' ]=translate("listofwinners",2), -- winner team GS-III
-- 2 place:
[ 'Q20882668' ]=translate("listofwinners",3), -- second
[ 'Q72065970' ]=translate("listofwinners",3), -- second teampoints
[ 'Q72099969' ]=translate("listofwinners",3), -- youth (time or point)
[ 'Q72068718' ]=translate("listofwinners",3), -- second country
[ 'Q72068725' ]=translate("listofwinners",3), -- second countryU23
[ 'Q98959192' ]=translate("listofwinners",3), -- second team GS-I
[ 'Q98959194' ]=translate("listofwinners",3), -- second team GS-II
[ 'Q98959195' ]=translate("listofwinners",3), -- second team GS-III
-- 3 place:
[ 'Q20882669' ]=translate("listofwinners",4), -- third
[ 'Q72065977' ]=translate("listofwinners",4), -- third teampoints
[ 'Q72099972' ]=translate("listofwinners",4), -- youth (time or point)
[ 'Q72068721' ]=translate("listofwinners",4), -- third country
[ 'Q72068729' ]=translate("listofwinners",4), -- third countryU23
[ 'Q98959196' ]=translate("listofwinners",4), -- third team GS-I
[ 'Q98959197' ]=translate("listofwinners",4), -- third team GS-II
[ 'Q98959198' ]=translate("listofwinners",4), -- third team GS-III
}
end
--localframe defined as global for references
Line 5.991 ⟶ 6.406:
for num, _ in pairs(localframe.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localframe.args[num]), 'row') then
local _, _,
local _, _, key01,
if
if
end
end
Line 6.005 ⟶ 6.420:
if part.rank ~= 'deprecated' and part.mainsnak.snaktype == 'value' then
local partID = part.mainsnak.datavalue.value.id
local timeOfRace=getTimeOfRace(partID) --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.070 ⟶ 6.476:
local tTitleRow=mw.html.create('tr')
:
:css('background-color',backgroundColor)
local tCell=tTitleRow:tag('th')
if WDlink_on == false then
Line 6.076 ⟶ 6.483:
:wikitext("[[File:Wikidata-logo S.svg|12px|link=d:"..raceID .. "#P527]]")
end
tCell:wikitext(
for _, pp in ipairs(s.winnersProperty) do
tTitleRow:tag('th'):wikitext(titletable[pp])
Line 6.118 ⟶ 6.525:
end
--firstpart with header no foot
if
return
elseif shapka == 2 then -- you need to add a title and you can add text at the beginning
return table_center
else -- you need to add a title and you can add anything and anywhere
return table_first .. tostring(tTitleRow) .. table_center .. "</table>"
end
end
--==
function p.listofstages(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
Line 6.166 ⟶ 6.573:
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
= 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
local _,
local key01,
local key21, key22
for num, var in pairs(localframe.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(var), WProw) then
_, _,
_, _, key01,
key2 = mw.ustring.lower(mw.text.trim(key2))
_, _, key21, key22 = mw.ustring.find(key2, "(%a+)%s*(%a*)")
if not WPcontent[
if
if
WPcontent[
WPcontent[
WPcontent[
end
if
WPcontent[
WPcontent[
WPcontent[
end
if
val = string.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[
WPcontent[
WPcontent[
end
if
if
if
val = string.gsub(val, "|", "|border|right|20px|", 1)
WPcontent[
if
end
end
Line 6.276 ⟶ 6.683:
local label, section_title
if sOrdinal == "0" then
label, section_title =
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.284 ⟶ 6.691:
("[[" .. section_title .. "|" .. label .. "]]")
local sDate =
local tempoverall
if winners['Q20882763']~='' then tempoverall=winners['Q20882763'] else tempoverall=winners['Q20882667'] end
Line 6.304 ⟶ 6.711:
:cssText(standardtablecss)
local tRow=tab:tag('tr'):
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1))
tRow:tag('th'):wikitext(
tRow:tag('th'):wikitext(
tRow:tag('th'):css('color',
tRow:tag('th'):wikitext(
if thereiselevation then
tRow:tag('th'):wikitext(
end
tRow:tag('th'):wikitext(
tRow:tag('th'):wikitext(
for num, row in pairs(rows) do
Line 6.469 ⟶ 6.877:
ITTtemp=true
else
local
if
local testMenRoadrace, testMenITT, testWomenRoadrace, testWomenITT
local
testMenRoadrace = string.find(
testMenITT = string.find(
testWomenRoadrace = string.find(
testWomenITT = string.find(
if testWomenRoadrace or testMenRoadrace then road = true roadtemp=true end
if testWomenITT or testMenITT then ITT = true ITTtemp=true end
Line 6.505 ⟶ 6.913:
end
--avoid double display of jersey
result = "<small>("..
elseif road then
result = "<small>("..
elseif ITT then
result = "<small>("..
else
result = ""
Line 6.516 ⟶ 6.924:
end
--
local function winnerjersey(raceID, winners)
local jerseytable, bgcolortable={}, {}
Line 6.573 ⟶ 6.981:
if thisGT=='Q33881' then
Sitelink = wikibase.getSitelink('Q2267539')
if Sitelink then overallname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q175399')
if Sitelink then pointsname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q927157')
if Sitelink then mountainname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q641662')
if Sitelink then youngname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q1436680')
if Sitelink then teamname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q2094179')
if Sitelink then combativityname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q1835362')
if Sitelink then combinedname="[["..Sitelink .."|"..
elseif thisGT=='Q33861' then
Sitelink = wikibase.getSitelink('Q1164275')
if Sitelink then overallname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q641083')
if Sitelink then pointsname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q641060')
if Sitelink then mountainname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q641662')
if Sitelink then youngname="[["..Sitelink .."|"..
else
Sitelink = wikibase.getSitelink('Q2532554')
if Sitelink then overallname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q2241695')
if Sitelink then pointsname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q1118296')
if Sitelink then mountainname="[["..Sitelink .."|"..
Sitelink = wikibase.getSitelink('Q2330008')
if Sitelink then combinedname="[["..Sitelink .."|"..
end
end
local winners = {
{ name =
{ name = overallname or
{ name = pointsname or
{ name = mountainname or
{ name =
{ name = youngname or
{ name = combativityname or
{ name =
{ name =
{ name = combinedname or
{ name =
{ name =
{ name =
{ name = teamname or
{ name =
{ name =
{ name =
}
Line 6.673 ⟶ 7.081:
local t = {key=ii, name=v.name, jersey='', bg_color='', used=false}
for ii = 1, #stages+1 do
t[ii] = { {}, {}, {} } --
end
columntable[v.QID] = t
Line 6.695 ⟶ 7.103:
for ii, v in pairs(stages) do
if v.mainsnak.snaktype == 'value' then
local somewinner = false --show the stage
local stageID = v.mainsnak.datavalue.value.id
local sitelink = mw.wikibase.getSitelink(stageID)
Line 6.710 ⟶ 7.118:
local label, section_title
if sOrdinal == "0" then
label, section_title =
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.745 ⟶ 7.153:
columntable[v.QID][ii][1]=win[v.QID]
if ii==1 then --first stage
columntable[v.QID][ii][2]=1 --start at row 1
columntable[v.QID][ii][3]=1 --1 consecutive stage
elseif columntable[v.QID][ii-1][1]==win[v.QID] then --same winner as past stage
local initialstage=columntable[v.QID][ii-1][2]
columntable[v.QID][ii][2]=initialstage --no change of the first stage
columntable[v.QID][initialstage][3]=columntable[v.QID][initialstage][3]+1 --one more consecutive stage
columntable[v.QID][ii][3]=0
else --new winner
columntable[v.QID][ii][2]=ii --start at this row/stage
columntable[v.QID][ii][3]=1 --1 consecutive stage
end
columntable[v.QID].used=true
if ii==1 then --read the jersey in the first stage of a race
columntable[v.QID].jersey=jerseytable[v.QID]
columntable[v.QID].bg_color=bgcolortable[v.QID]
Line 6.783 ⟶ 7.191:
somewinner=true
thiskey=generaltoleader[v.QID]
--fill the final classification
columntable[thiskey][#stages+1][1]=win[v.QID]
columntable[thiskey][#stages+1][2]=#stages+1
columntable[thiskey][#stages+1][3]=1
--#stages is the last stage
and thiskey~='Q20893984'
then --check nil actually, but it is a table..
columntable[thiskey][#stages][1]= win[v.QID] --extrapolate the winner
if type(columntable[thiskey][#stages-1][1])=="string" and
win[v.QID]==columntable[thiskey][#stages-1][1]
then --if there is a leader at forelast stage
local initialstage=columntable[thiskey][#stages-1][2]
columntable[thiskey][#stages][2]=initialstage
Line 6.798 ⟶ 7.212:
end
end
if jerseytable[v.QID] and jerseytable[v.QID]~='' then
columntable[thiskey].jersey=jerseytable[v.QID]
Line 6.805 ⟶ 7.218:
end
end
table.insert(stageinfotable,{sLink=
--build the table
Line 6.812 ⟶ 7.225:
:attr('cellspacing','0')
:cssText(standardtablecss)
local tRow=tab:tag('tr'):
:css('text-align','center')
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 6.838 ⟶ 7.252:
tCell=tRow:tag('td')
if ii==#stageinfotable then --general row
tCell:cssText('font-weight:bold; border-top: 2px black solid;')
end
Line 6.863 ⟶ 7.277:
tCell=tRow:tag('td')
if ii~=#stageinfotable and v.somewinner==true then
tCell:wikitext(
elseif ii~=#stageinfotable then
--empty
elseif v.somewinner==true then --general row
tCell:cssText('border-top: 2px black solid')
:wikitext(translate("listofstagesclassification",1)) --not attributed
else
tCell:cssText('border-top: 2px black solid') --empty
Line 6.879 ⟶ 7.293:
end
--
function p.startlist(frame)
local IDtemp
Line 6.887 ⟶ 7.301:
local s = {
header_function =
header_1 = 1, -- translation 1 in function
header_2 = {2, 3,4,5},
item=IDtemp,
Line 6.897 ⟶ 7.311:
}
local
return startlist_main(s,
end
Line 6.908 ⟶ 7.322:
local s = {
header_function =
header_1 = 1, -- translation 1 in function
header_2 = {2, 3,4,5},-- translations 2, 3, 4, 5, 6 in function
item=IDtemp,
title="Start list", -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
Line 6.922 ⟶ 7.336:
local function startlist_sub(p710, timeOfRace, WDlink_on, istable)
local h,
local tBody = '' --row in our case
local riderID,
riderID = p710.mainsnak.datavalue.value.id
Line 6.944 ⟶ 7.358:
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 =
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =
elseif dnf=='Q1210382' then riderDNF =
elseif dnf=='Q1229261' then riderDNF =
else riderDNF=''
end
Line 6.976 ⟶ 7.390:
if wiki == 'es' or wiki == 'fr' or wiki == 'ast' then
--[[ These wikis need the gender to display the rank correct. Other wikis can skip this. ]]
gender =
end
Line 6.984 ⟶ 7.398:
if countryID then
if wiki ~= "ar" then
riderLink = riderLink ..
end
riderLink = flag(countryID, timeOfRace) ..' '.. riderLink
Line 6.994 ⟶ 7.408:
end
riderTeamID=seasonToTeamID(riderTeamID)
riderTeamCode= getTeamCode(riderID, timeOfRace, q)
if
local sortkey = riderDossard == "" and 0 or tonumber(riderDossard)
Line 7.004 ⟶ 7.419:
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(riderLink)
if istable then
tBody:tag('td'):cssText("text-align:right;padding:0 0.5em"):wikitext(
end
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(number(gender,riderRank,wiki)..riderDNF)
table.insert(
return
end
function startlist_main(s,
local ridertable, DStable, subtable = {}, {}, {}, {}
local DSID, DSLink, DSteamID, DSteam
Line 7.026 ⟶ 7.441:
if q.P642 and q.P642[1].snaktype == 'value' then
DSteamID=q.P642[1].datavalue.value.id
end
table.insert(DStable, {DSLink=DSLink,
end
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
subtable=startlist_sub(p710, timeOfRace, WDlink_on, false)
ridertable[#ridertable + 1] = {
subtable[1].sortkey,
riderTeamLink=subtable[1].riderTeamLink,
riderTeamID=subtable[1].riderTeamID,
riderTeamCode=subtable[1].riderTeamCode,
tBody=subtable[1].tBody
}
end
Line 7.046 ⟶ 7.467:
tSubtitle:tag('td'):attr('width','30px')
:css("align:right;text-align:right")
:wikitext(
tSubtitle:tag('td'):attr('width','200px')
:css("align:right;text-align:right")
:wikitext(
tSubtitle:tag('td'):attr('width','85px')
:css("align:right;text-align:right")
:wikitext(
else
tSubtitle=mw.html.create('tr')
tSubtitle:tag('td'):attr('width','30px'):wikitext(
tSubtitle:tag('td'):attr('width','250px'):wikitext(
tSubtitle:tag('td'):attr('width','35px'):wikitext(
end
--look for transition between teams
local numberofteam=0
local tDS
if #ridertable==0 then--empty table
Line 7.067 ⟶ 7.489:
else
for ii=1,#ridertable do
if ridertable[ii].
if ii~=1 and ridertable[ii].
--new team
if test==1 or ii==1 then
Line 7.074 ⟶ 7.496:
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(
thisDS=nil
end
Line 7.096 ⟶ 7.518:
:attr('clear',floattable)
tTitle = mw.html.create('tr')
: :attr('align','center') local tCell=tTitle:tag('th'):attr('colspan','3')
tCell:tag('big'):wikitext(ridertable[ii].
insideTable:node(tTitle)
Line 7.106 ⟶ 7.530:
--look for the DS of this team
for _,v in pairs(DStable) do
if v.
end
end
Line 7.112 ⟶ 7.536:
end
--last DS
if
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5).." "..thisDS)
end
tag:node(thisTableRow)
return
end
end
function startlisttable_main(s,
local t_Body, fn_datetable, subtable = {}, {}, {}, {}
local WDlink_on = (wiki == "mk" or wiki == "ja" or wiki == "ru")
Line 7.130 ⟶ 7.558:
t_Body[#t_Body + 1] = {subtable[1].sortkey, tostring(subtable[1].tBody)}
end
return
end
--
local function checkminmaxyear(minmaxyear,thisyear)
if minmaxyear.minimum ==0 or thisyear<minmaxyear.minimum then
Line 7.146 ⟶ 7.574:
function p.riderranking(frame)
local s = {
item = string.gsub(frame.args[1], "%c", ""),
return riderranking_main(frame, s)
end
function riderranking_main(frame,s)
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local
local minmaxyear= {
minimum = 0, -- lots of jerseyID
Line 7.160 ⟶ 7.588:
}
local calendarlistpresent={
["UCIwomen"]=false,
["UCImen"]=false
}
local UCI = {}
--inverse the table
for k,v in pairs(data.UCIYearToQ) do
UCI[k]={}
for kk, vv in pairs(v) do
UCI[k][vv]=kk
end
end
local UCImaster=data.UCImaster
UCImastername={
["women"]=translate("riderranking",2), ['WWT']=translate("riderranking",3),
['WWC']=translate("riderranking",4), ["UWT"]= translate("riderranking",5),
["europe"]=translate("riderranking",6), ["asia"]=translate("riderranking",7),
["oceania"]=translate("riderranking",8),["america"]=translate("riderranking",9) ,
["africa"]=translate("riderranking",10), ["WR"]=translate("riderranking",11),
["WC"]=translate("riderranking",12), ["UPT"]=translate("riderranking",13), --WC is world calendar here
["UCImen"]=translate("riderranking",14), ["WCmen"]=translate("riderranking",15), --UCImen = UCI ranking 1984-2004, WC= World cup men
["Pernod"]=translate("riderranking",16), ["Desgrange"]=translate("riderranking",17),
}
--missing: men world cup, men UCI ranking, pernod, Desgrange-Colombo
UCImasterlimit={
["women"]= {b=1989, e=0}, --women=Calendrier international féminin UCI, begin/end 0 = no end
["WWT"]= {b=2016, e=0},
["WWC"]= {b=1998, e=2015},
["UWT"]= {b=2011, e=2018},
["europe"]= {b=2005, e=0},
["asia"]= {b=2005, e=0},
["oceania"]={b=2005, e=0},
["america"]={b=2005, e=0},
["africa"]= {b=2005, e=0},
["WR"]= {b=2016, e=0},
["WC"]= {b=2009, e=2010},
["UPT"]= {b=2005, e=2008},
["UCImen"]= {b=1984, e=2004},
["WCmen"]= {b=1989, e=2004},
["Pernod"]= {b=1959, e=1987},
["Desgrange"]= {b=1948, e=1958},
}
local listofwomencalendar={"
local listofmencalendar={"Desgrange","Pernod","UCImen","WCmen","UPT",
"WC","UWT","WR","europe","asia","america","oceania","africa","Pro"}
local gender=getGenderCode(s.item, 'm')
if gender=="f" then
listofcalendar=listofwomencalendar
else
listofcalendar=listofmencalendar
end
--init table
for ii=1900,2100,1 do
for _, calendar in pairs(listofcalendar) do
rank=nil,
sitelink=nil
Line 7.215 ⟶ 7.667:
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
rank = tonumber(q.P1352[1].datavalue.value.amount)
DSQ = isdisqualified(p1344, q)
else
rank= nil
end
if rank then
resultTable[thisyear][calendar]["DSQ"]=DSQ or ""
calendarlistpresent[calendar]=true
sitelink=mw.wikibase.getSitelink(thisCompetition)
end
end
Line 7.234 ⟶ 7.688:
local wdLin = wdLink(string.gsub(s.item, '%s', '') .. "#P1344")
local tRow= finalTable:tag('tr'):tag('th'
:css("background-color",backgroundColor)
:wikitext(wdLin..' '..translate("riderranking",1))
for ii=minmaxyear.minimum,minmaxyear.maximum,1 do
tRow:tag('th'):attr("width","50px
:css('background-color',backgroundColor)
:css("text-align","center")
:css("padding","1px 1px")
:wikitext(tostring(ii))
end
Line 7.252 ⟶ 7.711:
end
for
thisyear=tostring(
color="white"
if
if
color="gold"
elseif (2<=tonumber(
color="YellowGreen"
elseif (4<=tonumber(
color="silver"
end
tCell=tRow:tag('td'):attr("bgcolor",color):cssText(resultTable[thisyear][calendar]["DSQ"])
rank=number(gender,rank,wiki)
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
tCell:wikitext(
end
--this ranking exist for this year, but the rider is not ranked
elseif yy>=UCImasterlimit[calendar].b and
(UCImasterlimit[calendar].e==0 or yy<=UCImasterlimit[calendar].e) then
if wiki=="fr" then
tRow:tag('td'):wikitext(' nc ')
else
tRow:tag('td'):wikitext(' - ')
end
--this ranking does not exist for this year
else
tRow:tag('td'):css('background-color',backgroundColorLight)
end
end
Line 7.278 ⟶ 7.747:
end
local UCIlink, legend
if wiki=="fr" then
UCIlink="https://www.uci.org/fr/route/classements"
legend= " Légende : nc = non classé"
else
UCIlink="https://www.uci.org/road/rankings"
legend=""
end
Line 7.289 ⟶ 7.760:
finalTable:tag('tr'):tag('td'):addClass("navigation-only")
:attr('colspan',tostring(tableyearsize))
:cssText("border-top: 2px
tCell=finalTable:tag('tr'):tag('td'):attr('colspan',tostring(tableyearsize))
:tag('small')
tCell:tag('span'):css("float","left")
:wikitext(legend)
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1).."["..UCIlink..' UCI]')
return
end
end
local function toboolean(str)
if str=="true" then
return true
elseif str=="false" then
return false
else
return str
end
end
--=== O) Rider infobox
local function convertDate(date1, beginOrEnd, initialYear, finalYear)
if not date1 then
if beginOrEnd==0 then --begin
y1=tostring(initialYear)
m1="01"
d1="01"
else
y1=tostring(finalYear)
m1="12"
d1="31"
end
else
_, _, y1,m1,d1 = string.find(date1, "(%d+)-(%d+)-(%d+)")
if m1 ==nil or m1=="00" then
if beginOrEnd==0 then --begin
m1="01"
d1="01"
else--end
m1="12"
d1="31"
end
end
end
return '+'..y1.."-"..m1.."-"..d1.."T00:00:00Z"
end
local function listofTeam(itemID, initialYear, finalYear, PID)
--first we have to read P54 of the rider
--alternative P6087 for managed team
local riderteam={}
local stagiaire
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
if p54 then
teamId=p54.mainsnak.datavalue.value.id
else
teamId=nil
end
local q = p54.qualifiers
if q then
local sTime, eTime=getStartEndfromQuali(q)
sTime=convertDate(sTime, 0, initialYear, finalYear)
eTime=convertDate(eTime, 1, initialYear, finalYear)
if q.P39 and q.P39[1] and q.P39[1].snaktype == 'value' then
stagiaire = q.P39[1].datavalue.value
else
stagiaire = nil
end
dis=checkDis(q)
table.insert(riderteam,{teamId=teamId, startTime=sTime, endTime=eTime, stagiaire=stagiaire, dis=dis})
end
end
return riderteam
end
--format the date for display of the team
local function riderFormatDate(thisDate)
if thisDate=='' then
return ''
else
local month=math.ceil(thisDate['month']/2)
if month==12 or month==1 then
return thisDate['year']
else
local date1='+'..thisDate['year'].."-"..month.."-".."01".."T00:00:00Z"
-- local newobj = Complexedate.splitDate(date1)
if month == 0 or month==nil then
return thisDate['year']
else
return month..'.'..thisDate['year']
end
end
end
end
local function getTeamInfo(teamId,mm,yy,dd,managedTeam)
--get the nature and name of the team for the date mm,yy
mm=tostring(mm)
yy=tostring(yy)
dd=tostring(dd)
if mw.ustring.len(mm)==1 then mm='0'..mm end
thistime='+'..yy.."-"..mm.."-"..dd.."T00:00:00Z"
local sitelink, teamNature=getTeamLinkCat(teamId, thistime, false)
local cat, boolean
local amateurcat={Q20639848=true,Q20652655=true,Q26849121=true}
local nationalcat={Q23726798=true, Q20738667=true, Q54660600=true, Q54555994=true, Q99658502=true}
if managedTeam then
cat=nationalcat
else
cat=amateurcat
end
if cat[teamNature] then --club
boolean=true--amateur / national selection
else
boolean=false--pro / not national selection
end
return boolean, sitelink
end
--for managed team, the table should be splat, as we can be national trainer and team trainer at the same time
local function analyzeManagedTeam(teamRider, initialYear,finalYear)
local natTeamOut, managedTeamOut={},{}
local dis="road"
local managedTeam=true
for i=1,24 do --init table
natTeamOut[i]={}
managedTeamOut[i]={}
for j=initialYear,finalYear do
natTeamOut[i][j]={ amateurTeam, link, stagiaire=nil}
managedTeamOut[i][j]={amateurTeam,link, stagiaire=nil}
end
end
local teamId, natTeam, sitelink
local sYear, sMonth,eYear, eMonth, sDay, eDay
if teamRider==nil then return nil end
for _, v in pairs(teamRider) do --for each team where was the rider
if v['dis']==dis then
--exception managed at the reading
_, _, sYear,sMonth,sDay = string.find(v['startTime'], "(%d+)-(%d+)-(%d+)")
_, _, eYear,eMonth,eDay = string.find(v['endTime'], "(%d+)-(%d+)-(%d+)")
sYear=tonumber(sYear)
sMonth=tonumber(sMonth)
eYear=tonumber(eYear)
eMonth=tonumber(eMonth)
if sYear<=eYear then --test of congruence
for yy=sYear,eYear do
for mm=1,12 do
local mmindex=(mm-1)*2+1
--avoid reading info where the team is not the one of the rider
getinfo=true
if (yy==sYear and mm<sMonth) or (yy==eYear and mm>eMonth) then
getinfo=false
end
if getinfo then
if (yy==sYear) and (mm==sMonth) and (sDay~='01' and sDay~='00' and sDay~=nil)then
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,sDay, managedTeam)
if natTeam then
natTeamOut[mmindex+1][yy]['amateurTeam']=true
natTeamOut[mmindex+1][yy]['link']=sitelink
else
managedTeamOut[mmindex+1][yy]['amateurTeam']=false
managedTeamOut[mmindex+1][yy]['link']=sitelink
end
else
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,1, managedTeam)
if natTeam then
natTeamOut[mmindex][yy]['amateurTeam']=true
natTeamOut[mmindex][yy]['link']=sitelink
if natTeamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
natTeamOut[mmindex+1][yy]['amateurTeam']=true --a nat team stays a nat team
natTeamOut[mmindex+1][yy]['link']=sitelink
end
else
managedTeamOut[mmindex][yy]['amateurTeam']=false
managedTeamOut[mmindex][yy]['link']=sitelink
if managedTeamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
natTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
managedTeamOut[mmindex+1][yy]['amateurTeam']=false --a nat team stays a nat team
managedTeamOut[mmindex+1][yy]['link']=sitelink
end
end
end
end
end
end
end
end
end
return natTeamOut, managedTeamOut --a filled matrix with the link and nature of the teams
end
local function analyzeTeam(teamRider, initialYear,finalYear, dis)
local teamOut={}
local managedTeam=false
for i=1,24 do --init table
teamOut[i]={}
for j=initialYear,finalYear do
teamOut[i][j]={ amateurTeam, link, stagiaire}
end
end
local teamId, amateurTeam, sitelink
local sYear, sMonth,eYear, eMonth, sDay, eDay
if teamRider==nil then return nil end
for _, v in pairs(teamRider) do --for each team where was the rider
if v['dis']==dis then
--exception managed at the reading
_, _, sYear,sMonth,sDay = string.find(v['startTime'], "(%d+)-(%d+)-(%d+)")
_, _, eYear,eMonth,eDay = string.find(v['endTime'], "(%d+)-(%d+)-(%d+)")
sYear=tonumber(sYear)
sMonth=tonumber(sMonth)
eYear=tonumber(eYear)
eMonth=tonumber(eMonth)
if sYear<=eYear then --test of congruence
for yy=sYear,eYear do
for mm=1,12 do
local mmindex=(mm-1)*2+1
--avoid reading info where the team is not the one of the rider
getinfo=true
if (yy==sYear and mm<sMonth) or (yy==eYear and mm>eMonth) then
getinfo=false
end
if getinfo then
if (yy==sYear) and (mm==sMonth) and (sDay~='01' and sDay~='00' and sDay~=nil)then
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,sDay, managedTeam)
teamOut[mmindex+1][yy]['amateurTeam']=amateurTeam
teamOut[mmindex+1][yy]['link']=sitelink
teamOut[mmindex+1][yy]['stagiaire']=v['stagiaire']
else
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,1, managedTeam)
teamOut[mmindex][yy]['amateurTeam']=amateurTeam
teamOut[mmindex][yy]['link']=sitelink
teamOut[mmindex][yy]['stagiaire']=v['stagiaire']
if teamOut[mmindex+1][yy]['amateurTeam']==nil or v['stagiaire'] then --to avoid problem with team name change during the month
amateurTeam, sitelink=getTeamInfo(v['teamId'],mm,yy,30,managedTeam)
teamOut[mmindex+1][yy]['amateurTeam']=amateurTeam
teamOut[mmindex+1][yy]['link']=sitelink
teamOut[mmindex+1][yy]['stagiaire']=v['stagiaire']
end
end
end
end
end
end
end
end
return teamOut --a filled matrix with the link and nature of the teams
end
local function insertTeam(teamAmateur,teamPro,sDate,eDate,v)
local sDate2=riderFormatDate(sDate)
local eDate2=riderFormatDate(eDate)
local ins = {link=v['link'], sDate=sDate2,eDate=eDate2,stagiaire=v['stagiaire']}
if v['amateurTeam'] then
table.insert(teamAmateur,ins)
else
table.insert(teamPro,ins)
end
return teamAmateur,teamPro
end
local function synthetizeTable(analyzedTeam, initialYear,finalYear)
local teamPro, teamAmateur, tempTeam, tempsDate, tempeDate={}, {},{},{},{}
local empty=true
local active=false
--bring together successive month with identical content
for yy=initialYear,finalYear do
for mm=1,24 do
local v=analyzedTeam[mm][yy]
if v['amateurTeam']~=nil then
if empty then --first line
active=true
empty=false
tempTeam=v
tempsDate['month']=mm
tempsDate['year']=yy
else
if tempTeam['amateurTeam']==v['amateurTeam'] and tempTeam['link']==v['link']
and tempTeam['stagiaire']==v['stagiaire'] then --no change
if yy==finalYear and mm==24 then--present team
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,'',tempTeam)
end
else--change
--save the old
if active then --if active false then it was already saved
if mm==1 then
tempeDate['year']=yy-1
tempeDate['month']=24
else
tempeDate['year']=yy
tempeDate['month']=mm-1
end
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,tempeDate,tempTeam)
end
--save the new
active=true
tempTeam=v
tempsDate['month']=mm
tempsDate['year']=yy
end --change
end--first line
elseif active then --there was a team and now there is an empty period
active=false
--save the old
if mm==1 then
tempeDate['year']=yy-1
tempeDate['month']=24
else
tempeDate['year']=yy
tempeDate['month']=mm-1
end
teamAmateur,teamPro=insertTeam(teamAmateur,teamPro,tempsDate,tempeDate,tempTeam)
tempTeam['link']=nil --avoid problem if the rider comes back in the same team
end
end-- for mm
end--for yy
return teamAmateur,teamPro
end
local function listOfManagedTeamTable(itemID, initialYear,finalYear)
local managedTeamRider = listofTeam(itemID, initialYear,finalYear,'P6087')--raw list of team
if not managedTeamRider then
return nil, nil
end
local natTeamOut, managedTeamOut=analyzeManagedTeam(managedTeamRider, initialYear,finalYear) --table with links and nature of teams
local nationalTeam,_=synthetizeTable(natTeamOut, initialYear,finalYear)
local _,managedTeam=synthetizeTable(managedTeamOut, initialYear,finalYear)
return nationalTeam,managedTeam
end
local function listOfTeamTable(itemID, initialYear,finalYear)
local teamRider = listofTeam(itemID, initialYear,finalYear,'P54')--raw list of team
if not teamRider then
return nil, nil
end
local analyzedTeam1=analyzeTeam(teamRider, initialYear,finalYear, "road") --table with links and nature of teams
local teamAmateur,teamPro=synthetizeTable(analyzedTeam1, initialYear,finalYear) --table formated, global
local analyzedTeam2=analyzeTeam(teamRider, initialYear,finalYear, "mountainBike")
local _, teamMountainBike=synthetizeTable(analyzedTeam2, initialYear,finalYear)
local analyzedTeam3=analyzeTeam(teamRider, initialYear,finalYear, "cycloCross")
local _, teamCycloCross=synthetizeTable(analyzedTeam3, initialYear,finalYear)
local analyzedTeam4=analyzeTeam(teamRider, initialYear,finalYear, "track")
local _, teamTrack=synthetizeTable(analyzedTeam4, initialYear,finalYear)
return teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack
end
function getBirthDeathDate(entityID)
local birthDate=firstValue(entityID, 'P569', 'time')
local deathDate=firstValue(entityID, 'P570', 'time')
local temp2, temp3, birth, death, initialYear, finalYear, age
if birthDate then
local birthDateFormatted= funcDate(birthDate, 'long')
age, initialYear, finalYear=calculateAge(birthDate)
local birthPlace = firstValue(entityID, 'P19', 'id')
local birthPlaceLink=''
if birthPlace then birthPlaceLink=getPlaceLink(birthPlace, birthDate) end
local plural, gen_singular, gen_plural = plural(age)
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 not deathDate then
temp2=' ('..tostring(age)..' '..ans..')<br/>'
else
temp2='<br/>'
end
birth=birthDateFormatted..temp2..birthPlaceLink
else
birth=nil
end
if deathDate then
local deathDateFormatted= funcDate(deathDate, 'long')
local deathPlace= firstValue(entityID, 'P20', 'id')
local deathPlaceLink=''
if deathPlace then deathPlaceLink=getPlaceLink(deathPlace, deathDate) end
if birthDate then
local age=calculateAge(birthDate, deathDate)
local plural, gen_singular, gen_plural = plural(age)
local ans
if gen_singular then
ans=translate("riderinfobox",48)
elseif gen_plural then
ans=translate("riderinfobox",49)
else
ans=translate("riderinfobox",50)
end
temp2=' ('..tostring(age)..' '..ans..')<br/>'
else
temp2='<br/>'
end
death=deathDateFormatted..temp2..deathPlaceLink
else
death=nil
end
return birth, death, initialYear, finalYear
end
local function presentTeam(itemID)
local tToday=os.date("*t")
if mw.ustring.len(tToday["month"])==1 then tToday["month"]='0'..tToday["month"] end
if mw.ustring.len(tToday["day"])==1 then tToday["day"]='0'..tToday["day"] end
local today='+'..tToday["year"].."-"..tToday["month"].."-"..tToday["day"].."T00:00:00Z"
local plural=false
local teamId, result, teamLink, teamLinkRoad, row
for _, s in statements(itemID, 'P54') do
p54 =checktime(s, s.qualifiers, today) --present Team
if p54 then
teamId= p54.mainsnak.datavalue.value.id
teamLink=getTeamLinkCat(teamId, today)
dis=checkDis(p54.qualifiers)
row=nil
if dis=='road' then
teamLinkRoad=teamLink
elseif dis=='mountainBike' then
row=teamLink..' (VTT)'
elseif dis=='cycloCross' then
row=teamLink..' (cyclo-cross)'
else
row=teamLink..' (piste)'
end
if row then
if not result then
result = row
else
result= result..'<br/>'..row
plural = true
end
end
end
end
if teamLinkRoad and result then --put road first
result = teamLinkRoad..' (route)<br/>'..result
plural= true
elseif teamLinkRoad then
result = teamLinkRoad
end
return result, plural
end
local function getSomeNames(details,entityID, PID, index, display_language)
local rows={}
if not details[index].content then
local listOfNames=getFormerNames(entityID, PID)
if listOfNames then
for _, v in pairs(listOfNames) do
rows[#rows + 1]=v[3]
if v[2] and v[2]~='' then
rows[#rows]=rows[#rows]..' <small>('..v[2]..')</small>'
end
if display_language then
rows[#rows]=rows[#rows]..' <b><small>('..v[4]..')</small></b>'
end
end
if #rows>0 then
details[index].content = table.concat(rows, '<br/>')
end
end
end
end
--for wikidata input
function teamTable(tab, teamAmateur, title_singular, title_plural)
if teamAmateur and #teamAmateur>0 then
if #teamAmateur==1 then
tab:node(addATitle(title_singular))
else
tab:node(addATitle(title_plural))
end
for _, v in pairs(teamAmateur) do
local nametemp=v['link']
if v['sDate']==v['eDate'] then
periodtemp=v['sDate']
else
periodtemp=v['sDate']..'-'..v['eDate']
end
if v['stagiaire'] then
local stagiaire = string.gsub(wikibase.label('Q2328847'), "%b()", "") or getLabelFallback('Q2328847',{'en', 'fr', 'de'})
nametemp=nametemp..' ('..stagiaire..')'
end
tab:node(addARow(periodtemp or '',nametemp)) --period, name
end
end
end
--for local data
function localTeamTable(tab, names, periods, title_singular, title_plural)
if names then
names = mw.text.split(names, '<br />')
periods = mw.text.split(periods or '', '<br />')
if #names==1 then
tab:node(addATitle(title_singular))
else
tab:node(addATitle(title_plural))
end
for i, name in pairs(names) do
tab:node(addARow(periods[i] or '', name))
end
end
end
local function dispArrayLabel(details, index, entityID, PID)
if not details[index].content then
for _, p in statements(entityID, PID) do
if p and p.mainsnak.snaktype == 'value' then
local label=wikibase.getLabelByLang(p.mainsnak.datavalue.value.id, wiki)
if label then
if not details[index].content then
details[index].content=label
else
details[index].content=details[index].content..'<br/>'..label
if details[index].name_plural then
details[index].name = details[index].name_plural
end
end
end
end
end
end
end
function p.riderinfobox(frame)
local frame = frame
local lang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
local details = {
{ name = translate("riderinfobox",1), name_plural =translate("riderinfobox",2)}, -- birth name
{ name = translate("riderinfobox",3), name_plural =translate("riderinfobox",4)}, -- nick name
{ name = translate("riderinfobox",5), name_plural =translate("riderinfobox",6)}, -- official name
{ name = translate("riderinfobox",7), name_plural =translate("riderinfobox",8)}, -- official name
{ name = translate("riderinfobox",9) }, -- birth translate("riderinfobox",9)
{ name = translate("riderinfobox",10)}, -- death
{ name = translate("riderinfobox",11), name_plural =translate("riderinfobox",12)}, -- country
{ name = translate("riderinfobox",13), name_plural =translate("riderinfobox",14)}, -- present team
{ name = translate("riderinfobox",15), name_plural =translate("riderinfobox",16)}, -- speciality
{ name = translate("riderinfobox",17) }, -- lateralisation
{ name = translate("riderinfobox",18) }, -- blood group
{ name = translate("riderinfobox",19) }, -- height
{ name = translate("riderinfobox",20) }, -- weight
{ name = translate("riderinfobox",21), name_plural =translate("riderinfobox",22)}, -- awards
}
local teams = {
{ name = translate("riderinfobox",23), name_plural =translate("riderinfobox",24)}, -- directed teams
{ name = translate("riderinfobox",25)}, -- directed years
{ name = translate("riderinfobox",26), name_plural =translate("riderinfobox",27)}, -- amateur names
{ name = translate("riderinfobox",28)}, -- amateur periods
{ name = translate("riderinfobox",29), name_plural =translate("riderinfobox",30)}, -- nonUCI names
{ name = translate("riderinfobox",31)}, -- nonUCI periods
{ name = translate("riderinfobox",32), name_plural =translate("riderinfobox",33)}, -- pro names
{ name = translate("riderinfobox",34)}, -- pro periods
{ name = translate("riderinfobox",35), name_plural =translate("riderinfobox",36)}, -- UCI names
{ name = translate("riderinfobox",37)}, -- UCI periods
{ name = translate("riderinfobox",52), name_plural =translate("riderinfobox",53)}, -- national selections
{ name = translate("riderinfobox",54)}, -- national selection years
}
--separated to have a title
local subtitle = {
{ name = translate("riderinfobox",51)}, -- insertion of a sub-title
}
--separated to have a title
local victories = {
{ name = translate("riderinfobox",38)}, -- main victories
}
--separated to have a title
local medals = {
{ name = translate("riderinfobox",47)}, -- main victories
}
local others = {
{ name = translate("infobox",29)}, -- picture
{ name = translate("infobox",30)}, -- caption
{ name = translate("infobox",31)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30)}, -- caption map
{ name = translate("infobox",30)}, -- caption sectional
}
local entityID = mw.text.trim(frame.args[1])
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
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
local display_birthnameastitle=false
for _, value in pairs(display_birthnameastitle_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_birthnameastitle=true end
end
getLocalContent(subtitle, localframe.args)
if not subtitle[1].content and display_birthnameastitle then
local p1477 = mw.wikibase.getBestStatements(entityID, "P1477")
if p1477[1] and p1477[1].mainsnak.snaktype == 'value' then
subtitle[1].content = p1477[1].mainsnak.datavalue.value.text..' <b><small>('..
p1477[1].mainsnak.datavalue.value.language..')</small></b>'
end
if not subtitle[1].content then
local p1559 = mw.wikibase.getBestStatements(entityID, "P1559") -- P580 is start time
if p1559[1] and p1559[1].mainsnak.snaktype == 'value' then
subtitle[1].content = p1559[1].mainsnak.datavalue.value.text..' <b><small>('..
p1559[1].mainsnak.datavalue.value.language..')</small></b>'
end
end
end
local commons_cat=firstValue(entityID, 'P373', 'id')
infoGetOthers(others, entityID)
getLocalContent(details, localframe.args)
getLocalContent(teams, localframe.args)
getLocalContent(others, localframe.args)
getLocalContent(victories, localframe.args)
getLocalContent(medals, localframe.args)
local listOfBirthNames, listOfNickNames, listOfOfficialNames, listOfShortNames
local icon = ' [[File:Cycling (road) pictogram.svg|35px]]'
local display_language=false
for _, value in pairs(display_language_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_language=true end
end
-- getSomeNames(details, entityID, 'P1477', 1, display_language) --birthname
--less prio than P1477
getSomeNames(details, entityID, 'P1559', 1, display_language) --birthname, bis
getSomeNames(details, entityID, 'P1449', 2, display_language) --nick name
getSomeNames(details, entityID, 'P1448', 3, display_language) --official name
getSomeNames(details, entityID, 'P1813', 4, display_language) --short name
local birth, death, initialYear, finalYear=getBirthDeathDate(entityID)
if not details[5].content then
details[5].content=birth
end
if not details[6].content then
details[6].content= death
end
local display_flag=false
for _, value in pairs(display_flag_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_flag=true end
end
if not details[7].content then
local listOfProperty={'P1532','P27'}
local countryID
local countryList={}
for _, prop in ipairs(listOfProperty) do
if #countryList==0 then --if P1532 is used P17 is not used
for _, p1532 in statements(entityID, prop) do
countryID = p1532.mainsnak.datavalue.value.id
local period, sTime=getPeriod( p1532.qualifiers, true)
if not sTime then sTime="+"..initialYear.."-01-01T00:00:00Z" end --first
local temp
if display_flag then
temp= flag(countryID, sTime).." "..getCountryName(countryID)
else
temp=getCountryName(countryID)
end
table.insert(countryList,{sTime, period,temp})
end
end
end
table.sort(countryList, function(a, b) return a[1] < b[1] end)
if countryList and #countryList==1 then
details[7].content=countryList[1][3]
elseif countryList then
details[7].name = details[7].name_plural
details[7].content=''
for _, v in pairs(countryList) do
details[7].content= details[7].content..v[3] ..' <small>'..v[2]..'</small><br/>'
end
end
end
if not details[8].content then
local plural
details[8].content, plural=presentTeam(entityID)
if plural then
details[8].name = details[8].name_plural
end
end
--speciality
dispArrayLabel(details, 9, entityID, 'P413')
--lateralisation, for cycling not very interesting
--dispArrayLabel(details, 10, entityID, 'P552')
--blood group, idem
--dispArrayLabel(details, 11, entityID, 'P1853')
--height
if not details[12].content then
details[12].content=getHeight(entityID)
end
local display_weight=true
for _, value in pairs(display_noweight_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_weight=false end
end
--weight
if not details[13].content and display_weight then
details[13].content=getWeight(entityID)
end
--award, should be table
--awards look weird
--if not details[14].content then
-- dispArrayLabel(details, 14, entityID, 'P166')
--end
local amateurTeam, nonUCITeam, proTeam, UCITeam --local data
local amateurWD=true
local proWD=true
local managedWD=true
local teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack=listOfTeamTable(entityID, initialYear, finalYear)
local nationalTeam, managedTeam=listOfManagedTeamTable(entityID, initialYear, finalYear)
local managedTeam_names, managedTeam_periods, amateurTeam_names, amateurTeam_periods
local nonUCITeam_names, nonUCITeam_periods, proTeam_names, proTeam_periods
local nationalTeam_names, nationalTeam_periods
local UCITeam_names, UCITeam_periods
if teams[1].content then
managedTeam_names=teams[1].content
managedTeam_periods=teams[2].content
managedWD=false
end
if teams[3].content then
amateurWD=false
amateurTeam_names=teams[3].content
amateurTeam_periods=teams[4].content
end
if teams[5].content then
amateurWD=false
nonUCITeam_names=teams[5].content
nonUCITeam_periods=teams[6].content
end
if teams[7].content then
proWD=false
proTeam_names=teams[7].content
proTeam_periods=teams[8].content
end
if teams[9].content then
proWD=false
UCITeam_names=teams[9].content
UCITeam_periods=teams[10].content
end
if teams[11].content then
nationalTeam_names=teams[11].content
nationalTeam_periods=teams[12].content
managedWD=false
end
--plate and grab
tab = infoInitTab("300px", name, icon, 2)
if subtitle[1].content then
tCell=tab:tag('tr'):tag('td'):attr('colspan','2')
:cssText('solid white; text-align:center')
:wikitext(subtitle[1].content)
end
infoFillOthersDetails(tab, others, details,"Information","260px")
if amateurWD then
teamTable(tab, teamAmateur, translate("riderinfobox",26), translate("riderinfobox",27))
else
localTeamTable(tab,amateurTeam_names, amateurTeam_periods, translate("riderinfobox",26), translate("riderinfobox",27))
localTeamTable(tab,nonUCITeam_names, nonUCITeam_periods, translate("riderinfobox",29), translate("riderinfobox",30))
end
if proWD then
teamTable(tab, teamPro, translate("riderinfobox",45),translate("riderinfobox",46))
teamTable(tab, teamMountainBike, translate("riderinfobox",39), translate("riderinfobox",40))
teamTable(tab, teamCycloCross, translate("riderinfobox",41), translate("riderinfobox",42))
teamTable(tab, teamTrack, translate("riderinfobox",43), translate("riderinfobox",44))
else
localTeamTable(tab,proTeam_names, proTeam_periods,translate("riderinfobox",45), translate("riderinfobox",46))
localTeamTable(tab,UCITeam_names, UCITeam_periods, translate("riderinfobox",35), translate("riderinfobox",36))
end
--managed teams
if managedWD then
teamTable(tab, nationalTeam, translate("riderinfobox",52), translate("riderinfobox",53))
teamTable(tab, managedTeam, translate("riderinfobox",23), translate("riderinfobox",24))
else
localTeamTable(tab,managedTeam_names, managedTeam_periods,translate("riderinfobox",23), translate("riderinfobox",24))
end
if victories[1].content then
tab:node(addATitle(translate("riderinfobox",38)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
:wikitext(victories[1].content)
end
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), entityID,commons_cat)
return tab
end
function p.testlocal(frame) --function to test local functions
local function_name=frame.args[1]
local argu=frame.args
local temp, temp2
if function_name=='firstValue' then
return firstValue(argu[2],argu[3],argu[4])
elseif function_name=='getOfficialName' then
return getOfficialName(argu[2],argu[3],argu[4])
elseif function_name=='getRiderLink' then
temp=getRiderLink(argu[2],argu[3]) --only first arg returned
return temp
elseif function_name=='funcDate' then
return funcDate(argu[2],argu[3])
elseif function_name=='getTeam' then
temp=getTeam(argu[2],argu[3],argu[4])
if temp then return temp else return 'nil' end
elseif function_name=='getStatementForTime' then
temp=getStatementForTime(argu[2],argu[3],argu[4])
if temp then
return temp.mainsnak.datavalue.value.id
else
return 'nil'
end
elseif function_name=='getTeamLinkCat' then
temp=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4]),toboolean(argu[5]))
if temp then return temp else return 'nil' end
elseif function_name=='seasonToTeamID' then
if argu[2]=="nil" then arg2=nil else arg2=argu[2] end
return tostring(seasonToTeamID(arg2))
elseif function_name=='translate' then
return translate(argu[2],tonumber(argu[3]))
elseif function_name=="classLinkFn" then
return classLinkFn(argu[2])
elseif function_name=='raceLink' then
return tostring(raceLink(argu[2]))
elseif function_name=='getMainRaceLink' then
if argu[5]=="nil" then arg5=nil else arg5=argu[5] end
return tostring(getMainRaceLink(argu[2],argu[3],argu[4], arg5,argu[6]))
elseif function_name=='fn_getClassInfo1' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[1]
elseif function_name=='fn_getClassInfo2' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[2]
elseif function_name=='fn_getClassInfo4' then
local temp= fn_getClassInfo(argu[2],argu[3],nil)
return temp[4]
elseif function_name=='getYear' then
return getYear(argu[2])
elseif function_name=='getCountryName' then
return tostring(getCountryName(argu[2]))
elseif function_name=='getTeamCodeCat' then
return tostring(getTeamCodeCat(argu[2],argu[3]))
elseif function_name=='getTeamCode' then
return tostring(getTeamCode(argu[2],argu[3],argu[4]))
elseif function_name=='getCountryBool' then
return tostring(getCountryBool({argu[2],argu[3]}))
elseif function_name=='WPlinkpure' then
return WPlinkpure(argu[2])
elseif function_name=='uciCodeCountry' then
return uciCodeCountry(argu[2])
elseif function_name=='isHuman' then
return tostring(isHuman(argu[2]))
elseif function_name=='isCountry' then
return tostring(isCountry(argu[2]))
elseif function_name=='commaStage' then
temp =commaStage(argu[2],argu[3])
return temp[1]
elseif function_name=='number' then
return number(argu[2],tonumber(argu[3]), argu[4])
elseif function_name=='classToCircuit1' then
temp, temp2= classToCircuit(argu[2], argu[3], argu[4], toboolean(argu[5]), nil)
return temp
elseif function_name=='classToCircuit2' then
temp, temp2= classToCircuit(argu[2], argu[3], argu[4], toboolean(argu[5]), nil)
return temp2
elseif function_name=='getGenderCode' then
return tostring(getGenderCode(argu[2], argu[3]))
elseif function_name=='calculateTime' then
return calculateTime(argu[2])
elseif function_name=='getClass1' then
temp, temp2 = getClass(argu[2])
return temp
elseif function_name=='getClass2' then
temp, temp2 = getClass(argu[2])
return temp2
elseif function_name=='infoGetPlace' then
local details = {{ name = "test", name_plural="tests"}} -- course / not used
infoGetPlace(details,1, argu[2], argu[3], argu[4])
return details[1].content
elseif function_name=='getFormerNames1' then
temp=getFormerNames(argu[2],'P1448')
if temp[1] then
return temp[1][2] --period
else
return ""
end
elseif function_name=='getFormerNames2' then
temp=getFormerNames(argu[2],'P1448')
if temp[1] then
return temp[1][3] --name
else
return ""
end
elseif function_name=='getType' then
return getType(argu[2])
elseif function_name=='compareDate' then
return tostring(compareDate(argu[2]))
elseif function_name=='officialSite' then
return officialSite(argu[2])
elseif function_name=='trans' then
return tostring(trans(argu[2], argu[3], argu[4]))
elseif function_name=='parseDate1' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp1
elseif function_name=='parseDate2' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp2
elseif function_name=='parseDate5' then
temp1, temp2, temp3, temp4, temp5= parseDate(argu[2], argu[3], argu[4], argu[5], "", "error text")
return temp5
elseif function_name=='findLastName' then
return findLastName(argu[2],wiki)
elseif function_name=='findSortKey' then
if wiki=="ru" or wiki=="mk" then
return findSortKey(argu[2],false, true)
else
return findSortKey(argu[2],true, false)
end
elseif function_name=='calculateAge' then
temp1, _, _ =calculateAge(argu[2])
return temp1
elseif function_name=='getBirthDeathDate1' then
temp1, temp2 = getBirthDeathDate(argu[2])
return temp1
elseif function_name=='getBirthDeathDate2' then
temp1, temp2 = getBirthDeathDate(argu[2])
return temp2
elseif function_name=='getLocalContent' then
local details = {
{ name = argu[2], name_plural= argu[3]}
}
local arguments = {}
arguments[argu[4]]="test"
getLocalContent(details, arguments)
return details[1].content
elseif function_name=='plural1' then
_, temp1, temp2=plural(tonumber(argu[2]))
return temp1
elseif function_name=='plural2' then
_, temp1, temp2=plural(tonumber(argu[2]))
return temp2
end
end
function p.test_import(frame)
local function_name=frame.args[1]
local argu=frame.args
if function_name=='class' then
return tostring(class[tonumber(argu[2])])
elseif function_name=='class_2x' then
return tostring(class_2x[tonumber(argu[2])])
elseif function_name=='class_without2x' then
return tostring(class_without2x[tonumber(argu[2])])
elseif function_name=="class_sort" then
return tostring(class_sort[argu[2]])
elseif function_name=='classes' then
return tostring(classes[argu[2]])
elseif function_name=='stages' then
return tostring(stages[tonumber(argu[2])])
elseif function_name=='bg_color_table' then
local temp = bg_color_table[argu[2]]
temp=string.gsub(temp,'#',"")
return temp
end
end
return p
|