Jump to content

Module:Person

From Namtars

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

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlanMono()
	return {
		['Tibetan name'] = {'Tibetan name', '@bo'},
		['Wylie transliteration'] = {'Wylie transliteration', '@bo-x-ewts'}
	}
end
local function propertiesPlan()
	return {
		['Cover image']                   = {'Has cover image', 'file'},
		['Cover image caption']           = {'Has caption'},
		['Description']                   = {'Description text'},
		['Main quote']                    = {'Has main quote'},
		['Main quote source']             = {'Main quote source'},		
		['Oldest known root mindstream']  = {'Oldest known root mindstream'},
		['Has closest known predecessor'] = {'Has closest known predecessor'},
		['Emanation type']                = {'Emanation type', ','},
		['Birth place']                   = {'Birth place'},
		['Death place']                   = {'Death place'},
		['Roles']                         = {'Has role', ','},
		['Places of activity']            = {'Place of activity', ','},
		['Teachers']                      = {'Has teacher', ','},
		['Students']                      = {'Has student', ','},
		['Dharma friends']                = {'Is Dharma friend of', ','},
		['Has related map']               = {'Has related map', 'GeoJSON'}
	}
end

local function infoboxSectionPlan()
	local sectionMap = {
		['Cover'] = {
			heading = '',
			template = 'Infobox/Cover',
			subobject = 'false',
			order = '1',
			rows = {
				'Tibetan name',
				'Cover image',
				'Cover image caption',
				'Description',
				'Main quote',
				'Main quote source'
			}
		},
		['Timeline'] = {
			heading = 'Timeline',
			template = 'Infobox/Person timeline',
			subobject = 'false',
			order = '2',
			rows = {
				'Birth',
				'Death',
				'Birth place',
				'Death place',
			}
		},
		['Mindstream'] = {
			heading = 'Mindstream',
			template = 'Infobox/Mindstream',
			subobject = 'false',
			order = '3',
			rows = {
				'Oldest known root mindstream',
				'Has closest known predecessor',
				'Is immediate successor',
				'Emanation type',
			}
		},
		['Training'] = {
			heading = 'Training',
			template = 'Infobox/Training',
			subobject = 'false',
			order = '4',
			rows = {
				'Teachers',
			}
		},
		['Activity'] = {
			heading = 'Activity',
			template = 'Infobox/Activity',
			subobject = 'false',
			order = '5',
			rows = {
				'Roles',
				'Places of activity',
				'Students',
				'Dharma friends'
			}
		},
		['Names'] = {
			heading = 'Names',
			template = 'Infobox/Names',
			subobject = 'true',
			order = '6',
			rows = {
				'Tibetan name',
				'Wylie transliteration',
				'Names'
			}
		},
		['Custom Map'] = {
			heading = '',
			template = 'Infobox/Custom map',
			subobject = 'false',
			order = '7',
			rows = {
				'Include custom map',
				'Has related map'
			}
		},
		['Quotes'] = {
			heading = 'Quotes',
			template = 'Infobox/Quotes',
			subobject = 'true',
			order = '8',
			rows = {
				'Quotes'
			}
		},
		['Resources'] = {
			heading = 'External resources',
			template = 'Infobox/Person external profiles',
			subobject = 'true',
			order = '9',
			rows = {
				'Resource'
			}
		}
	}
	return sectionMap
end

function p.infobox(frame)
	local args      = frame:getParent().args
	local monoProps = utils.setPropertiesMono(propertiesPlanMono(), args) or {}
	mw.smw.set(monoProps)
	local cat        = 'People'
	local properties = propertiesPlan()
	local sections   = infoboxSectionPlan()
	local infobox    = utils.createInfobox(frame, cat, properties, sections)
	return infobox
end

return p