Aller au contenu

« Module:Infobox/Biographie » : différence entre les versions

Une page de Wikipédia, l'encyclopédie libre.
Contenu supprimé Contenu ajouté
Prise en compte des chartes féminisées. Voir Discussion modèle:Infobox Biographie2#Féminisation des chartes
Balise : Révoqué
+date
 
(27 versions intermédiaires par 5 utilisateurs non affichées)
Ligne 4 : Ligne 4 :
local linguistic = require 'Module:Linguistique'
local linguistic = require 'Module:Linguistique'
local occupationformats = require 'Module:Infobox/Biographie/Chartes'
local occupationformats = require 'Module:Infobox/Biographie/Chartes'

local function setformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
local function setformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
local occupations = wd.getIds(localdata.item, {property = 'P106'}) -- récupère les Qid des professions
local occupations = wd.getIds(localdata.item, {property = 'P106'}) -- récupère les Qid des professions


if not occupations or (#occupations > 1) then -- si plusieurs occupations, on ne sait pas laquelle choisir
if not occupations or (#occupations > 1) then -- si plusieurs occupations, on ne sait pas laquelle choisir
return {'Q', '', '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
return {'Q', {'par défaut'}, '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
end
end
occupations = wd.addVals(occupations, {property = 'P279'}, 2) -- nombre d'étages de sous-classes à remonter
occupations = wd.addVals(occupations, {property = 'P279'}, 2) -- nombre d'étages de sous-classes à remonter
for i, j in pairs(occupations) do
for i, j in pairs(occupations) do
for k, l in pairs(occupationformats) do
for k, l in pairs(occupationformats) do
if l[1] == j then
local chartIds = l[1]
if type(chartIds) == 'string' then chartIds = {chartIds} end
return l --retourne une ligne de la table occupationformats, correspondant à l'une des occupations du sujet
if wd.isHere(chartIds,j) then
return l --retourne une ligne de la table occupationformats, correspondant à l'occupation du sujet
end
end
end
end
end
end
return {'Q', {''}, '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
return {'Q', {'par défaut'}, '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
end
end
local function setcharte()
local function setcharte()
Ligne 24 : Ligne 27 :
if charte then
if charte then
for i, j in pairs(occupationformats) do
for i, j in pairs(occupationformats) do
knownchartes = j[2]
local knowncharts = j[2]
if type(knowncharts) == 'table' then
for k,l in pairs(knownchartes) do
if l == charte then
if wd.isHere(knowncharts,charte) then
return j
return j
end
end
Ligne 35 : Ligne 38 :
end
end
local personformat = setcharte()
local personformat = setcharte()
local function formatreligion (entity) -- pour éviter d'afficher '-' quand le paramètre religion vaut 'no value'
if localdata["religion"] or wd.formatStatements{entity = entity, property = 'P140'} ~= '-' then
return person.religion()
end
end


local function documentation()
local function documentation()
Ligne 57 : Ligne 55 :
table.sort(occupationformats, function (left, right)
table.sort(occupationformats, function (left, right)
return string.lower(left[2][1] or ''):gsub('é','e') < string.lower(right[2][1] or ''):gsub('é','e')
local chartesleft = left[2]
local chartesright = right[2]
return string.lower(chartesleft[1] or ''):gsub('é','e') < string.lower(chartesright[1] or ''):gsub('é','e')
end)
end)


table.insert(occupationformats, 1, {nil, nil, nil, nil, nil, nil})
table.insert(occupationformats, 1, {nil, nil, nil, nil, nil, nil})


for i,j in pairs(occupationformats) do
for i, j in pairs(occupationformats) do
local wd = j[1] or ''
local wdsource = j[1] or {"Q"}
if type(wdsource) == 'string' then wdsource = {wdsource} end
local chartes = j[2] or {'par défaut'}
local charte = chartes[1] or ''
local wd = table.concat(wdsource, ", ")
local chartesource = j[2] or {"par défaut"}
--for k,l in pairs(chartes) do
-- if(k > 1) then charte = charte .. '<br>' end
if type(chartesource) == 'string' then chartesource = {chartesource} end
-- charte = charte .. l
local charte = table.concat(chartesource or {}, ", ")
--end tentative d'afficher aussi les alias
local couleur1 = j[3] or '#CCCCAA'
local couleur1 = j[3] or '#CCCCAA'
local couleur2 = j[4] or '#D1CFAD'
local couleur2 = j[4] or '#D1CFAD'
Ligne 97 : Ligne 92 :
return table.concat(lines, "\n" )
return table.concat(lines, "\n" )
end
end

--catégorisation par charte utilisée (qu'elle soit déclarée manuellement ou déduite de Wikidata)
local chartcatlabel = (personformat[2] or {})[1] or "par défaut"
chartcatlabel = "Article utilisant l'infobox Biographie2 avec la charte " .. chartcatlabel
local categories
if not mw.title.makeTitle('Catégorie', chartcatlabel ).exists then chartcatlabel = "Article utilisant l'infobox Biographie2 avec une charte sans catégorie" end


return {
return {
Ligne 102 : Ligne 103 :
secondcolor = personformat[4],
secondcolor = personformat[4],
thirdcolor = personformat[5],
thirdcolor = personformat[5],
categories = {chartcatlabel},
documentation = documentation,
documentation = documentation,
parts = {
parts = {
Ligne 108 : Ligne 110 :
person.mainimage(),
person.mainimage(),
person.officialposition(),
person.officialposition(),
person.specialrole(),
person.nobilitytitle(),
person.nobilitytitle(),
{type = 'table',title='Biographie',rows = {
{type = 'table',title='Biographie',rows = {
Ligne 114 : Ligne 117 :
person.placeofburial(),
person.placeofburial(),
person.othernames(),
person.othernames(),
{type = 'row', label = 'Époque', value = 'époque', property = 'P2348'},
{type = 'row', label = 'Époque', value = 'époque', wikidata = {property = 'P2348'}},
person.nationality(),
person.nationality(),
{type = 'row', label = 'Allégeance', plurallabel = 'Allégeances', value = 'allégeance', property = 'P945'},
{type = 'row', label = 'Allégeance', plurallabel = 'Allégeances', value = 'allégeance', wikidata = {property = 'P945'}},
person.places(),
person.places(),
person.education(),
person.education(),
Ligne 146 : Ligne 149 :
}},
}},
{type = 'table',title='Autres informations',rows = {
{type = 'table',title='Autres informations',rows = {
{type = 'row', label = 'Organisation', plurallabel = 'Organisations', value = 'organisation', property = 'P1268'},
{type = 'row', label = 'Événement clé', plurallabel = 'Événements clés', value = 'événement', wikidata = {property = 'P793' , expl = true , showdate = true}},
{type = 'row', label = 'Organisation', plurallabel = 'Organisations', value = 'organisation', wikidata = {property = 'P1268', showdate = true}},
person.employer(),
person.employer(),
{type = 'row', label = 'Chaire', plurallabel = 'Chaires', value = 'chaire', property = 'P803'},
{type = 'row', label = 'Chaire', plurallabel = 'Chaires', value = 'chaire', wikidata = {property = 'P803'}},
{type = 'row', label = 'Domaine', plurallabel = 'Domaines', value = 'domaine'}, --l'appel à P101 doublonne généralement l'Activité
{type = 'row', label = 'Domaine', plurallabel = 'Domaines', value = 'domaine'}, --l'appel à P101 doublonne généralement l'Activité
{type = 'row', label = 'Propriétaire de', value = 'propriétaire de', wikidata = {property = 'P1830', showdate = true, sorttype= 'chronological'}},
{type = 'row', label = 'Propriétaire de', value = 'propriétaire de', wikidata = {property = 'P1830', showdate = true, sorttype= 'chronological'}},
person.religion(),
formatreligion(localdata["wikidata"]),
person.politicalparty(),
person.politicalparty(),
{type = 'row', label = 'Idéologie', value = 'idéologie', wikidata = {property = 'P1142'}},
{type = 'row', label = 'Idéologie', value = 'idéologie', wikidata = {property = 'P1142'}},
Ligne 174 : Ligne 178 :
person.appearance(),
person.appearance(),
person.sport(),
person.sport(),
{type = 'row', label = 'Grade', plurallabel = 'Grades', value= 'grade', wikidata = {property = 'P468', numval = '1', sorttype = 'inverted', showdate = true, precision = 'year', removedupes = true}},
{type = 'row', label = 'Grade', plurallabel = 'Grades', value= {'grade dan/kyu','grade'}, wikidata = {property = 'P468', numval = '1', sorttype = 'inverted', showdate = true, precision = 'year', removedupes = true}},
--{type = 'row',label = 'Commandement',plurallabel = 'Commandements',wikidata = {property = 'P598', sorttype= 'chronological', showdate = true, precision = 'year'},}, --propriété obsolète sur Wikidata
--{type = 'row',label = 'Commandement',plurallabel = 'Commandements',wikidata = {property = 'P598', sorttype= 'chronological', showdate = true, precision = 'year'},}, --propriété obsolète sur Wikidata
--{type = 'row', label = 'A participé à', value = 'participant à', property = 'P1344'}, --risque de générer de longue listes sans grande pertinence
--{type = 'row', label = 'A participé à', value = 'participant à', property = 'P1344'}, --risque de générer de longue listes sans grande pertinence
Ligne 180 : Ligne 184 :
person.music(),
person.music(),
person.contacts(),
person.contacts(),
{type = 'row', label = 'Monture', plurallabel= 'Montures', value= 'monture', property = 'P3091'},
{type = 'row', label = 'Monture', plurallabel= 'Montures', value= 'monture', wikidata = {property = 'P3091', showdate = true}},
{type = 'row', label = 'Genre artistique', plurallabel= 'Genres artistiques', value= 'genre artistique', property = 'P136'},
{type = 'row', label = 'Genre artistique', plurallabel= 'Genres artistiques', value= {'genre artistique','genre'}, wikidata = {property = 'P136'}},
person.influencedby(),
person.influencedby(),
person.victims(),
person.victims(),
Ligne 191 : Ligne 195 :
person.filmography(),
person.filmography(),
person.discography(),
person.discography(),
{type = 'row', label = 'Abréviation en botanique', plurallabel = 'Abréviations en botanique', value = 'abréviation en botanique', wikidata={property = 'P428'}},
{type = 'row', label = 'Abréviation en zoologie', plurallabel = 'Abréviations en zoologie', value = 'abréviation en zoologie', wikidata={property = 'P835'}},
person.archivesat(),
person.archivesat(),
person.feast(),
person.feast(),

Dernière version du 26 avril 2024 à 16:28

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox. Elle utilise des fonctions définies sur Module:Infobox/Fonctions/Personne. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Biographie2.


local localdata = require 'Module:Infobox/Localdata'
local person = require 'Module:Infobox/Fonctions/Personne'
local wd = require 'Module:Wikidata'
local linguistic = require 'Module:Linguistique'
local occupationformats = require 'Module:Infobox/Biographie/Chartes'

local function setformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
	local occupations = wd.getIds(localdata.item, {property = 'P106'}) -- récupère les Qid des professions

	if not occupations or (#occupations > 1) then -- si plusieurs occupations, on ne sait pas laquelle choisir
		return  {'Q', {'par défaut'}, '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
	end
	occupations = wd.addVals(occupations, {property = 'P279'}, 2) -- nombre d'étages de sous-classes à remonter
	for i, j in pairs(occupations) do
		for k, l in pairs(occupationformats) do
			local chartIds = l[1]
			if type(chartIds) == 'string' then chartIds = {chartIds} end
			if wd.isHere(chartIds,j) then
				return l --retourne une ligne de la table occupationformats, correspondant à l'occupation du sujet
			end
		end
	end
	return {'Q', {'par défaut'}, '#EEEEFF', '#F6F6FF', '#000000', 'defaut'}
end
local function setcharte()
	local charte = localdata['charte']
	if charte then
		for i, j in pairs(occupationformats) do
			local knowncharts = j[2]
			if type(knowncharts) == 'table' then
				if wd.isHere(knowncharts,charte) then
					return j
				end
			end
		end
	end
	return setformat()
end
local personformat = setcharte()

local function documentation()

	local lines = {}

	table.insert(lines , '{| class="wikitable sortable" style="width:100%"')
	table.insert(lines , '|-')
	table.insert(lines , '! style="width:10%" | Charte')
	table.insert(lines , '! style="width:10%" | Élément Wikidata')
	table.insert(lines , '! style="width:10%" | Valeur primaire<br />(fond titre)')
	table.insert(lines , '! style="width:10%" | Valeur secondaire<br />(sous-titre)')
	table.insert(lines , '! style="width:10%" | Valeur tertiaire<br />(texte titre)')
	table.insert(lines , '! style="width:10%" | Icône<br />([[Projet:Infobox/Pictogramme|liste]])')
	table.insert(lines , '! style="width:20%" | rendu titre')
	table.insert(lines , '! style="width:20%" | rendu sous-titre')
	
	table.sort(occupationformats, function (left, right)
	    return string.lower(left[2][1] or ''):gsub('é','e') < string.lower(right[2][1] or ''):gsub('é','e')
	end)

	table.insert(occupationformats, 1, {nil, nil, nil, nil, nil, nil})

	for i, j in pairs(occupationformats) do
		local wdsource = j[1] or {"Q"}
		if type(wdsource) == 'string' then wdsource = {wdsource} end
		local wd = table.concat(wdsource, ", ")
		local chartesource = j[2] or {"par défaut"}
		if type(chartesource) == 'string' then chartesource = {chartesource} end
		local charte = table.concat(chartesource or {}, ", ")
		local couleur1 = j[3] or '#CCCCAA'
		local couleur2 = j[4] or '#D1CFAD'
		local couleur3 = j[5] or '#000000'
		local icone = j[6] or ''

		local pict = ''
		if icone ~= '' and icone ~= 'defaut' then
			pict = mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Infobox/Pictogramme/' .. mw.text.trim(icone) .. '.css'})
		end

		table.insert(lines , '|-')
		table.insert(lines , '! style="text-align:left;" | ' .. charte)
		table.insert(lines , '| style="text-align:center;" | ' .. wd)
		table.insert(lines , '| style="text-align:center;" | ' .. couleur1)
		table.insert(lines , '| style="text-align:center;" | ' .. couleur2)
		table.insert(lines , '| style="text-align:center;" | ' .. couleur3)
		table.insert(lines , '| style="text-align:center;" | ' .. icone)
		table.insert(lines , '| class="entete ' .. icone .. '" style="background-color:' .. couleur1 .. '; height:45px; text-align:center; font-size:150%; font-weight:bolder; color:' .. couleur3 .. ';" | titre ' .. pict)
		table.insert(lines , '| style="background-color:' .. couleur2 .. '; height:45px; text-align:center; font-size:150%; font-weight:bolder; color:#000000;" | sous-titre')
	end

	table.insert(lines , '|}')
	
	return table.concat(lines, "\n" )
end

--catégorisation par charte utilisée (qu'elle soit déclarée manuellement ou déduite de Wikidata)
local chartcatlabel = (personformat[2] or {})[1] or "par défaut"
chartcatlabel = "Article utilisant l'infobox Biographie2 avec la charte " .. chartcatlabel
local categories
if not mw.title.makeTitle('Catégorie', chartcatlabel ).exists then chartcatlabel = "Article utilisant l'infobox Biographie2 avec une charte sans catégorie" end

return {
	maincolor = personformat[3],
	secondcolor = personformat[4],
	thirdcolor = personformat[5],
	categories = {chartcatlabel},
	documentation = documentation,
	parts = {
		
		person.title(personformat[6]),
		person.mainimage(),
		person.officialposition(),
		person.specialrole(),
		person.nobilitytitle(),
		{type = 'table',title='Biographie',rows = {
			person.birth(),
			person.death(),
			person.placeofburial(),
			person.othernames(),
			{type = 'row', label = 'Époque', value = 'époque', wikidata = {property = 'P2348'}},
			person.nationality(),
			{type = 'row', label = 'Allégeance', plurallabel = 'Allégeances', value = 'allégeance', wikidata = {property = 'P945'}},
			person.places(),
			person.education(),
			person.occupation(),
			person.floruit(),
			person.writinglanguage(),
			person.haswrittenfor(),
			{
				type = 'row',
				label = 'Appartenance ethno-culturelle',
				plurallabel = 'Appartenances ethno-culturelles',
				value= 'ethnicité',
				wikidata = {
				-- ethnicité veut dire appartenance à une ethnie d'après [[Ethnie]]
				-- essai de expl=true qui est normalement fait pour données mises à jour 
				-- mais à utilité dans chaque article difficile à décider automatiquement
					property = 'P172',
					expl = true, 
					-- désactivé si la valeur est une instance de race humaine (Q3254959)
					condition = function(claim)
						local v = wd.getMainId(claim)
						return (not wd.isInstance('Q3254959', v, 2))
					end
				}
			},
			person.family(),
			person.gens(),
			person.slavery(),
		}},
		{type = 'table',title='Autres informations',rows = {
			{type = 'row', label = 'Événement clé', plurallabel = 'Événements clés', value = 'événement', wikidata = {property = 'P793' , expl = true , showdate = true}},
			{type = 'row', label = 'Organisation', plurallabel = 'Organisations', value = 'organisation', wikidata = {property = 'P1268', showdate = true}},
			person.employer(),
			{type = 'row', label = 'Chaire', plurallabel = 'Chaires', value = 'chaire', wikidata = {property = 'P803'}},
			{type = 'row', label = 'Domaine', plurallabel = 'Domaines', value = 'domaine'},  --l'appel à P101 doublonne généralement l'Activité 
			{type = 'row', label = 'Propriétaire de', value = 'propriétaire de', wikidata = {property = 'P1830', showdate = true, sorttype= 'chronological'}},
			person.religion(),
			person.politicalparty(),
			{type = 'row', label = 'Idéologie', value = 'idéologie', wikidata = {property = 'P1142'}},
			person.memberof(),
			{
				type = 'row',
				label = '[[Huit Bannières|Bannière]]',
				plurallabel = '[[Huit Bannières|Bannières]]',
				value = "bannière d'appartenance",
				wikidata = {
					property = 'P470',
					labelformat = function(id)
						local label = wd.getLabel(id)
						if label then
							return mw.ustring.gsub(label, '[Bb]annière ', '')
						end
					end
				}
 			},
			person.military(),
			person.movement(),
			person.appearance(),
			person.sport(),
			{type = 'row', label = 'Grade', plurallabel = 'Grades', value= {'grade dan/kyu','grade'}, wikidata = {property = 'P468', numval = '1', sorttype = 'inverted', showdate = true, precision = 'year', removedupes = true}},
			--{type = 'row',label = 'Commandement',plurallabel = 'Commandements',wikidata = {property = 'P598', sorttype= 'chronological', showdate = true, precision = 'year'},}, --propriété obsolète sur Wikidata
			--{type = 'row', label = 'A participé à', value = 'participant à', property = 'P1344'}, --risque de générer de longue listes sans grande pertinence
			person.torero(),
			person.music(),
			person.contacts(),
			{type = 'row', label = 'Monture', plurallabel= 'Montures', value= 'monture', wikidata = {property = 'P3091', showdate = true}},
			{type = 'row', label = 'Genre artistique', plurallabel= 'Genres artistiques', value= {'genre artistique','genre'}, wikidata = {property = 'P136'}},
			person.influencedby(),
			person.victims(),
			person.penalties(),
			{type = 'row', label = 'Adjectifs dérivés', value = 'adjectifs dérivés'},
			person.website(),
			{type = 'row', label = 'Blog officiel', value = 'blog officiel', wikidata={property = 'P1581' , conjtype = 'new line', showlang = true }},
			person.awards(),
			person.filmography(),
			person.discography(),
			{type = 'row', label = 'Abréviation en botanique', plurallabel = 'Abréviations en botanique', value = 'abréviation en botanique', wikidata={property = 'P428'}},
			{type = 'row', label = 'Abréviation en zoologie', plurallabel = 'Abréviations en zoologie', value = 'abréviation en zoologie', wikidata={property = 'P835'}},
			person.archivesat(),
			person.feast(),
		}},
		person.honorifictitle(),
		person.voice(),
		person.prononciation(),
		person.blason(),
		person.sceau(),
		person.monogram(),
		person.flag(),
		person.logo(),
		person.works{title = localdata['intitulé œuvres'] or localdata['intitulé oeuvres']},
		person.signature(),
		person.plaque(),
		person.tombe(),
	}
}