Przejdź do zawartości

Moduł:Osoba: Różnice pomiędzy wersjami

Z Encyklopedia Poznanskiego Sportu
Nie podano opisu zmian
Nie podano opisu zmian
Linia 12: Linia 12:
end
end


-- zamiana * na <ul><li>
-- lista z *
local function makeList(text)
local function makeList(text)
if notEmpty(text) and string.find(text, "%*") then
if notEmpty(text) and string.find(text, "%*") then
Linia 21: Linia 21:
end
end
return "<ul>" .. table.concat(items) .. "</ul>"
return "<ul>" .. table.concat(items) .. "</ul>"
end
return text
end
-- medale
local function addMedals(text)
if notEmpty(text) then
text = string.gsub(text, "{złoto}", "[[Plik:Gold medal icon.png|16px]]")
text = string.gsub(text, "{srebro}", "[[Plik:Silver medal icon.png|16px]]")
text = string.gsub(text, "{brąz}", "[[Plik:Bronze medal icon.png|16px]]")
end
end
return text
return text
Linia 32: Linia 42:
end
end


local function section(title, content)
local function section(title, content, medals)
if notEmpty(content) then
if notEmpty(content) then
content = makeList(content)
content = makeList(content)
if medals then
content = addMedals(content)
end
return "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | " .. title .. "\n" ..
return "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | " .. title .. "\n" ..
"|-\n| colspan='2' | " .. content .. "\n"
"|-\n| colspan='2' | " .. content .. "\n"
Linia 46: Linia 59:
local txt = "{| class='infobox' style='float:right; width:270px; border:1px solid #a2a9b1; background:#f8f9fa;'\n"
local txt = "{| class='infobox' style='float:right; width:270px; border:1px solid #a2a9b1; background:#f8f9fa;'\n"


txt = txt .. "|+ style='background:#3366cc; color:white; text-align:center;' | '''" ..
-- nagłówek z ikoną
    (a.imie or "") .. " " .. (a.nazwisko or "") .. "'''\n"
local header = ""
if notEmpty(a.dyscyplina_ikona) then
    header = "[[Plik:" .. a.dyscyplina_ikona .. "|20px]] "
end
 
txt = txt .. "|+ style='background:#3366cc; color:white; text-align:center;' | " ..
    header .. "'''" .. (a.imie or "") .. " " .. (a.nazwisko or "") .. "'''\n"


-- zdjęcie + podpis
if notEmpty(a.zdjecie) then
if notEmpty(a.zdjecie) then
     txt = txt .. "|-\n| colspan='2' style='text-align:center;' | [[Plik:" .. a.zdjecie .. "|250px]]\n"
     txt = txt .. "|-\n| colspan='2' style='text-align:center;' | [[Plik:" .. a.zdjecie .. "|250px]]"
    if notEmpty(a.podpis_zdjecia) then
        txt = txt .. "<br><small>" .. a.podpis_zdjecia .. "</small>"
    end
    txt = txt .. "\n"
end
 
-- obywatelstwo + flaga
local obywatelstwo = a.obywatelstwo or ""
if notEmpty(a.flaga) then
    obywatelstwo = "[[Plik:" .. a.flaga .. "|20px]] " .. obywatelstwo
end
end


Linia 58: Linia 88:
dane = dane .. row("Data śmierci", formatDate(frame, a.data_smierci))
dane = dane .. row("Data śmierci", formatDate(frame, a.data_smierci))
dane = dane .. row("Miejsce śmierci", a.miejsce_smierci)
dane = dane .. row("Miejsce śmierci", a.miejsce_smierci)
dane = dane .. row("Obywatelstwo", a.obywatelstwo)
dane = dane .. row("Obywatelstwo", obywatelstwo)
dane = dane .. row("Wzrost", a.wzrost)
dane = dane .. row("Wzrost", a.wzrost)
dane = dane .. row("Pozycja", a.pozycja)
dane = dane .. row("Pozycja", a.pozycja)
Linia 80: Linia 110:
txt = txt .. section("Kariera reprezentacyjna", a.kariera_reprezentacyjna)
txt = txt .. section("Kariera reprezentacyjna", a.kariera_reprezentacyjna)
txt = txt .. section("Kariera trenerska", a.kariera_trenerska)
txt = txt .. section("Kariera trenerska", a.kariera_trenerska)
txt = txt .. section("Osiągnięcia", a.osiagniecia)
txt = txt .. section("Osiągnięcia", a.osiagniecia, true)


