Module:Location Template

-- credit: Marvel Database (marvel.fandom.com) -- module for Marvel Database:Location Template local p = {} local getArgs = require('Module:Arguments').getArgs local h = require("Module:HF") local design = require('Module:Design') local field_names = { 'Dimension', 'Galaxy', 'StarSystem', 'Planet', 'Continent', 'Country', 'State', 'Province', 'Territory', 'Region', 'District', 'Prefecture', 'Division', 'City', 'Locale'} local list1 = { 'Dimension', 'Galaxy', 'Star System', 'Planet', 'Continent', 'Country', 'State', 'Province', 'Territory', 'Region', 'District', 'Prefecture', 'Administrative Division', 'City', 'Locale'} local list2 = { 'Dimensions', 'Galaxies', 'Star Systems', 'Planets', 'Continents', 'Countries', 'States', 'Provinces', 'Territories', 'Regions', 'Districts', 'Prefectures', 'Administrative Divisions', 'Cities', 'Locales'}

function p.main(frame) local args = getArgs(frame) local pagename = mw.title.getCurrentTitle.text local page_type = 'Location' local value local categories = {} local output_categories = {} local output = {}

table.insert(output_categories, p.lua_get_outdated_fields(args) )

-- sections -- adds 'Quote', 'Overview' section, 'TOC' and 'History' section value, categories = design.add_quote_overview_toc_history(args, page_type) output_categories = h.join_tables(output_categories, categories) output = h.join_tables(output, value)

table.insert( output, design.add_section('Points of Interest', args.PointsOfInterest, 2) ) table.insert( output, design.add_section('Residents', args.Residents, 2) )

-- adds 'Notes', 'Trivia', 'See Also', 'Recommended Reading' and 'Links and References' sections links to standard sub-pages/categories - "Appearances", "Minor Appearances", Mentions", "Images", "Quotes" and "Gallery" 	value, categories = design.add_notes_trivia_see_also_recommended_links_references(args, page_type, pagename)	output_categories = h.join_tables(output_categories, categories)	output = h.join_tables(output, value) --	output_categories = h.add_categories(output_categories)	output = table.concat(output)	return frame:preprocess(output)..output_categories end

-- function p.lua_get_outdated_fields(args) local output = '' if not h.isempty(args.Custom) or not h.isempty(args.CustomLabel) or not h.isempty(args.CustomSection1) or not h.isempty(args.CustomText1) or not h.isempty(args.CustomSection2) or not h.isempty(args.CustomText2) or not h.isempty(args.NotesHeader) or not h.isempty(args.TriviaHeader) or not h.isempty(args.LinksHeader) or not h.isempty(args.HistoryHeader) or not h.isempty(args.PointsOfInterestHeader) or not h.isempty(args.ResidentsHeader) or not h.isempty(args.SeeAlsoHeader) or not h.isempty(args.RecommendedHeader) or not h.isempty(args.Title2) then output = 'Outdated Fields/Locations' end return output end

