Jump to content

Module:Autoname/data

Permanently protected module
From Wikipedia, the free encyclopedia
local cfg = mw.loadData ('Module:Citation/CS1/Configuration');


--[[--------------------------< B A S E _ P A R A M E T E R S >------------------------------------------------
]]

local param_alias_keys_t = {													-- These values represent keys in the [[Module:Citation/CS1/Configuration]] aliases table
	['author']			= 'AuthorList-Last',
	['contributor']		= 'ContributorList-Last',
	['editor']			= 'EditorList-Last',
	['periodical']		= 'Periodical',
	['encyclopedia']	= 'Encyclopedia',
	['title'] 			= 'Title',
	['booktitle'] 		= 'BookTitle',											--{{cite conference}} only
	['url']				= 'URL'
	};

local params_order_t = {														-- the order to evaluate non-enumerated parameters; also order to evaluate params for final rendering
	'contributor',																-- contributors are always first
	'author',
	'editor',
	'periodical',
	'encyclopedia',
	'title',
	'booktitle',																-- {{cite conference}} only
	'url'																		-- url is always last
	};


--[[--------------------------< E N U M E R A T E D _ N A M E L I S T _ P A R A M E T E R S >------------------
]]


local enum_param_alias_keys_t = {												-- These values represent keys in the [[Module:Citation/CS1/Configuration]] aliases table
	['author']			= 'AuthorList-Last',
	['contributor']		= 'ContributorList-Last',
	['editor']			= 'EditorList-Last',
	}								

local enum_params_order_t = {													-- the order to evaluate enumerated parameters
	'contributor',																-- contributors are always first
	'author',
	'editor'
	};


--[[--------------------------< F E T C H   P A R A M E T E R   A L I A S E S >--------------------------------
]]

local params_t = {};															-- sequences to hold the various name parameter values
local enum_params_t = {};

for k,v in pairs (param_alias_keys_t) do										-- fetch parameter names and aliases in /data from [[Module:Citation/CS1/Configuration]]
	params_t[k] = {}
	if type(cfg.aliases[v]) == 'table' then
		for _, alias in ipairs (cfg.aliases[v]) do
			params_t[k][alias:gsub('#', '')] = true
		end	
	else
		params_t[k][cfg.aliases[v]:gsub('#', '')] = true
	end
end

for k,v in pairs (enum_param_alias_keys_t) do
	enum_params_t[k] = {}
	if type(cfg.aliases[v]) == 'table' then
		for _, alias in ipairs (cfg.aliases[v]) do
			 enum_params_t[k][alias] = true
		end	
	else
		 enum_params_t[k][cfg.aliases[v]] = true
	end
end


--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]

return {
	params_t = params_t,
	enum_params_t = enum_params_t,
	
	params_order_t = params_order_t,
	enum_params_order_t = enum_params_order_t,
}