txt = txt .. "|}"
txt = txt .. "|}"

Wersja z 04:27, 26 kwi 2026

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Osoba/opis

local p = {}

local function notEmpty(v)
return v ~= nil and v ~= ""
end

local function formatDate(frame, d)
if notEmpty(d) then
return frame:callParserFunction("#time", "j xg Y", d)
end
return ""
end

-- lista z *
local function makeList(text)
if notEmpty(text) and string.find(text, "%*") then
local items = {}
for line in string.gmatch(text, "[^\r\n]+") do
local item = string.gsub(line, "^%*%s*", "")
table.insert(items, "<li>" .. item .. "</li>")
end
return "<ul>" .. table.concat(items) .. "</ul>"
end
return text
end

-- medale
local function addMedals(text)
if notEmpty(text) then
text = string.gsub(text, "{złoto}", "[[Plik:Gold medal icon.png|16px]]")
text = string.gsub(text, "{srebro}", "[[Plik:Silver medal icon.png|16px]]")
text = string.gsub(text, "{brąz}", "[[Plik:Bronze medal icon.png|16px]]")
end
return text
end

local function row(label, value)
if notEmpty(value) then
return "|-\n! " .. label .. "\n| " .. value .. "\n"
end
return ""
end

local function section(title, content, medals)
if notEmpty(content) then
content = makeList(content)
if medals then
content = addMedals(content)
end
return "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | " .. title .. "\n" ..
"|-\n| colspan='2' | " .. content .. "\n"
end
return ""
end

function p.infobox(frame)
local a = frame:getParent().args

local txt = "{| class='infobox' style='float:right; width:270px; border:1px solid #a2a9b1; background:#f8f9fa;'\n"

-- nagłówek z ikoną
local header = ""
if notEmpty(a.dyscyplina_ikona) then
    header = "[[Plik:" .. a.dyscyplina_ikona .. "|20px]] "
end

txt = txt .. "|+ style='background:#3366cc; color:white; text-align:center;' | " ..
    header .. "'''" .. (a.imie or "") .. " " .. (a.nazwisko or "") .. "'''\n"

-- zdjęcie + podpis
if notEmpty(a.zdjecie) then
    txt = txt .. "|-\n| colspan='2' style='text-align:center;' | [[Plik:" .. a.zdjecie .. "|250px]]"
    if notEmpty(a.podpis_zdjecia) then
        txt = txt .. "<br><small>" .. a.podpis_zdjecia .. "</small>"
    end
    txt = txt .. "\n"
end

-- obywatelstwo + flaga
local obywatelstwo = a.obywatelstwo or ""
if notEmpty(a.flaga) then
    obywatelstwo = "[[Plik:" .. a.flaga .. "|20px]] " .. obywatelstwo
end

local dane = ""
dane = dane .. row("Data urodzenia", formatDate(frame, a.data_urodzenia))
dane = dane .. row("Miejsce urodzenia", a.miejsce_urodzenia)
dane = dane .. row("Data śmierci", formatDate(frame, a.data_smierci))
dane = dane .. row("Miejsce śmierci", a.miejsce_smierci)
dane = dane .. row("Obywatelstwo", obywatelstwo)
dane = dane .. row("Wzrost", a.wzrost)
dane = dane .. row("Pozycja", a.pozycja)

if dane ~= "" then
    txt = txt .. "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | Dane osobowe\n"
    txt = txt .. dane
end

local klub = ""
klub = klub .. row("Klub", a.klub)
klub = klub .. row("Numer", a.numer)

if klub ~= "" then
    txt = txt .. "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | Informacje klubowe\n"
    txt = txt .. klub
end

txt = txt .. section("Kariera juniorska", a.kariera_juniorska)
txt = txt .. section("Kariera klubowa", a.kariera_klubowa)
txt = txt .. section("Kariera reprezentacyjna", a.kariera_reprezentacyjna)
txt = txt .. section("Kariera trenerska", a.kariera_trenerska)
txt = txt .. section("Osiągnięcia", a.osiagniecia, true)

txt = txt .. "|}"

return txt

end

return p