-- function p.get_government(frame) local list = { ["absolute matriarchy"]					= {'Absolute Monarchies', 'Absolute Matriarchy'}, ["absolute monarchy"]					= {'Absolute Monarchies', 'Absolute Monarchy'}, ["anarchy"]								= {'Anarchies', 'Anarchy'}, ["autocracy"]							= {'Autocracies', 'Autocracy'}, ["benevolent matriarchy"]				= {'Benevolent Matriarchies', 'Benevolent Matriarchy'}, ["benign anarchy"]						= {'Benign Anarchies', 'Benign Anarchy'}, ["city-state"]							= {'City-States', 'City-State'}, ["city-states"]							= {'City-States Countries', 'City-States'}, ["communist republic"]					= {'Communist Republics', 'Communist Republic'}, ["communist state"]						= {'Communist States', 'Communist State'}, ["constitutional democracy"]			= {'Constitutional Democracies', 'Constitutional Democracy'}, ["constitutional federal republic"]		= {'Constitutional Federal Republics', 'Constitutional Federal Republic'}, ["constitutional monarchy"]				= {'Constitutional Monarchies', 'Constitutional Monarchy'}, ["constitutional republic"]				= {'Constitutional Republics', 'Constitutional Republic'}, ["democracy"]							= {'Democracies', 'Democracy'}, ["democratic constitutional monarchy"]	= {'Democratic Constitutional Monarchies', 'Democratic Constitutional Monarchy'}, ["democratic republic"]					= {'Democratic Republics', 'Democratic Republic'}, ["democratic federal republic"]			= {'Democratic Federal Republics', 'Democratic Federal Republic'}, ["democratic parliamentary monarchy"]	= {'Democratic Parliamentary Monarchies', 'Democratic Parliamentary Monarchy'}, ["dictatorship"]						= {'Dictatorships', 'Dictatorship'}, ["elective monarchy"]					= {'Elective Monarchies', 'Elective Monarchy'}, ["fascistic military dictatorship"]		= {'Fascistic Military Dictatorships', 'Fascistic Military Dictatorship'}, ["federal republic"]					= {'Federal Republics', 'Federal Republic'}, ["federation"]							= {'Federations', 'Federation'}, ["feudal"]								= {'Feudal Governments', 'Feudal Government'}, ["feudal government"]					= {'Feudal Governments', 'Feudal Government'}, ["feudalism"]							= {'Feudal Governments', 'Feudal Government'}, ["hereditary monarchy"]					= {'Hereditary Monarchies', 'Hereditary Monarchy'}, ["hivelike"]							= {'Hivelike Governments', 'Hivelike Government'}, ["hivelike matriarchy"]					= {'Hivelike Matriarchies', 'Hivelike Matriarchy'}, ["empire"]								= {'Imperial Governments', 'Imperial Government'}, ["imperial"]							= {'Imperial Governments', 'Imperial Government'}, ["imperial government"]					= {'Imperial Governments', 'Imperial Government'}, ["imperial technocracy"]				= {'Imperial Technocracies', 'Imperial Technocracy'}, ["islamic republic"]					= {'Islamic Republics', 'Islamic Republic'}, ["laissez-faire democracy"]				= {'Laissez-Faire Democracies', 'Laissez-Faire Democracy'}, ["limited monarchy"]					= {'Limited Monarchies', 'Limited Monarchy'}, ["matriarchal feudal government"]		= {'Matriarchal Feudal Governments', 'Matriarchal Feudal Government'}, ["matriarchal monarchy"]				= {'Matriarchal Monarchies', 'Matriarchal Monarchy'}, ["militaristic"]						= {'Militaristic Governments', 'Militaristic'}, ["military dictatorship"]				= {'Military Dictatorships', 'Military Dictatorship'}, ["military technocratic dictatorship"]	= {'Military-Technocratic Dictatorships', 'Military-Technocratic Dictatorship'}, ["monarchistic government"]				= {'Monarchistic Governments', 'Monarchistic Government'}, ["monarchistic republic"]				= {'Monarchistic Republics', 'Monarchistic Republic'}, ["monarchy"]							= {'Monarchies', 'Monarchy'}, ["oligarchy"]							= {'Oligarchies', 'Oligarchy'}, ["parliamentary democracy"]				= {'Parliamentary Democracies', 'Parliamentary Democracy'}, ["parliamentary monarchy"]				= {'Parliamentary Monarchies', 'Parliamentary Monarchy'}, ["parliamentary republic"]				= {'Parliamentary Republics', 'Parliamentary Republic'}, ["principality"]						= {'Principalities (Government)', 'Principality'}, ["protectorate"]						= {'Protectorates', 'Protectorate'}, ["republic"]							= {'Republics', 'Republic'}, ["republican parliamentary democracy"]	= {'Republican Parliamentary Democracies', 'Republican Parliamentary Democracy'}, ["socialist"]							= {'Socialist Republics', 'Socialist Republic'}, ["socialist republic"]					= {'Socialist Republics', 'Socialist Republic'}, ["technocracy"]							= {'Technocracies', 'Technocracy'}, ["technocratic"]						= {'Technocracies', 'Technocracy'}, ["technocratic dictatorship"]			= {'Technocracic Dictatorships', 'Technocracic Dictatorship'}, ["technocratic socialist republic"]		= {'Technocratic Socialist Republics', 'Technocratic Socialist Republic'}, ["theocracy"]							= {'Theocracies', 'Theocracy'}, ["theocratic monarchies"]				= {'Theocratic Monarchies', 'Theocratic Monarchy'}, ["theocratic monarchy"]					= {'Theocratic Monarchies', 'Theocratic Monarchy'}, ["tribe"]								= {'Tribal Councils', 'Tribal Council'}, ["tribal"]								= {'Tribal Councils', 'Tribal Council'}, ["tribal council"]						= {'Tribal Councils', 'Tribal Council'}, ["totalitarian"]						= {'Totalitarian Governments', 'Totalitarian Government'}, ["totalitarian dictatorship"]			= {'Totalitarian Dictatorships', 'Totalitarian Dictatorship'}, ["totalitarian republic "]				= {'Totalitarian Republics', 'Totalitarian Republic'}, ["utopia"]								= {'Utopias (Governments)', 'Utopia'}, ["utopia (government)"]					= {'Utopias (Governments)', 'Utopia'}, ["utopian government"]					= {'Utopias (Governments)', 'Utopia'}, }	local args = getArgs (frame) local value = args.Government local value2 = args.Government2 local info local category = '' local output = '' if not h.isempty(value) then info = list[string.lower(value)] if info ~= nil then category = h.Category(info[1]) output = h.LinkToCategory(info[1], info[2]) else output = value end end if not h.isempty(value2) then output = output..' '..value2 end return output..category end

-- function p.get_status(frame) local pagename = mw.title.getCurrentTitle.text local args = getArgs (frame) local value = '' local location_type = 'Locations' local i	local category = '' local output = ''

for i = 1, #field_names do		value = args[field_names[i]] if not h.isempty(value) and value == pagename then location_type = list2[i] end end

value = args.Status if not h.isempty(value) then if string.lower(value) == 'defunct' then category = 'Defunct '..location_type output = h.LinkToCategory(category, 'Defunct') elseif string.lower(value) == 'destroyed' then category = 'Destroyed '..location_type output = h.LinkToCategory(category, 'Destroyed') else output = value end if category ~= '' then category = h.Category(category) end end return output..category end

-- function p.get_location_details(frame) local pagename = mw.title.getCurrentTitle.text local args = getArgs (frame) local location_type = args[1] local value = args[location_type] local value2 = args[location_type..'2'] local i	local category = '' local output = ''

if not h.isempty(value) then if value == pagename then for i = 1, #field_names do						if location_type == field_names[i] then category = h.Category(list2[i]) end end else if location_type == 'Country' and h.in_list({'USA', 'US', 'United States', 'U.S.A.', 'America', 'United States Of America'}, value) then value = 'United States of America' end category = h.Category(value) if h.exists(value) then output = h.Link(value, string.gsub(value, ' %(State%)', '')) elseif h.exists('Category:'..value) then output = h.LinkToCategory(value, string.gsub(value, ' %(State%)', '')) else output = h.Link(value, string.gsub(value, ' %(State%)', '')) end end end if not h.isempty(value2) then output = output..' '..value2 end return output..category end

return p