Module:Recent deaths

From Wikidata
Jump to navigation Jump to search
Lua
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules

Documentation for this module may be created at Module:Recent deaths/doc

Code

local p = {}

local script = {
	ja='other',
	zh='other',
	ar='other',
	fa='other',
	ko='other',
	hy='other',
	el='other',
	th='other',
	ta='other',
	mr='other',
	sr='cyrl',
	mk='cyrl',
	kk='cyrl',
	ru='cyrl',
	uk='cyrl',
	ur='دیگر'

}

local color = {
	other="#E8E8E8",
	cyrl="#F2F2F8",
	latin="white"
}

local lang = {
	simple='en'
}

local sign = {
	other="→ ",
	cyrl="⇒ ",
	latin="",
	en="[en]"
}

function p.main(frame)
	args = frame:getParent().args
	entity = mw.wikibase.getEntityObject(args[1])
	site=string.sub( args[2], 1, (string.find( args[2], ',' ) or (string.len( args[2] )+1))-1 )
	text='<tr valign=top bgcolor=' .. color[script[site] or "latin"] .. '><td data-sort-value="' .. string.sub( args[1], 2 ) .. '">[[' .. args[1] .. ']]</td><td>'
	text=text..(entity:getLabel( lang[site] or site ) or '' ).. '</td><td>'
	text=text..string.sub(entity:formatPropertyValues( 'P21' ).value .. '?',1,1) .. '</td><td><span style="white-space: nowrap;">'
	text=text..entity:formatPropertyValues( 'P569' ).value .. '</span></td><td>'
	text=text..entity:formatPropertyValues( 'P106' ).value .. '</td><td>'
	text=text..entity:formatPropertyValues( 'P27' ).value .. '</td><td>'
	text=text..entity:formatPropertyValues( 'P735' ).value .. '</td><td>'
	text=text..0 .. '</td><td><span style="white-space: nowrap;">'
	text=text..(sign[site] or (sign[script[site] or "latin"] .. site))  .. '</span></td><td><span style="white-space: nowrap;">'
	text=text..args[3] .. '</span></td><td>'
	text=text..entity:formatPropertyValues( 'P31' ).value .. '</td><td><span style="white-space: nowrap;">'
	text=text..entity:formatPropertyValues( 'P570' ).value .. '</span></td>'
	return text
end

return p