Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Karta/opis
local p = {}
local data = mw.loadData('Module:Karty')
function p.main(frame)
local title = frame.args[1] or mw.title.getCurrentTitle().text
local card = data[title]
if not card then
return 'Nie znaleziono karty "'..title..'".'
end
local image = p._encode(title..'.png')
local art = p._encode(title..'_Art.jpg')
local premium = p._encode(title..'_Premium.gif')
local infobox = mw.html.create('infobox'):attr('type', 'card')
infobox
:tag('title')
:tag('default'):wikitext(title):done()
:done()
:tag('group'):attr('name', 'content')
:tag('group'):attr('name', 'image')
:tag('panel')
:tag('section')
:tag('label'):wikitext('Karta'):done()
:tag('image')
:tag('default'):wikitext(image):done()
:done()
:done()
:tag('section')
:tag('label'):wikitext('Obraz'):done()
:tag('image'):attr('name', 'art')
:tag('default'):wikitext(art):done()
:done()
:done()
:tag('section')
:tag('label'):wikitext('Premium'):done()
:tag('image'):attr('name', 'premium')
:tag('default'):wikitext(premium):done()
:done()
:done()
:done()
:done()
:tag('group')
:attr('name', 'data')
:tag('panel')
:tag('section')
:tag('label'):wikitext('Informacje'):done()
:tag('group')
:tag('group'):attr('row-items', '3')
:node(p._data('[[File:'..card.frakcja..'.png|x48px|link='..card.frakcja..']]', 'Frakcja'))
:node(p._data('[[File:Infobox_'..card.sila..'.png|x32px|link=]]', 'Siła'))
:node(p._data('[[File:Infobox_'..card.werbunek..'.png|x32px|link=]]', 'Werbunek'))
:done()
:node(p._data(card.kolor, 'Kolor'))
:node(p._data(card.rzadkosc, 'Rzadkość'))
:node(p._data(card.rodzaj, 'Rodzaj'))
:node(p._data(card.zestaw, 'Zestaw Kart'))
:node(p._data(p._concat(card.kategorie), 'Kategorie'))
:node(p._data(p._concat(card.powiazane), 'Powiązane'))
:node(p._data(card.artysta, 'Artysta'))
:done()
:done()
:done()
:done()
:done()
:tag('group'):attr('name', 'footer')
:tag('panel')
:tag('section')
:tag('label'):wikitext('Umiejętność'):done()
:node(p._data(card.umiejetnosc))
:done()
:tag('section')
:tag('label'):wikitext('Cytat'):done()
:node(p._data(card.cytat, nil, 'quote'))
:done()
:done()
:done()
local markup = tostring(infobox)
return mw.getCurrentFrame():preprocess(markup)
end
function p._data(content, label, name)
local d = mw.html.create('data')
if name then d:attr('name', name) end
if label then d:tag('label'):wikitext(label) end
if content then d:tag('default'):wikitext(content) end
return d
end
function p._encode(file)
return file:gsub(':', ''):gsub(' ', '_')
end
function p._concat(t)
local out = ''
for i, v in ipairs(t) do
out = out .. v
if t[i + 1] then out = out .. ', ' end
end
return out
end
return p