Nie podano opisu zmian |
Nie podano opisu zmian |
||
Linia 68: | Linia 68: | ||
: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]]'), 'Powiązane')) |
:node(p._data(p._concat(card.powiazane, '[[$1]]'), 'Powiązane')) |
||
− | :node(p._data(card.artysta and '[['..card.artysta..']]' or |
+ | :node(p._data(card.artysta and '[['..card.artysta..']]' or 'Nieznany', 'Artysta')) |
:done() |
:done() |
||
:done() |
:done() |
||
Linia 88: | Linia 88: | ||
local markup = tostring(infobox) |
local markup = tostring(infobox) |
||
+ | |||
+ | if mw.title.getCurrentTitle().isContentPage then |
||
+ | markup = markup..p._categorize(card) |
||
+ | markup = markup..'[[en:'..card.interlang..']]' |
||
+ | end |
||
return mw.getCurrentFrame():preprocess(markup) |
return mw.getCurrentFrame():preprocess(markup) |
||
Linia 121: | Linia 126: | ||
for i = 1, string.len(number) do |
for i = 1, string.len(number) do |
||
out = out..'[[File:Infobox '..string.sub(number, i, i)..'.png|x32px|link=]]' |
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 |
end |
||
return out |
return out |
Wersja z 16:16, 16 lut 2019
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Karta/opis
local getArgs = require('Dev:Arguments').getArgs
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 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(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]]'), 'Powiązane'))
:node(p._data(card.artysta and '[['..card.artysta..']]' 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..']]'
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)
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 .. ', ' 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
return p