Module:Auteu
Documentation for this module may be created at Module:Auteu/doc
local p = {}
local lang = "pcd"
local img = "Gray - replace this image male.svg"
local NS = mw.title.getCurrentTitle().namespace
local CatNS = mw.site.namespaces.Category.name
function p.main(frame)
if frame.args.wd == nil or frame.args.wd == "" then return end
-- data from Wikidata
local item = mw.wikibase.getEntity(frame.args.wd)
local html = mw.html.create()
if NS == 108 then
html:wikitext('[['..CatNS..':Picard]]')
html:wikitext('[['..CatNS..':Authors]]')
if frame.args.index ~= nil and frame.args.index ~= "" then
local I = string.upper(frame.args.index)
div_index = mw.html.create( 'div' )
div_index:wikitext('[[Wikisource:Authors-'..I..'|Author Index: '..I..']]')
html:wikitext('[['..CatNS..':Authors-'..I..']]')
end
end
div_author = mw.html.create( 'div' )
div_author:css({
["margin-bottom"] = "1em",
["border"] = "1px solid #BEA2A2",
["background"] = "#E4D8D8",
["overflow"] = "auto",
["padding"] = "10px"
})
div_author_text = mw.html.create( 'div' )
div_author_text:css({
["margin-left"] = "200px"
})
div_iw = mw.html.create( 'div' )
div_iw:css({
["float"] = "right"
})
-- index
if div_index ~= nil then div_iw:node( div_index ) end
-- Wikidata
if item.id~= nil then
div_iw:wikitext( '<div>[[:d:'..item.id..'|Wikidata]]</div>' )
end
-- Wikipedia
local iwd = item:getSitelink( lang..'wiki' )
if iwd ~= nil then
div_iw:wikitext( '<div>[[:w:'..lang..':'..iwd..'|Wikipédia]]</div>' )
end
-- Commons
local iwc = item:formatPropertyValues('P373').value
if iwc ~= nil and iwc ~= '' then
div_iw:wikitext( '<div>[[:c:Category:'..iwc..'|Commons]]</div>' )
end
div_author:node( div_iw )
local imgWD = item:getBestStatements('P18')
if imgWD[1] ~= nil and imgWD[1].mainsnak.datavalue ~= nil then
img = imgWD[1].mainsnak.datavalue.value
end
div_author:wikitext( '[[File:'..img..'|left|128px]]' )
local fullnameWD = item:getLabel(lang)
if fullnameWD == nil then fullnameWD = "?" end
div_author_name = mw.html.create( 'div' )
div_author_fname = mw.html.create( 'span' )
div_author_fname:css({
["font-weight"] = "bold",
["font-family"] = "sherif",
["font-size"] = "200%"
})
div_author_fname:wikitext(fullnameWD)
div_author_name:node( div_author_fname )
local akaWD = item:getBestStatements('P742')
local i = 1
local akas = {}
while( akaWD[i] ~= nil and akaWD[i].mainsnak.datavalue ~= nil ) do
table.insert(akas, akaWD[i].mainsnak.datavalue.value)
if i == 3 then break end
i = i + 1
end
if #akas > 0 then
div_author_name:wikitext(' (<abbr title="no d’ pene">n.p.</abbr> ' .. table.concat(akas, ', ') ..')')
end
table.remove(akas)
div_author_text:node( div_author_name )
local birthWD = item:getBestStatements('P569')
local deathWD = item:getBestStatements('P570')
if birthWD == nil or birthWD[1] == nil then birthWD = "?" else birthWD = string.sub(birthWD[1].mainsnak.datavalue.value.time, 2, 5) end
if deathWD == nil or deathWD[1] == nil then deathWD = "?" else deathWD = string.sub(deathWD[1].mainsnak.datavalue.value.time, 2, 5) end
div_author_dates = mw.html.create( 'div' )
div_author_dates:wikitext(birthWD.." — "..deathWD)
div_author_text:node( div_author_dates )
local descWD = item:getDescription( lang )
if descWD == nil then descWD = "''i nn’o poin coére éd donnèes in picard édseur Wikidata''" end
div_author_des = mw.html.create( 'div' )
div_author_des:wikitext(descWD)
div_author_text:node( div_author_des )
div_author:node( div_author_text )
html:node( div_author )
return html
end
return p