Moduł:Osoba: Różnice pomiędzy wersjami
Wygląd
Utworzono nową stronę "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 local function row(label, value) if notEmpty(value) then return "|-\n! " .. label .. "\n| " .. value .. "\n" end return "" end local function section(title, content) if notEmpty(content) then return "|-\n! colspan='2' style='background:#eaecf0; text-align:center;'…" |
Nie podano opisu zmian |
||
| Linia 10: | Linia 10: | ||
end | end | ||
return "" | return "" | ||
end | |||
-- zamiana * na <ul><li> | |||
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 | end | ||
| Linia 21: | Linia 34: | ||
local function section(title, content) | local function section(title, content) | ||
if notEmpty(content) then | if notEmpty(content) then | ||
content = makeList(content) | |||
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" | ||
Wersja z 16:36, 25 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
-- zamiana * na <ul><li>
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
local function row(label, value)
if notEmpty(value) then
return "|-\n! " .. label .. "\n| " .. value .. "\n"
end
return ""
end
local function section(title, content)
if notEmpty(content) then
content = makeList(content)
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"
txt = txt .. "|+ style='background:#3366cc; color:white; text-align:center;' | '''" ..
(a.imie or "") .. " " .. (a.nazwisko or "") .. "'''\n"
if notEmpty(a.zdjecie) then
txt = txt .. "|-\n| colspan='2' style='text-align:center;' | [[Plik:" .. a.zdjecie .. "|250px]]\n"
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", a.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)
txt = txt .. "|}"
return txt
end
return p