Aller au contenu

Module:Infoboesse/live

Èn årtike di Wikipedia.

La documentation pour ce module peut être créée à Module:Infoboesse/live/doc

-- Ci module ci c' est po les dnêyes d' on live (eplaidaedje)
local p = {}
local date = require("Module:Date")
local infoboesse = require("Module:Infoboesse")
local wd = require("Module:Wikidata")

function p.get_infos(entity)
	local frame = mw.getCurrentFrame()
	local data = mw.html.create()
	local tb = {}
	
	-- tite
	local title = entity:getClaims('P1476')
	if title and title[1] then
		text = title[1].mainsnak.datavalue.value.text
		lang = title[1].mainsnak.datavalue.value.language
		if lang ~= "wa" then
			val = "<small style=\"color:gray;\">'''("..lang..")'''</small> "
			    .. "''"..frame:expandTemplate{ title = 'ling', args = { lang, text } } .. "''"
		else
			val = "''"..text.."''"
		end
		table.insert(tb, {"Tite", val})
	end
	
	-- oteur
	local askepieus = entity:getBestStatements('P50')
	local label = "Oteur"
	val = {}
	if askepieus ~= nil then
		for i, askepieu in ipairs( askepieus ) do
			local val_of = mw.wikibase.getLabel(askepieu.mainsnak.datavalue.value.id)
			if mw.wikibase.getSitelink(askepieu.mainsnak.datavalue.value.id) then
		    	val_of = "[[".. mw.wikibase.getSitelink(askepieu.mainsnak.datavalue.value.id) .."|" .. val_of .. "]]"
		    end
		    table.insert(val, val_of)
		end
		if #val > 1 then label = label.."s" end
		val = table.concat(val, ', ')
		table.insert(tb, {label, val})
	end
	
	-- date
	local fdate = entity:getClaims('P577')
	if fdate and fdate[1] then
		val = date.formatDate(fdate[1].mainsnak)
		table.insert(tb, {"Eplaidaedje", val})
	end
	
	data:node(infoboesse.get_simple_html_table(tb))
	
	return data
end

return p