„Modul:Infobox” változatai közötti eltérés
Megjelenés
Nincs szerkesztési összefoglaló |
Nincs szerkesztési összefoglaló |
||
| (Egy közbenső módosítás ugyanattól a felhasználótól nincs mutatva) | |||
| 13. sor: | 13. sor: | ||
local name = (args['név'] ~= '' and args['név']) or "Nincs név" | local name = (args['név'] ~= '' and args['név']) or "Nincs név" | ||
local image = (args['kép'] ~= '' and args['kép']) or nil | local image = (args['kép'] ~= '' and args['kép']) or nil | ||
local image2 = (args['kép2'] ~= '' and args['kép2']) or nil | |||
local date = (args['dátum'] ~= '' and args['dátum']) or "Nincs dátum" | local date = (args['dátum'] ~= '' and args['dátum']) or "Nincs dátum" | ||
local nationality = (args['állampolgárság'] ~= '' and args['állampolgárság']) or "ismeretlen" | local nationality = (args['állampolgárság'] ~= '' and args['állampolgárság']) or "ismeretlen" | ||
| 22. sor: | 23. sor: | ||
-- TÁBLÁZAT GENERÁLÁSA | -- TÁBLÁZAT GENERÁLÁSA | ||
output = output .. '{| class="infobox biota ember"\n' | output = output .. '{| class="infobox biota ember"\n' | ||
output = output .. '|-\n ! colspan="2" | ' .. name .. '\n' | output = output .. '|-\n' | ||
output = output .. '|-\n ! colspan="2" | ' .. date .. '\n' | output = output .. '! colspan="2" | ' .. name .. '\n' | ||
output = output .. '|-\n' | |||
output = output .. '! colspan="2" | ' .. date .. '\n' | |||
if image then | if image then | ||
output = output .. '|-\n ! colspan="2"|[[Fájl:' .. image .. '|340px]]\n' | output = output .. '|-\n' | ||
output = output .. '! colspan="2"|[[Fájl:' .. image .. '|340px]]\n' | |||
end | end | ||
output = output .. '|-\n | class="left" | állampolgárság || class="right" | ' .. nationality .. '\n' | if image2 then | ||
output = output .. '|-\n | class="left" | foglalkozás || class="right" | ' .. profession .. '\n' | output = output .. '|-\n' | ||
output = output .. '|-\n | class="left" | rövidítés || class="right" | ' .. abbreviation .. '\n' | output = output .. '! colspan="2" style="text-align:center; width:340px;"|' .. image2 .. '\n' | ||
end | |||
output = output .. '|-\n' | |||
output = output .. '| class="left" | állampolgárság || class="right" | ' .. nationality .. '\n' | |||
output = output .. '|-\n' | |||
output = output .. '| class="left" | foglalkozás || class="right" | ' .. profession .. '\n' | |||
if abbreviation ~= "" then -- nem egyyenlő | |||
output = output .. '|-\n' | |||
output = output .. '| class="left" | rövidítés || class="right" | ' .. abbreviation .. '\n' | |||
end | |||
output = output .. '|}\n' | output = output .. '|}\n' | ||
A lap jelenlegi, 2026. május 21., 18:24-kori változata
A modult a Modul:Infobox/doc lapon tudod dokumentálni
-- ==========================================================
-- Modul:Infobox.lua
-- ==========================================================
local p = {} -- EZ HIÁNYZOTT: Létrehozzuk a csomag tábláját
function p.buildInfobox(frame)
-- Ha nincs frame (pl. parancssorból futtatva rosszul), ne szálljon el
local args = (frame.getParent and frame:getParent().args) or frame.args
-- Változónevek ékezet nélkül (biztonságosabb offline futtatáshoz)
-- De a kulcsok (pl. args['név']) maradhatnak ékezetesek, mert azok stringek
local name = (args['név'] ~= '' and args['név']) or "Nincs név"
local image = (args['kép'] ~= '' and args['kép']) or nil
local image2 = (args['kép2'] ~= '' and args['kép2']) or nil
local date = (args['dátum'] ~= '' and args['dátum']) or "Nincs dátum"
local nationality = (args['állampolgárság'] ~= '' and args['állampolgárság']) or "ismeretlen"
local profession = (args['foglalkozás'] ~= '' and args['foglalkozás']) or "ismeretlen"
local abbreviation = (args['rövidítés'] ~= '' and args['rövidítés']) or ""
local output = ""
-- TÁBLÁZAT GENERÁLÁSA
output = output .. '{| class="infobox biota ember"\n'
output = output .. '|-\n'
output = output .. '! colspan="2" | ' .. name .. '\n'
output = output .. '|-\n'
output = output .. '! colspan="2" | ' .. date .. '\n'
if image then
output = output .. '|-\n'
output = output .. '! colspan="2"|[[Fájl:' .. image .. '|340px]]\n'
end
if image2 then
output = output .. '|-\n'
output = output .. '! colspan="2" style="text-align:center; width:340px;"|' .. image2 .. '\n'
end
output = output .. '|-\n'
output = output .. '| class="left" | állampolgárság || class="right" | ' .. nationality .. '\n'
output = output .. '|-\n'
output = output .. '| class="left" | foglalkozás || class="right" | ' .. profession .. '\n'
if abbreviation ~= "" then -- nem egyyenlő
output = output .. '|-\n'
output = output .. '| class="left" | rövidítés || class="right" | ' .. abbreviation .. '\n'
end
output = output .. '|}\n'
return output
end
-- ==========================================================
-- OFFLINE TESZTELŐ SZAKASZ
-- ==========================================================
if arg then
-- MW szimuláció
mw = { uri = { encode = function(s) return s:gsub(" ", "%%20") end } }
local mock_frame = {
getParent = function()
return {
args = {
['név'] = "Karl Moritz Schumann",
['kép'] = "Karl Moritz Schumann.jpg",
['dátum'] = "1851 - 1904",
['állampolgárság'] = "német",
['foglalkozás'] = "botanikus",
['rövidítés'] = "K.Schum."
}
}
end
}
print("\n--- INFOBOX GENERÁLT WIKITEXT ---")
local success, result = pcall(p.buildInfobox, mock_frame)
if success then
print(result)
else
print("HIBA: " .. result)
end
end
return p -- EZ IS FONTOS: Visszaadjuk a táblát a MediaWiki számára