Jump to content

Module:Location

From Namtars

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

local utils = require( 'Module:Utils' )

local p = {}

local function propertiesPlanMono()
	local propMap = {
		['Tibetan name']               = {'Tibetan name', '@bo'},
		['Wylie transliteration']      = {'Wylie transliteration', '@bo-x-ewts'}
	}
	return propMap
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'},	
		['BDRC']                       = {'BDRC ID'},
		['Prefers manual coordinates'] = {'Prefers manual coordinates'},
		['Coordinates']                = {'Has coordinates'},
		['Located in region']          = {'Located in region', ','},
		['Location type']              = {'Location type'},
		['River']                      = {'Has related river'},
		['Related practitioners']      = {'Has related practitioner', ','},
		['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'
			}
		},
		['Map'] = {
			heading = '',
			template = 'Infobox/Map',
			subobject = 'false',
			order = '3',
			rows = {
				'BDRC',
				'Coordinates',
				'Prefers manual coordinates'
			}
		},
		['Custom Map'] = {
			heading = '',
			template = 'Infobox/Custom map',
			subobject = 'false',
			order = '4',
			rows = {
				'Include custom map',
				'Has related map'
			}
		},
		['Related'] = {
			heading = 'Related',
			template = 'Infobox/Related',
			subobject = 'false',
			order = '2',
			rows = {
				'Located in region',
				'River',
				'Related practitioners'
			}
		},
		['Names'] = {
			heading = 'Names',
			template = 'Infobox/Names',
			subobject = 'true',
			order = '5',
			rows = {
				'Tibetan name',
				'Wylie transliteration',
				'Names'
			}
		},
		['Quotes'] = {
			heading = 'Quotes',
			template = 'Infobox/Quotes',
			subobject = 'true',
			order = '6',
			rows = {
				'Quotes'
			}
		},
		['Links'] = {
			heading = 'Resources',
			template = 'Infobox/Links',
			subobject = 'true',
			order = '7',
			rows = {
				'Links'
			}
		}
	}
	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        = 'Locations'
	local properties = propertiesPlan()
	local sections   = infoboxSectionPlan()
	local infobox    = utils.createInfobox(frame, cat, properties, sections)
	return infobox
end

return p