« Module:Auteur2 » : différence entre les versions

Contenu supprimé Contenu ajouté
ajout de la récupération du logo et des dates de créations/dissolutions pour les institutions
simplifie le code
Ligne 219 :
end
 
function formatDates(naissance, deces, naissanceProp, decesPropclass)
if naissance.text == nil and deces.text == nil then
return ''
Ligne 226 :
local text = '('
if naissance.precision >= 9 then
textlocal = text .. '<timeannotation datetime=' .. naissance.year .. ' class="bday" itemprop="' .. naissanceProp .. 'birthDate">' .. naissance.text .. '</time> '
if next(naissanceWikidata)class ~= "Q5" and class ~= nil then
naissancePropannotation = 'itemprop="foundingDate'
end
text = text .. '<time datetime="' .. naissance.year .. '" ' .. annotation .. '>' .. naissance.text .. '</time> '
elseif naissance.text ~= nil then
text = text .. naissance.text .. ' '
Ligne 232 ⟶ 236 :
text = text .. '–'
if deces.precision >= 9 then
textlocal = text .. ' <timeannotation datetime=' .. deces.year .. ' class="dday" itemprop="' .. decesProp .. 'deathDate">' .. deces.text .. '</time>'
if next(naissanceWikidata)class ~= "Q5" and class ~= nil then
decesPropannotation = 'itemprop="dissolutionDate'
end
text = text .. ' <time datetime="' .. deces.year .. '" ' .. annotation .. '>' .. deces.text .. '</time>'
elseif deces.text ~= nil then
text = text .. ' ' .. deces.text
Ligne 265 ⟶ 273 :
 
local naissance = getDateFromArgs(args, 'naissance', 'Naissance')
local naissanceProp = 'birthDate'
local deces = getDateFromArgs(args, 'deces', 'Deces')
local decesProp = 'deathDate'
local schemaType = 'http://schema.org/Person'
local sexe = nil
local class = nil
Ligne 305 ⟶ 310 :
if next(naissanceWikidata) == nil then -- on utilise la date de création
naissanceWikidata = getDateFromTimeStatements(item:getBestStatements('P571'), 'création')
if next(naissanceWikidata) ~= nil then
naissanceProp = 'foundingDate'
schemaType = 'http://schema.org/Organization'
end
end
if naissance.text == nil then
Ligne 321 ⟶ 322 :
if next(decesWikidata) == nil then -- on utilise la date de dissolution
decesWikidata = getDateFromTimeStatements(item:getBestStatements('P576'), 'dissolution')
if next(naissanceWikidata) ~= nil then
decesProp = 'dissolutionDate'
schemaType = 'http://schema.org/Organization'
end
end
if deces.text == nil then
Ligne 405 ⟶ 402 :
 
local main = html:tag('div')
:addClass('vcard')
:attr('itemscope', '')
:attr('itemtype', schemaType)
:css({['background-color'] = '#F1F1DE', ['overflow'] = 'auto', ['border-radius'] = '0.7em', ['box-shadow'] = '0.2em 0.3em 0.2em #B7B7B7'})
 
if class == "Q5" or class == nil then
main = main:attr('itemtype', 'http://schema.org/Person'):addClass('vcard')
else
schemaTypemain = main:attr('itemtype', 'http://schema.org/Organization')
end
if item ~= nil and item.id ~= nil then
main:attr('itemid', 'http://www.wikidata.org/entity/' .. item.id)
Ligne 505 ⟶ 506 :
fullDescription
:newline()
:wikitext(formatDates(naissance, deces, naissanceProp, decesPropclass))
if args.pseudo ~= nil and args.pseudo ~= '-' then
fullDescription:tag('br')