Module:Infobox/Ouvrage
Wikimedia module / De Wikipedia, l'encyclopédie encyclopedia
local localdata = require 'Module:Infobox/Localdata' local general = require "Module:Infobox/Fonctions" local wikidata = require "Module:Wikidata" local linguistic = require "Module:Linguistique" local convert = require "Module:Conversion"
local function italics(query) local val = wikidata.formatAndCat(query) if val then return '' .. val .. '' end end
local function isNotInFrench(claim) local snak = claim.mainsnak if snak.snaktype == 'value' and snak.datatype == 'monolingualtext' then return snak.datavalue.value.language ~= 'fr' end return true end
local occupationformats = { --{élément Wikidata, nom charte, couleur titre, couleur sous-titre, couleur texte, icône) doivent être classés du plus spécifique au plus général
{'Q131569' , 'traité' , '#E1E1E1' , , , }, {'Q5185279' , 'poème', '#C4698F', , , 'auteur'}, {'Q482' , 'poésie', '#C4698F', , , 'auteur'}, {'Q49084', 'nouvelle' , '#FFE680' , , , 'auteur'}, {'Q20730955' , 'conte' , '#70759A', , '#FFFFFF' , }, {'Q56028349' , 'comic' , '#800000', "#FF3040", '#FFFFFF' , 'bd'}, {'Q838795' , 'strip' , '#800000', "#FF3040", '#FFFFFF' , 'bd'}, {'Q1004' , 'bd' , '#FFDD55', "#FFEEAA", '#000000' , 'bd'},
{'Q8274' , 'manga' , '#9BD1FF' , '#C3E2FF' , , 'bd'}, {'Q25379' , 'théâtre' , '#B03030' , , '#FFFFFF' , 'persofiction'}, {'Q685935' , 'revue' , '#DDFFCC' , , , 'communication'}, {'Q642946' , 'livre-jeu' , '#E8E8E8' , , , }, {'Q2085381' , 'maison d\'édition' , '#8E5434' , , '#FFFFFF' , },
{'Q12308638' ,'recueil de poèmes' , '#C4698F' , , , 'auteur'}, {'Q1279564' , 'recueil de nouvelles' , '#FFE680' , , , 'auteur'}, {'Q27560760' , 'recueil de contes' , '#70759A', , '#FFFFFF' , },
{'Q5292' , 'encyclopédie' , '#CCB266' , , , 'universite'}, {'Q23622' , 'dictionnaire' , '#CCB266' , , , 'universite'}, {'Q41298' , 'magazine' , '#E1E1E1' , , , 'presse'}, {'Q1002697' , 'périodique' , '#E1E1E1' , , , 'presse'},
}
local function setformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre local occupations = wikidata.getIds(localdata.item, {property = 'P7937,P31,P136'}) -- récupère les Qid des genres
--if not occupations or (#occupations > 1) then -- si plusieurs genres, on ne sait pas lequel choisir --return {'Q', , '#7DA7D9', , '#000000', 'universite'} --end occupations = wikidata.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 if l[1] == j then return l end end end return {'Q', , '#7DA7D9', , '#000000', 'universite'} end local function setcharte() local charte = localdata['charte'] if charte then for i, j in pairs(occupationformats) do if j[2] == charte then return j end end end return setformat() end local workformat = setcharte() return { maincolor = workformat[3], secondcolor = workformat[4], thirdcolor = workformat[5], parts =
{
general.title(workformat[6], nil, nil, nil, true), general.mainimage{ cat = "Article à illustrer Ouvrage", wikidata = {property = {"P3383", "P2716", "P18", "P10"}, numval = 1}, alt = localdata['alt'] }, {type = "table", rows = { {type = "row", label = "Titre original", value = "titre original", plurallabel = "Titres originaux" , wikidata = function ( item ) return italics({entity = item, property = 'P1476', conjtype = 'new line' , condition = isNotInFrench, showlang = true , numval = 1}) end }, {type = "row", label = "Nom officiel", value = "nom officiel", plurallabel = "Noms officiels" , wikidata = function ( item ) return italics({entity = item, property = 'P1448', conjtype = 'new line' , lang='fr' , showlang = true }) end }, {type = "row", label = "Format", value = "format" , plurallabel = "Formats" , wikidata = {property = 'P7937,P31', conjtype = 'new line' , excludevalues = {'Q571', 'Q47461344', 'Q7725634', 'Q3331189' , 'Q386724' , 'Q25839930', 'Q108329152','Q58483083','Q105543609'}}},
{type = "row", label = "Partie de", value = "partie de" , wikidata = function ( item )
return italics({entity = item, property = 'P361', conjtype = 'new line' , showlang = true }) end },
{type = "row", label = "Comprend", value = "comprend" , wikidata = function ( item )
return italics({entity = item, property = 'P527', conjtype = 'new line' , showlang = true, sorttype = 'P1545' }) end }, {type = "row", label = "Langue", value = "langue" , plurallabel = "Langues", property = 'P364,P407'}, {type = "row", label = "Auteur", value = "auteur", plurallabel = "Auteurs" , wikidata = {property = 'P50,P2093' , conjtype = 'new line', sorttype = 'P1545'}}, {type = "row", label = "Fondateur", value = "fondateur", plurallabel = "Fondateurs" , wikidata = {property = 'P112' , conjtype = 'new line'}}, {type = "row", label = "Attribué à", value = "attribué à", wikidata = {property = 'P1773' , conjtype = 'new line'}}, {type = "row", label = "Scénariste", value = "scénariste", plurallabel = "Scénaristes" , wikidata = {property = 'P58' , conjtype = 'new line'}}, {type = "row", label = "Signataire", value = "signataire", plurallabel = "Signataires" , wikidata = {property = 'P1891' , conjtype = 'new line'}},
{type = "row", label = "Préface", value = "préface", wikidata = {property = 'P2679' , conjtype = 'new line'}},
{type = "row", label = "Traduction", value = "traduction", plurallabel = "Traductions" , wikidata = {property = 'P655' , conjtype = 'new line'}}, {type = "row", label = "Lettreur", value = "lettreur" , plurallabel = "Lettreurs" , wikidata = {property = 'P9191' , conjtype = 'new line'}}, {type = "row", label = "Illustration", value = "illustration" , wikidata = {property = 'P110' , conjtype = 'new line'}}, {type = "row", label = "Coloriste", value = "coloriste" , plurallabel = "Coloristes" , wikidata = {property = 'P6338' , conjtype = 'new line'}},
{type = "row", label = "Basé sur", value = "basé sur" , wikidata = function ( item )
return italics({entity = item, property = 'P144,P941' , conjtype = 'new line' , showlang = true }) end }, {type = "row", label = "Genre", value = "genre", plurallabel = "Genres" , wikidata = {property = 'P136' , conjtype = 'new line'}}, {type = "row", label = "Sujet", value = "sujet", plurallabel = "Sujets" , wikidata = {property = 'P921'}}, {type = "row", label = "Personnage", value = "personnage", plurallabel = "Personnages" , wikidata = {property = 'P674' , numval = 5 , conjtype = 'new line'}}, {type = "row", label = "Époque de l'action", value = "époque", wikidata = {property = 'P2408', sorttype = 'chronological', showqualifiers = 'P585,P1319,P1326,P580,P582' , conjtype='new line'}}, {type = "row", label = "Date", value = "date", plurallabel = "Dates" , wikidata = {property = 'P585' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437'}},
{type = "row", label = "Date de création", value = "date de création", wikidata = {property = 'P571', sorttype = 'chronological'}},
{type = "row", label = "Date de parution", value = "date de parution", plurallabel = "Dates de parution" , wikidata = {property = 'P577,P580' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437,P407,P123'}}, {type = 'row', label = "Date de fin", value="date de fin", wikidata = {property = 'P582' , sorttype = 'chronological'}}, {type = "row", label = "Date de dissolution", value = "date de dissolution", wikidata = {property = 'P576', sorttype = 'chronological'}}, --trouver le moyen de transformer en "mensuel", "annuel", etc. {type = "row", label = "Périodicité" , value = "périodicité" , wikidata = {property = 'P2896' , showunit = 'long'}}, {type = "row", label = "Lieu", value = "lieu" , plurallabel = "Lieux" , property = 'P276'}, {type = "row", label = "Lieu de publication", value = "lieu de publication" , plurallabel = "Lieux de publication" , property = 'P291'}, {type = "row", label = "Pays", value = "pays" , property = 'P495,P17'}, {type = "row", label = "Publié dans", value = "publié dans", wikidata = function ( item ) return italics({entity = item, property = 'P1433', conjtype = 'new line' , showlang = true }) end }, {type = "row", label = "Éditeur", value = "éditeur", plurallabel = "Éditeurs" , wikidata = {property = 'P123,P98' , showqualifiers = 'P407' , showdate = true, conjtype = 'new line'}}, {type = "row", label = "Collection", value = "collection", plurallabel = "Collections" , wikidata = {property = 'P195' , conjtype = 'new line' , sorttype = 'chronological' , showdate = true}}, {type = "row", label = "Nombre de pages", value = "pages", wikidata = {property = 'P1104'}}, {type = "row", label = "Œuvre dérivée", value = "oeuvre", plurallabel = "Œuvres dérivées" , wikidata = function ( item ) return italics({entity = item, property = 'P4969', conjtype = 'new line' , showlang = true }) end }, {type = "row", label = "ISBN 10", value = "isbn10" , wikidata = {property = 'P957' , conjtype = 'new line'}},
{type = "row", label = "ISBN 13", value = "isbn13" , wikidata = {property = 'P212' , conjtype = 'new line'}}, {type = "row", label = "ISSN", value = "issn" , wikidata = {property = 'P236' , conjtype = 'new line'}}, general.website(),
} }, {type = "table", title = "Distinctions", rows = { {type = "row", value = "distinction", wikidata = {property = 'P166' , conjtype = 'new line', showqualifiers = 'P585'}}, } }, {type = "table", title = "Séquence", rows = { {type = "row", label = "Univers", value = "univers", wikidata = function ( item ) return italics({entity = item, property = 'P1434', conjtype = 'new line' , showlang = true }) end }, {type = "row", label = "Série", value = "série", plurallabel = "Séries" , wikidata = function ( item ) return italics({entity = item, property = 'P179', conjtype = 'new line' , showlang = true }) end }, {type = "navbox", inner = true, previouswikidata = function ( item ) line = italics({entity = item, property = 'P155', conjtype = 'new line' , showlang = true }) if not line then line = italics({entity = item, property = 'P179', conjtype = 'new line' , showlang = true, showonlyqualifier = 'P155', excludespecial = true }) end return line end, nextwikidata = function ( item ) line = italics({entity = item, property = 'P156', conjtype = 'new line' , showlang = true }) if not line then line = italics({entity = item, property = 'P179', conjtype = 'new line' , showlang = true, showonlyqualifier = 'P156', excludespecial = true }) end return line end }, } }, { type = 'images', style = {['padding-top'] = '25px'},--{['border-width'] = '10px', ['border-style'] = 'solid'}, label = 'Audio', captionparameter = 'légende audio', value = 'audio', property = 'P51', numval = 1, defaultcaption = 'fichier audio', }, { type = 'images', imageparameters = {'logo'}, defaultimages = nil, defaultupright = 0.5, uprightparameter = 'upright logo', sizeparameter = 'taille logo', -- obsolète captionparameter = 'légende logo', defaultcaption = 'logo', property = 'P154',
},
} }