Modul:Szerző
Megjelenés
A modult a Modul:Szerző/doc lapon tudod dokumentálni
local p = {}
local getArgs = require('Modul:Arguments').getArgs
local projects = {
wp = { logo = 'Wikipedia-logo-v2.svg', text = "Szócikk a '''[[w:%s|Wikipédiában]]'''" },
commons = { logo = 'Commons-logo.svg', text = "Médiaállományok a '''[[commons:%s|Wikimédia Commonsban]]'''" },
ws = { logo = 'Wikisource-logo.svg', text = "Művek a '''[[s:%s|Wikiforrásban]]'''" },
gutenberg = { logo = 'Gutenberg ico.png', text = "Művek a [//www.gutenberg.org/ebooks/author/%s Project Gutenbergben]" },
dominiopu = { logo = 'Dpb.png', text = "Művek a [http://www.dominiopublico.gov.br/pesquisa/PesquisaObraForm.do?select_action=&co_autor=%s Domínio Públicón]" },
domipubli = { logo = 'Dpe.png', text = "Művek a [http://www.dominiopublico.nom.es/autor.php?r=r&id=%s Dominio Públicón]" },
cervantes = { logo = nil, text = "Művek a [http://www.cervantesvirtual.com/FichaAutor.html?Ref=%s Cervantes Virtualon]" },
ebooksg = { logo = nil, text = "Művek az [http://www.ebooksgratuits.com/ebooks.php?id_categorie=1&id_genre=1&id_auteur=%s eBooks Gratuitson]" },
}
local function wikibase(id, overwrite)
if overwrite then
return overwrite ~= '-' and overwrite or nil
end
local entity = mw.wikibase.getEntity()
if not entity then
return nil
end
local statements = entity:getBestStatements( id:upper() )
for _, v in pairs(statements) do
local snak = v.mainsnak
if snak.snaktype == 'value' then
local datavalue = snak.datavalue
if datavalue.type == 'string' then
return datavalue.value
end
end
end
return nil
end
local function sitelink(id, overwrite)
if overwrite then
return overwrite ~= '-' and overwrite or nil
end
return mw.wikibase.getEntity() and mw.wikibase.getEntity():getSitelink(id)
end
local function field(text, style, header)
local row = mw.html.create('tr')
local cell = mw.html.create( (header and 'th') or 'td' )
if (style) then
cell:css(style)
end
cell:wikitext(text)
row:node(cell)
return row
end
local function seealsoLink(id, article)
local project = projects[id]
if not project then
return nil
end
local logo, text = project.logo, project.text
if logo then
logo = '[[Fájl:' .. logo .. '|20px]] '
else
logo = ''
end
text = mw.ustring.format(text, article)
return field(logo .. text)
end
function p.main(frame)
local args = getArgs(frame)
local title = args['Nome'] or args['név'] or args['Név'] or mw.title.getCurrentTitle().text
local colorcss = { ['background-color'] = args['Cor'] or args['szín'] or args['Szín'] or nil }
local htmltable = mw.html.create('table')
htmltable
:addClass('infobox toccolours')
:attr('cellpadding', 3)
:attr('cellspacing', 0)
:css{
float = 'right',
margin = '5px',
border = '3px solid #efefef',
width = '260px'
}
htmltable:node( field(title, colorcss, true) )
local image = wikibase( 'P18', args['kép'] or args['Kép'] )
if image then
local desc = args['képaláírás'] or args['Képaláírás']
image = '[[Fájl:' .. image .. '|' .. (args['képméret'] or args['Képméret'] or '250px') .. (desc and '|' .. desc or '') .. ']]'
if desc then
desc = '<div style="font-size:smaller;">' .. desc .. '</div>'
image = image .. desc
end
htmltable:node( field(image, { ['text-align'] = 'center' } ) )
end
local links = {
wp = sitelink('huwiki', args['wikipédia'] or args['Wikipédia']),
commons = args['wikicommons'] or args['Wikicommons'],
ws = sitelink('huwikisource', args['wikidézet'] or args['Wikidézet']),
gutenberg = wikibase( 'P1938', args['gutenberg'] or args['Gutenberg']),
dominiopu = args['DominioPu'],
domipubli = args['DomuPubli'],
cervantes = wikibase( 'P2799', args['cervantes'] or args['Cervantes']),
ebooksg = args['ebooksg'] or args['EbooksG']
}
local seealso = {}
for n, v in pairs(links) do
if v then
local link = seealsoLink(n, v)
table.insert( seealso, link )
end
end
if #seealso > 0 then
htmltable:node( field('Lásd még', colorcss, true) )
for _, v in pairs(seealso) do
htmltable:node(v)
end
end
return htmltable:done()
end
return p