Vejatz lo contengut

Mòdul:Infobox/Obratge

Un article de Wikipèdia, l'enciclopèdia liura.

La documentacion d'utilizacion d'aquel modul se pòt crear a Mòdul:Infobox/Obratge/ús

local localdata = require 'Mòdul:Infobox/Localdata'
local general = require "Mòdul:Infobox/Foncions"
local wikidata = require "Mòdul:Wikidata"
local linguistic = require "Mòdul:Lingüistica"
local convert = require "Mòdul:Conversion"
local periodicitat = require 'Mòdul:Diccionari Wikidata/Periodicitat'

local function italics(query)
	local val = wikidata.formatAndCat(query)
	if val then
		return '<i>' .. val .. '</i>'
	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 carta, couleur titre, couleur sous-titre, couleur texte, icône)  doivent être classés du plus spécifique au plus général
    {'Q131569' , 'tractat' , '#E1E1E1' , '' , '' , ''},
    {'Q5185279' , 'poèma', '#C4698F', '', '', 'autor'},
    {'Q482' , 'poesia', '#C4698F', '', '', 'autor'},
    {'Q49084', 'novèla' , '#FFE680' , '' , '' , 'autor'},
    {'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' , 'teatre' , '#B03030' , '' , '#FFFFFF' , 'persoficcion'},
	{'Q685935' , 'revista' , '#DDFFCC' , '' , '' , 'communicacion'},
	{'Q642946' , 'librejòc' , '#E8E8E8' , '' , '' , ''},
	{'Q2085381' , 'editorial' , '#8E5434' , '' , '#FFFFFF' , ''},
    {'Q12308638' ,'recuèlh de poèmas' , '#C4698F' , '' , '' , 'autor'},
    {'Q1279564' , 'recuèlh de novèlas' , '#FFE680' , '' , '' , 'autor'},
    {'Q27560760' , 'recuèlh de contes' , '#70759A', '' , '#FFFFFF' , ''},
	{'Q5292' , 'encyclopèdia' , '#CCB266' , '' , '' , 'universitat'},
	{'Q23622' , 'diccionnari' , '#CCB266' , '' , '' , 'universitat'},
	{'Q41298' , 'magazina' , '#E1E1E1' , '' , '' , 'premsa'},
	{'Q1002697' , 'periodic' , '#E1E1E1' , '' , '' , 'premsa'},
	
}

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 --is this case sensitive? getIds doesn't work, but I see getid and getids elsewhere...

	--if not occupations or (#occupations > 1) then -- si plusieurs genres, on ne sait pas lequel choisir
		--return  {'Q', '', '#7DA7D9', '', '#000000', 'universitat'}
	--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', 'universitat'}
end
local function setcarta()
	local carta = localdata['carta']
	if carta then
		for i, j in pairs(occupationformats) do
			if j[2] == carta then
				return j
			end
		end
	end
	return setformat()
end
local workformat = setcarta()
return {
	maincolor = workformat[3],
	secondcolor = workformat[4],
	thirdcolor = workformat[5],
	parts =
    	{
			general.title(workformat[6], nil, nil, nil, true),
			general.mainimage{ 
				cat = "Article a illustrar Obratge",
				wikidata = {property = {"P3383", "P2716", "P18", "P10"}, numval = 1},
				alt = localdata['alt']
				},
		{type = "table", rows = {
			{type = "row", label = "Títol original", value = "títol original", plurallabel = "Títols originals" , wikidata = function ( item )
					return italics({entity = item, property = 'P1476,P629', conjtype = 'new line' , condition = isNotInFrench, showlang = true , numval = 1})
				end
			},
					{type = "row", label = "Nom oficial", value = "nom oficial", plurallabel = "Noms oficials" , 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','Q49848'}}},
   			{type = "row", label = "Partida de", value = "partida de" , wikidata = function ( item )
					return italics({entity = item, property = 'P361', conjtype = 'new line' , showlang = true })
				end
			},
   			{type = "row", label = "Compren", value = "compren" , wikidata = function ( item )
					return italics({entity = item, property = 'P527', conjtype = 'new line' , showlang = true, sorttype = 'P1545' })
				end
			},
			{type = "row", label = "Lenga", value = "lenga" , plurallabel = "Lengas", property = 'P364,P407'},
			{type = "row", label = "Autor", value = "autor", plurallabel = "Autors" , wikidata = {property = 'P50,P2093' , conjtype = 'new line', sorttype = 'P1545'}},
			{type = "row", label = "Fondator", value = "fondator", plurallabel = "Fondators" , wikidata = {property = 'P112' , conjtype = 'new line'}},
			{type = "row", label = "Atribuit a", value = "atribuit a", wikidata = {property = 'P1773' , conjtype = 'new line'}},
			{type = "row", label = "Scenarista", value = "scenarista", plurallabel = "Scenaristas" , wikidata = {property = 'P58' , conjtype = 'new line'}},
			{type = "row", label = "Signatari", value = "signatari", plurallabel = "Signataris" , wikidata = {property = 'P1891' , conjtype = 'new line'}},
            {type = "row", label = "Prefaci", value = "prefaci", wikidata = {property = 'P2679' , conjtype = 'new line'}},
			{type = "row", label = "Traduccion", value = "traduccion", plurallabel = "Traduccions" , wikidata = {property = 'P655' , conjtype = 'new line'}},
			{type = "row", label = "Letror", value = "letror" , plurallabel = "Letrors" , wikidata = {property = 'P9191' , conjtype = 'new line'}},
			{type = "row", label = "Illustracion", value = "illustracion" , wikidata = {property = 'P110' , conjtype = 'new line'}},
			{type = "row", label = "Colorista", value = "colorista" , plurallabel = "Coloristas" , wikidata = {property = 'P6338' , conjtype = 'new line'}},
            {type = "row", label = "Basat sus", value = "basat sus" , 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 = "Subjècte", value = "subjècte", plurallabel = "Subjèctes" , wikidata = {property = 'P921'}},
			{type = "row", label = "Personatge", value = "personatge", plurallabel = "Personatges" , wikidata = {property = 'P674' , numval = 5 , conjtype = 'new line'}},
			{type = "row", label = "Epòca de l'accion", value = "epòca", wikidata = {property = 'P2408', sorttype = 'chronological', showqualifiers = 'P585,P1319,P1326,P580,P582' , conjtype='new line'}},
			{type = "row", label = "Data", value = "data", plurallabel = "Datas" , wikidata = {property = 'P585' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437'}},
            {type = "row", label = "Data de creacion", value = "data de creacion", wikidata = {property = 'P571', sorttype = 'chronological'}},
			{type = "row", label = "Data de parucion", value = "data de parucion", plurallabel = "Datas de parucion" , wikidata = {property = 'P577,P580' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437,P407,P123'}},
			{type = "row", label = "Periodicitat", value = "periodicitat", plurallabel = "periodicitats" , wikidata = {property = 'P2896' , speciallabels = periodicitat}},
			{type = "row", label = "Jorns de parucion", value = "jorn de parucion", plurallabel = "jorns de parucion" , property = 'P6437'},
			{type = 'row', label = "Data de fin", value="data de fin", wikidata = {property = 'P582' , sorttype = 'chronological'}},
			{type = "row", label = "Data de dissolucion", value = "data de dissolucion", 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 = "Luòc", value = "luòc" , plurallabel = "Luòcs" , property = 'P276'},
			{type = "row", label = "Luòc de publicacion", value = "luòc de publicacion" , plurallabel = "Luòcs de publicacion" , property = 'P291'},
			{type = "row", label = "País", value = "país" , wikidata = {property = 'P495,P17' , removedupes = true}},
			{type = "row", label = "Publicat dins", value = "publicat dins", wikidata = function ( item )
					return italics({entity = item, property = 'P1433', conjtype = 'new line' , showlang = true })
					end
				},
			{type = "row", label = "Editor", value = "editor", plurallabel = "Editors" , wikidata = {property = 'P123,P98' , showqualifiers = 'P407' , showdate = true, conjtype = 'new line'}},
			{type = "row", label = "Colleccion", value = "colleccion", plurallabel = "Colleccions" , wikidata = {property = 'P195' , conjtype = 'new line' , sorttype = 'chronological' , showdate = true}},
			{type = "row", label = "Nombre de paginas", value = "paginas", wikidata = {property = 'P1104'}},
			{type = "row", label = "Òbra derivada", value = "òbra", plurallabel = "Òbras derivadas" , wikidata = function ( item )
					return italics({entity = item, property = 'P4969', conjtype = 'new line' , showlang = true })
				end
				},
			{type = "row", label = "[[International Standard Book Number|ISBN]] 10", value = "isbn10" , wikidata = {property = 'P957' , conjtype = 'new line'}},
            {type = "row", label = "[[International Standard Book Number|ISBN]] 13", value = "isbn13" , wikidata = {property = 'P212' , conjtype = 'new line'}},
            {type = "row", label = "[[International Standard Serial Number|ISSN]]", value = "issn" , wikidata = {property = 'P236' , conjtype = 'new line'}},
            general.website(),
		}
		},
	{type = "table", title = "Distinccions", rows = {
			{type = "row", value = "distinccion", wikidata = {property = 'P166' , conjtype = 'new line', showqualifiers = 'P585'}},
		}
		},
	{type = "table", title = "Sequéncia", 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 = "Seria", value = "seria", plurallabel = "Serias" , wikidata = function ( item )
					return italics({entity = item, property = 'P179', conjtype = 'new line' , showlang = true })
				end
			},
			{type = "navigator", 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 = 'legenda audio',
			value		     = 'audio',
			property	     = 'P51',
			numval           = 1,
			defaultcaption = 'fichièr audio',
		},
	{
		     type = 'images',
		     imageparameters =  {'logo'},
		     defaultimages = nil,
		     defaultupright = 0.5,
		     uprightparameter = 'upright logo',
		     sizeparameter = 'talha logo', -- obsolète
			 captionparameter = 'legenda logo',
			 defaultcaption = 'logo',
			 property = 'P154',
    },
}
}