Module:Creator

Lua
CodeDiscussionLinksLink count SubpagesDocumentationTestsResultsSandboxLive code All modules

Aim edit

This aim of this module is to develop routines to either work with or replace parts of the {{Creator}} template extensively used on Commons.

It is currently at a very early stage of inital development and experimentation.

Test pages edit

Code

local p = {}

local wikidata = require('Module:Wikidata')

function p.CreatorProperties(frame)
	local item = frame.args[1]
	local entity = mw.wikibase.getEntityObject(item)  -- item needs to include the Q
	
	local t = {}
	table.insert(t, ' {{Creator')
	
	table.insert(t, '   | Name              = ' .. entity:getLabel())
	table.insert(t, '   | Birthdate         = ' .. table.maxn(entity:formatPropertyValues('P569'),'/'))
	table.insert(t, '   | Birthloc          = ' .. table.maxn(entity:formatPropertyValues('P19'),'/'))
	table.insert(t, '   | Deathdate         = ' .. table.maxn(entity:formatPropertyValues('P570'),'/'))
	table.insert(t, '   | Deathloc          = ' .. table.maxn(entity:formatPropertyValues('P20'),'/'))
	
	table.insert(t, '   | Wikidata          = ' .. item)	
	table.insert(t, ' }}')	
	
	local ret = table.concat(t, '\n')
	return(ret)
end	


return p