Jump to content

Module:Historical event

From Namtars

Documentation for this module may be created at Module:Historical event/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()
	local propMap = {
		['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'},			
		['Has related map']         = {'Has related map', 'GeoJSON'}
	}
	return propMap
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 = '',
			template = 'Infobox/Event timeline',
			subobject = 'false',
			order = '2',
			rows = {
				'Event timeline',
			}
		},
		['Names'] = {
			heading = 'Names',
			template = 'Infobox/Names',
			subobject = 'true',
			order = '3',
			rows = {
				'Tibetan name',
				'Wylie transliteration',
				'Names'
			}
		},
		['Custom Map'] = {
			heading = '',
			template = 'Infobox/Custom map',
			subobject = 'false',
			order = '4',
			rows = {
				'Include custom map',
				'Has related map'
			}
		},
		['Quotes'] = {
			heading = 'Quotes',
			template = 'Infobox/Quotes',
			subobject = 'true',
			order = '5',
			rows = {
				'Quotes'
			}
		}
	}
	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        = 'Historical events'
	local properties = propertiesPlan()
	local sections   = infoboxSectionPlan()
	local infobox    = utils.createInfobox(frame, cat, properties, sections)
	return infobox
end

return p