Nie podano opisu zmian |
Nie podano opisu zmian |
||
Linia 79: | Linia 79: | ||
:node(p._data('[[:Kategoria:'..card.zestaw..'|'..card.zestaw..']]', 'Zestaw Kart')) |
:node(p._data('[[:Kategoria:'..card.zestaw..'|'..card.zestaw..']]', 'Zestaw Kart')) |
||
:node(p._data(p._concat(card.kategorie, '[[:Kategoria:$1|$1]]'), 'Kategorie')) |
:node(p._data(p._concat(card.kategorie, '[[:Kategoria:$1|$1]]'), 'Kategorie')) |
||
− | :node(p._data(p._concat(card.powiazane, '[[$1]] |
+ | :node(p._data(p._concat(card.powiazane, '[[$1]]', ', <br/>'), 'Powiązane')) |
:node(p._data(card.artysta and p._concat(u.split(card.artysta, ','), '[[$1]]') or 'Nieznany', 'Artysta')) |
:node(p._data(card.artysta and p._concat(u.split(card.artysta, ','), '[[$1]]') or 'Nieznany', 'Artysta')) |
||
:done() |
:done() |
Wersja z 09:50, 17 lut 2019
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Karta/opis
local getArgs = require('Dev:Arguments').getArgs
local u = require('Module:Utils')
local data = mw.loadData('Module:Karty')
local p = {}
function p.infobox(frame)
return p._infobox(getArgs(frame))
end
function p._infobox(args)
local title = args[1] or mw.title.getCurrentTitle().text
local i_title = u.trim(string.match(title, '^[^(]+'))
local p_title = title:gsub('%([^%)]+%)', '<small>%0</small>')
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(i_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()
:tag('section')
:tag('label'):wikitext('Dodaj'):done()
:tag('group'):attr('name', 'upload')
:node(p._data(p._t(mw.title.new('File:'..image).fileExists, nil, '<span class="plainlinks">[{{fullurl:Special:Upload|wpDestFile='..image..'&wpLicense=cdred&wpIgnoreWarning=1&wpGwentUploadAuto=1}} Prześlij obraz karty]</span>')))
:node(p._data(p._t(mw.title.new('File:'..art).fileExists, nil, '<span class="plainlinks">[{{fullurl:Special:Upload|wpDestFile='..art..'&wpLicense=cdred&wpIgnoreWarning=1&wpGwentUploadAuto=1}} Prześlij ilustrację karty]</span>')))
:node(p._data(p._t(mw.title.new('File:'..premium).fileExists, nil, '<span class="plainlinks">[{{fullurl:Special:Upload|wpDestFile='..premium..'&wpLicense=cdred&wpIgnoreWarning=1&wpGwentUploadAuto=1}} Prześlij obraz wersji premium]</span>')))
: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(p._imgNumbers(card.sila), 'Siła'))
:node(p._data(p._imgNumbers(card.werbunek), 'Werbunek'))
:done()
:node(p._data('[[:Kategoria:'..card.kolor..'|'..card.kolor..']]', 'Kolor'))
:node(p._data('[[:Kategoria:'..card.rzadkosc..'|'..card.rzadkosc..']]', 'Rzadkość'))
:node(p._data('[[:Kategoria:'..card.rodzaj..'|'..card.rodzaj..']]', 'Rodzaj'))
:node(p._data('[[:Kategoria:'..card.zestaw..'|'..card.zestaw..']]', 'Zestaw Kart'))
:node(p._data(p._concat(card.kategorie, '[[:Kategoria:$1|$1]]'), 'Kategorie'))
:node(p._data(p._concat(card.powiazane, '[[$1]]', ', <br/>'), 'Powiązane'))
:node(p._data(card.artysta and p._concat(u.split(card.artysta, ','), '[[$1]]') or 'Nieznany', '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)
if mw.title.getCurrentTitle().isContentPage then
markup = markup..p._categorize(card)
markup = markup..'[[en:'..card.interlang..']]'
if i_title ~= p_title and title == mw.title.getCurrentTitle().text then
markup = markup..'{{DISPLAYTITLE:'..p_title..'}}'
end
end
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, f, s)
local out = ''
for i, v in ipairs(t) do
if f then
out = out .. f:gsub('$1', v)
else
out = out .. v
end
if t[i + 1] then out = out .. (s or ', ') end
end
return out
end
function p._imgNumbers(number)
local out = ''
for i = 1, string.len(number) do
out = out..'[[File:Infobox '..string.sub(number, i, i)..'.png|x32px|link=]]'
end
return out
end
function p._categorize(card)
local out = '[[Kategoria:Karty]]'
out = out..'[[Kategoria:'..card.frakcja..']]'
out = out..'[[Kategoria:'..card.kolor..']]'
out = out..'[[Kategoria:'..card.rzadkosc..']]'
out = out..'[[Kategoria:'..card.rodzaj..']]'
out = out..'[[Kategoria:'..card.zestaw..']]'
for _, v in ipairs(card.kategorie) do
out = out..'[[Kategoria:'..v..']]'
end
return out
end
function p._t(s, t, f)
if s then return t else return f end
end
return p