توضیحات این پودمان می‌تواند در پودمان:InfoboxPerson/توضیحات قرار گیرد.

local p = {}

--==================================================
-- Module:InfoboxPerson
-- Version: Base Person Infobox
-- Part 1
-- Core / Arguments / Aliases
--==================================================

local html = mw.html


----------------------------------------------------
-- NORMALIZE
----------------------------------------------------

local function normalize(value)

	if value == nil then
		return nil
	end


	value = tostring(value)

	value = mw.text.trim(value)


	if value == "" then
		return nil
	end


	-- حذف نیم‌فاصله و کاراکترهای نامرئی
	value = mw.ustring.gsub(
		value,
		"[\u200C\u200D\uFEFF]",
		""
	)


	return value

end



----------------------------------------------------
-- COLLECT ARGUMENTS
----------------------------------------------------

local function collectArgs(frame)

	local args = {}


	local function read(tbl)

		if not tbl then
			return
		end


		for key, value in pairs(tbl) do

			local k = normalize(key)
			local v = normalize(value)


			if k and v then
				args[k] = v
			end

		end

	end



	local parent = frame:getParent()


	if parent then
		read(parent.args)
	end


	read(frame.args)


	return args

end



----------------------------------------------------
-- ARGUMENT ALIASES
----------------------------------------------------

local aliases = {


	-- عنوان اصلی

	name = {

		"نام",
		"نام شخص",
		"name"

	},



	-- تصویر

	image = {

		"تصویر",
		"پرونده",
		"image",
		"photo"

	},



	caption = {

		"توضیح تصویر",
		"زیرنویس",
		"caption"

	},



	-- اطلاعات هویتی

	fullname = {

		"نام کامل",
		"نام اصلی",
		"fullname",
		"full_name"

	},



	birth_name = {

		"نام تولد",
		"نام زمان تولد",
		"birth_name"

	},



	birth_date = {

		"زادروز",
		"تاریخ تولد",
		"birth_date",
		"date_of_birth"

	},



	birth_place = {

		"زادگاه",
		"محل تولد",
		"birth_place",
		"place_of_birth"

	},



	death_date = {

		"درگذشته",
		"تاریخ درگذشت",
		"death_date",
		"date_of_death"

	},



	death_place = {

		"محل درگذشت",
		"death_place"

	},



	nationality = {

		"ملیت",
		"nationality"

	},



	citizenship = {

		"تابعیت",
		"citizenship"

	},



	-- زندگی حرفه‌ای

	occupation = {

		"پیشه",
		"شغل",
		"occupation"

	},



	field = {

		"زمینه فعالیت",
		"حوزه فعالیت",
		"رشته",
		"field"

	},



	years_active = {

		"سال‌های فعالیت",
		"دوره فعالیت",
		"years_active"

	},



	education = {

		"تحصیلات",
		"education"

	}

}
--==================================================
-- RESOLVE ARGUMENTS
--==================================================

local function resolveArgs(args)

	local result = {}


	for key, list in pairs(aliases) do


		for i = 1, #list do

			local value = args[list[i]]


			if value then

				result[key] = value
				break

			end

		end

	end


	return result

end



----------------------------------------------------
-- VALUE CHECK
----------------------------------------------------

local function hasValue(value)

	return normalize(value) ~= nil

end



----------------------------------------------------
-- CREATE INFOBOX
----------------------------------------------------

local function createBox()

	local box = html.create("table")


	box
		:addClass("infobox")
		:addClass("person-infobox")


	return box

end



----------------------------------------------------
-- ADD TITLE
----------------------------------------------------

local function addTitle(box, args)


	local title = args.name


	if not title then

		title = mw.title.getCurrentTitle().text

	end



	local row = box:tag("tr")


	row
		:tag("th")
		:attr("colspan", "2")
		:css({

			["background-color"] = "#2C5F9E",
			color = "#FFFFFF",
			["text-align"] = "center",
			["font-size"] = "120%",
			padding = "8px"

		})
		:wikitext(title)


end



----------------------------------------------------
-- ADD IMAGE
----------------------------------------------------

local function addImage(box, args)


	if not hasValue(args.image) then

		return

	end



	local row = box:tag("tr")



	row
		:tag("td")
		:attr("colspan", "2")
		:css({

			["text-align"] = "center",
			padding = "5px"

		})
		:wikitext(

			"[[File:" ..
			args.image ..
			"|250px]]"

		)




	if hasValue(args.caption) then


		local caption = box:tag("tr")


		caption
			:tag("td")
			:attr("colspan", "2")
			:css({

				["text-align"] = "center",
				["font-size"] = "90%"

			})
			:wikitext(args.caption)


	end


end



----------------------------------------------------
-- ADD SECTION HEADER
----------------------------------------------------

local function addHeader(box, text)


	local row = box:tag("tr")


	row
		:tag("th")
		:attr("colspan", "2")
		:css({

			["background-color"] = "#2C5F9E",
			color = "#FFFFFF",
			["text-align"] = "center"

		})
		:wikitext(text)


end



----------------------------------------------------
-- ADD ROW
----------------------------------------------------

local function addRow(box, label, value)


	if not hasValue(value) then

		return false

	end



	local row = box:tag("tr")



	row
		:tag("th")
		:wikitext(label)



	row
		:tag("td")
		:wikitext(value)



	return true

end
--==================================================
-- PERSONAL INFORMATION SECTION
--==================================================

local function addPersonal(box, args)


	local hasData = false


	if hasValue(args.fullname)
	or hasValue(args.birth_name)
	or hasValue(args.birth_date)
	or hasValue(args.birth_place)
	or hasValue(args.death_date)
	or hasValue(args.death_place)
	or hasValue(args.nationality)
	or hasValue(args.citizenship) then


		hasData = true

	end



	if not hasData then

		return

	end



	addHeader(
		box,
		"اطلاعات شخصی"
	)



	addRow(
		box,
		"نام کامل",
		args.fullname
	)


	addRow(
		box,
		"نام تولد",
		args.birth_name
	)


	addRow(
		box,
		"زاده",
		args.birth_date
	)


	addRow(
		box,
		"زادگاه",
		args.birth_place
	)


	addRow(
		box,
		"درگذشته",
		args.death_date
	)


	addRow(
		box,
		"محل درگذشت",
		args.death_place
	)


	addRow(
		box,
		"ملیت",
		args.nationality
	)


	addRow(
		box,
		"تابعیت",
		args.citizenship
	)


end



--==================================================
-- CAREER INFORMATION SECTION
--==================================================

local function addCareer(box, args)


	local hasData = false


	if hasValue(args.occupation)
	or hasValue(args.field)
	or hasValue(args.years_active)
	or hasValue(args.education) then


		hasData = true

	end



	if not hasData then

		return

	end



	addHeader(
		box,
		"زندگی و فعالیت"
	)



	addRow(
		box,
		"پیشه",
		args.occupation
	)


	addRow(
		box,
		"زمینه فعالیت",
		args.field
	)


	addRow(
		box,
		"سال‌های فعالیت",
		args.years_active
	)


	addRow(
		box,
		"تحصیلات",
		args.education
	)


end



--==================================================
-- RENDER
--==================================================

local function render(args)


	local box = createBox()



	addTitle(
		box,
		args
	)



	addImage(
		box,
		args
	)



	addPersonal(
		box,
		args
	)



	addCareer(
		box,
		args
	)



	return tostring(box)

end



--==================================================
-- ENTRY POINT
--==================================================

function p.main(frame)


	local rawArgs = collectArgs(frame)



	local args = resolveArgs(rawArgs)



	return render(args)

end



return p