Marvel Wiki
Advertisement

Bu modül için bir Modül:Category Message Templates/belge belgelendirmesi oluşturabilirsiniz

-- module for message template placed in categories
local p = {}
local h = require("Modül:HF")
local design = require('Modül:Design')
local getArgs = require('Dev:Arguments').getArgs
local g_list_of_months = {'Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'}

function p.test()
	local basepagename = mw.title.getCurrentTitle().baseText
	local subpagename = mw.title.getCurrentTitle().subpageText
	local root = mw.title.getCurrentTitle().rootText
	local full = mw.title.getCurrentTitle().fullText
	local prefixed = mw.title.getCurrentTitle().prefixedText
	local text = mw.title.getCurrentTitle().text
	
	return 'base='..basepagename..'<br>subpage='..subpagename..'<br>root='..root..'<br>prefixed='..prefixed..'<br>full='..full..'<br>text='..text
end


--------------------------------------------------------------------------------
-- work-in-progress
function p.appearance_tags(pagename)
	local function add_links_from_list(list)
		local i
		local value
		local output = {}
		
		for i = 1, #list do
			value = list[i]
			value = h.Link('Şablon:'..value, value)
			table.insert(output, value)
		end
		
		return p.lua_add_navigation(output)
	end
	--local pagename = mw.title.getCurrentTitle().text
	local list = {}
	local death_destruction = {'ApDeath', 'Death', 'Deceased', 'Destruction', 'Destroyed', 'Only Dies', 'Only Destruction', 'Corpse', 'Ruins', 'Grave'}
	local message = ''
	local header = ''
	local help = ''
	local code = ''
	local output_categories = {}
	local output = ''
	
	if h.in_list(death_destruction, pagename)
		then 
			header = design.span('An appearance tag indicating what character clearly died.').bold
			help = add_links_from_list(death_destruction)
			message = design.messagebox({header..help}) 
			
			code = '<pre>{{'..pagename..'|[[subject_name]]}} or {{'..pagename..'}}</pre> Where <code>subject_name</code> is page name of the subject that appears in this medium (comic issue, episode, movie, game, novel, etc.). Parameter can be omitted when another appearance tag was already used with link and this one is added to indicate additional information.'
			code = code..'\nThis is a '..h.LinkToCategory('Major Appearance Templates', design.span('major appearance template').bold)
			code = code..'.If used with parameter it would add page into <code>Category:subject_name/Appearances</code>.'
			code = code.." If subject's appearance is actually "..h.LinkToCategory('Minor Appearance Templates', design.span('minor').bold)
			code = code..', then use '..h.Link('Şablon:Minor', 'Şablon:Minor')..' and this template without parameter (<pre>{{Minor|[[subject_name]]}} {{'..pagename..'}}</pre>'
			code = design.add_section('Code', code, 2)
			
			output = message..code
	end
	
	return output..h.add_categories(output_categories)
end



--------------------------------------------------------------------------------
-- used in Şablon:Cover Date Category
function p.cover_date_category(frame)
	local function get_months(year)
		local i
		local category
		local link
		local output = {}
		for i = 1, 12 do
			category = year..', '..g_list_of_months[i]..' bitim tarihi'
			link = string.sub(g_list_of_months[i], 1, 3)
			table.insert(output, p.lua_add_navigation_link(category, link, 'pages'))
		end
		
		output = p.lua_add_navigation(output, '  ')
		output = mw.html.create('div'):css('display', 'flex'):css('flex-wrap', 'wrap'):css('justify-content' , 'center'):wikitext(output)
		
		return tostring(output)
	end
	local pagename = mw.title.getCurrentTitle().text
	local year
	local previous_year = ''
	local next_year = ''
	local month
	local month_number = ''
	local headers = {}
	local message = ''
	local dpl_string = ''
	local gallery = {}
	local image
	local link 
	local output_categories = {}
	local output = ''

	year, month = string.match(pagename, '(%d%d%d%d), (.+) bitim tarihi')
	if year ~= nil
		then
			for i = 1, 12 do
				if g_list_of_months[i] == month
					then month_number = ' '..h.AddZeros(i, 2)
				end
			end
			
			table.insert(output_categories, {year..', '..month, 'bitim tarihi'})
			table.insert(output_categories, {year..' bitim tarihi', month_number})

			dpl_string = '{{#dpl:|category = '..pagename..'|notnamespace = Category|mode = userformat|ordermethod = title|allowcachedresults = true'
			dpl_string = dpl_string..'|includepage = {Marvel Wiki:Çizgi roman şablonu}:Image1|secseparators = %TITLE%~,@@@}}'
			dpl_string = frame:preprocess(dpl_string)
			dpl_string = h.explode('@@@', dpl_string)
			for i = 1, #dpl_string do
				link = mw.text.split(dpl_string[i], '~', true)
				image = link[2]
				link = require('Modül:StandardizedName').lua_get_title_volume_issue(link[1], 'Vol').link.all
				table.insert(gallery, '\n'..image..'{{!}}'..link)
			end

			gallery = table.concat(gallery)
			gallery = frame:preprocess('{{#tag:gallery|'..gallery..'|position=center|captionalign=center|widths=200px}}')
			gallery = design.show_hide({header = 'Gallery of comic issues', body = gallery})

			if h.pages_in_category((year-1)..' bitim tarihi', 'all') > 0
				then table.insert(headers, h.LinkToCategory((year-1)..' bitim tarihi', (year-1) ) )
				else table.insert(headers, (year-1) )
			end
			table.insert(headers, 'Comic issues with bitim tarihi of '..month..' of '..h.LinkToCategory(year..' bitim tarihi', year))
			if h.pages_in_category((year+1)..' bitim tarihi', 'all') > 0
				then table.insert(headers, h.LinkToCategory((year+1)..' bitim tarihi', (year+1) ) )
				else table.insert(headers, (year+1) )
			end
			for i = 1, 3 do
				headers[i] = tostring( mw.html.create('div'):css('font-weight', 'bold'):wikitext(headers[i]) )
			end
			headers = table.concat(headers)
			
			previous_year = get_months(year-1)
			next_year = get_months(year+1)
			year = get_months(year)
			message = mw.html.create('div'):css('display', 'grid'):css('grid-template-columns', '1fr 1fr 1fr'):wikitext(headers..previous_year..year..next_year)
			message = tostring(message)
			output = design.messagebox({message})..gallery
		else
			year = string.match(pagename, '(%d%d%d%d) bitim tarihi')
			if year ~= nil
				then
					table.insert(output_categories, {year, 'bitim tarihi'})
					
					header = design.span('Comic issues with '..year..' year in bitim tarihi.').bold
					message = {}
					for i = 1939, tonumber(mw.language.new('tr'):formatDate('Y')) + 1 do
						table.insert(message, h.LinkToCategory(i..' bitim tarihi', i) )
					end
					message = p.lua_add_navigation(message, '  ')
					output = design.messagebox({ header..message})
			end
	end
	
	return output..h.add_categories(output_categories)
end

--------------------------------------------------------------------------------
-- used in Template:Cover Date Category
function p.cover_date_category(frame)
	local function get_months(year)
		local i
		local category
		local link
		local output = {}
		for i = 1, 12 do
			category = year..', '..g_list_of_months[i]..' bitim tarihi'
			link = string.sub(g_list_of_months[i], 1, 3)
			table.insert(output, p.lua_add_navigation_link(category, link, 'pages'))
		end

		output = p.lua_add_navigation(output, '  ')
		output = mw.html.create('div'):css('display', 'flex'):css('flex-wrap', 'wrap'):css('justify-content' , 'center'):wikitext(output)

		return tostring(output)
	end
	local pagename = mw.title.getCurrentTitle().text
	local year
	local previous_year = ''
	local next_year = ''
	local month
	local month_number = ''
	local headers = {}
	local message = ''
	local dpl_string = ''
	local gallery = {}
	local image
	local link
	local output_categories = {}
	local output = ''

	year, month = string.match(pagename, '(%d%d%d%d), (.+) bitim tarihi')
	if year ~= nil
		then
			for i = 1, 12 do
				if g_list_of_months[i] == month
					then month_number = ' '..h.AddZeros(i, 2)
				end
			end

			table.insert(output_categories, {year..', '..month, 'bitim tarihi'})
			table.insert(output_categories, {year..' bitim tarihi', month_number})

			dpl_string = '{{#dpl:|category = '..pagename..'|notnamespace = Category|mode = userformat|ordermethod = title|allowcachedresults = true'
			dpl_string = dpl_string..'|includepage = {Marvel Wiki:Çizgi roman şablonu}:Image1|secseparators = %TITLE%~,@@@}}'
			dpl_string = frame:preprocess(dpl_string)
			dpl_string = h.explode('@@@', dpl_string)
			for i = 1, #dpl_string do
				link = mw.text.split(dpl_string[i], '~', true)
				image = link[2]
				link = require('Module:StandardizedName').lua_get_title_volume_issue(link[1], 'Vol').link.all
				table.insert(gallery, '\n'..image..'{{!}}'..link)
			end

			gallery = table.concat(gallery)
			gallery = frame:preprocess('{{#tag:gallery|'..gallery..'|position=center|captionalign=center|widths=200px}}')
			gallery = design.show_hide({header = 'Çizgi roman sayılarının galerisi', body = gallery})

			if h.pages_in_category((year-1)..' bitim tarihi', 'all') > 0
				then table.insert(headers, h.LinkToCategory((year-1)..' bitim tarihi', (year-1) ) )
				else table.insert(headers, (year-1) )
			end
			table.insert(headers, 'Comic issues with bitim tarihi of '..month..' of '..h.LinkToCategory(year..' bitim tarihi', year))
			if h.pages_in_category((year+1)..' bitim tarihi', 'all') > 0
				then table.insert(headers, h.LinkToCategory((year+1)..' bitim tarihi', (year+1) ) )
				else table.insert(headers, (year+1) )
			end
			for i = 1, 3 do
				headers[i] = tostring( mw.html.create('div'):css('font-weight', 'bold'):wikitext(headers[i]) )
			end
			headers = table.concat(headers)

			previous_year = get_months(year-1)
			next_year = get_months(year+1)
			year = get_months(year)
			message = mw.html.create('div'):css('display', 'grid'):css('grid-template-columns', '1fr 1fr 1fr'):wikitext(headers..previous_year..year..next_year)
			message = tostring(message)
			output = design.messagebox({message})..gallery
		else
			year = string.match(pagename, '(%d%d%d%d) bitim tarihi')
			if year ~= nil
				then
					table.insert(output_categories, {year, 'bitim tarihi'})

					header = design.span('Comic issues with '..year..' year in bitim tarihi.').bold
					message = {}
					for i = 1939, tonumber(mw.language.new('tr'):formatDate('Y')) + 1 do
						table.insert(message, h.LinkToCategory(i..' bitim tarihi', i) )
					end
					message = p.lua_add_navigation(message, '  ')
					output = design.messagebox({ header..message})
			end
	end

	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Month Category
function p.month_category(frame)
	local pagename = mw.title.getCurrentTitle().text
	local i 
	local year
	local month	
	local month_number = ''
	local navigation_months = {}
	local output_categories = {}
	local output = ''
	
	year, month = string.match(pagename, '(%d%d%d%d), (.+)')
	if year ~= nil
		then
			output = design.span(month..', '..h.LinkToCategory(year, year)..' tarihinde gerçekleşen çeşitli olayların listesi.').bold
			for i = 1, 12 do
				month = g_list_of_months[i]
				table.insert(navigation_months, p.lua_add_navigation_link(year..', '..month, month, 'all') )
			end
			navigation_months = p.lua_add_navigation(navigation_months)
			output = design.messagebox({ output..navigation_months })
			
			for i = 1, 12 do
				if g_list_of_months[i] == month
					then month_number = ' '..h.AddZeros(i, 2)
				end
			end
			table.insert(output_categories, {year, month_number})
	end
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Year Category
function p.year_category(frame)
	local i 
	local current_year = tonumber(mw.language.new('tr'):formatDate('Y'))
	local check_years = {1800,1801,1803,1804,1805,1806,1807,1808,1809,1811,1812,1813,1815,1816,1817,1818,1821,1822,1823,1825,1826,1827,1829,1830,1831,1833,1834,1836,1837,1838,1839,1840,1841,1843,1844,1845,1846,1848,1849,1852,1853,1854,1855,1858,1860,1861,1862,1863,1864,1865,1867,1868,1872,1873,1874,1876,1877,1879,1881,1882,1883,1886}
	local include_years = {1660,1667,1731,1745,1771,1789}
	local output = {}
	
	for i = 1660, 1799 do
		if h.in_list(include_years, i)
			then table.insert(output, h.LinkToCategory(i, i))
			else table.insert(output, p.nonexistent_page(i))
		end
	end
	
	for i = 1800, 1886 do
		if h.in_list(check_years, i)
			then table.insert(output, p.lua_add_navigation_link(i, i, 'all'))
			else table.insert(output, h.LinkToCategory(i, i))
		end
	end
	
	for i = 1887, current_year do
		table.insert(output, h.LinkToCategory(i, i))
	end
	
	current_year = current_year + 1
	if h.pages_in_category(current_year, 'all') > 0
		then table.insert(output, h.LinkToCategory(current_year, current_year))
	end
	
	output = mw.text.listToText(output, ' ', ' ')
	output = design.messagebox({ mesaj=output, extrastyle="font-family: monospace;" })
	
	return output..h.Category('Yıllar')
end


--------------------------------------------------------------------------------
-- used in Şablon:Marvel Staff Dates of Birth or Death Category
function p.marvel_staff_dates_of_birth_or_death_category(frame)
	local pagename = mw.title.getCurrentTitle().text
	local i
	local value
	local year
	local month
	local month_number = ''
	local navigation_months = {}
	local navigation_birth_death = {}
	local output_categories = {}
	local output = ''
	
	year, month = string.match(pagename, 'Born in (%d%d%d%d), (.+)')
	if year ~= nil
		then
			month_number = require('Modül:Date').get_month_number({month})
			month_number = ' '..h.AddZeros(month_number, 2)
			table.insert(output_categories, {'Born in '..year, month_number} )
			if h.exists('Category:'..year..', '..month)
				then 
					table.insert(output_categories, year..', '..month)
					month = h.LinkToCategory(year..', '..month, month)
			end

			output = 'Members of Marvel staff who were born in '..month..' of '..h.LinkToCategory(year, year)..'.'
			output = design.span(output).bold

			for i = 1, 12 do
				month = p.lua_add_navigation_link('Born in '..year..', '..g_list_of_months[i], g_list_of_months[i], 'pages')
				table.insert(navigation_months, month)
			end
			navigation_months = p.lua_add_navigation(navigation_months)

			output = design.messagebox({ output..navigation_months })
		else
			value, year = string.match(pagename, '(.+) in (%d%d%d%d)')
			if year ~= nil and h.in_list({'Born', 'Died'}, value)
				then
					navigation_birth_death = p.lua_add_year_of_birth_death_navigation(year)
					
					if value == 'Born'
						then
							table.insert(output_categories, {'Marvel Staff by Year of Birth', year})
							output = 'Members of Marvel staff who were born in '..h.LinkToCategory(year, year)..'.'
						else
							table.insert(output_categories, {'Marvel Staff by Year of Death', year})
							output = 'Members of Marvel staff who died in '..h.LinkToCategory(year, year)..'.'
					end
					table.insert(output_categories, year)
					output = design.span(output).bold
					output = design.messagebox({ output..navigation_birth_death })
			end
	end
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Nationality Category
function p.nationality_category(frame)
	local function get_flag_image(nation, frame)
		local output = ''
		local dpl_string = '{{#dpl:|titlematch = Flag of '..nation..'%|namespace = File|format = ,%TITLE%,|count = 1|noresultsheader = no_results}}'
		dpl_string = frame:preprocess(dpl_string)
		if dpl_string  ~= 'no_results'
			then output = '[[File:'..dpl_string..'|130px]]'
		end
		return output
	end
	local citizenship = require("Modül:Citizenship")
	local pagename = mw.title.getCurrentTitle().text
	local args = getArgs(frame)
	local name = args[1]
	local n = h.pages_in_category(pagename, 'pages')
	local flag = ''
	local nation = ''
	local header = ''
	local help = ''
	local navigation = ''
	local output_categories = {}
	local output = ''

	if not h.isempty(name)
		then name = mw.text.trim(name)
		else 
			name = pagename
			name = string.gsub(name, ' Staff Members', '')
	end
	
	nation = citizenship.countries[name]
	if nation == nil
		then
			if string.find(name, "ians") 
				then nation = mw.ustring.sub(name, 0, -5)
				else nation = mw.ustring.sub(name, 0, -3)
			end
	end

	if not h.isempty(nation)
		then 
			if string.find(pagename, ' Staff Members') == nil
				then
					header = 'List of characters who are from '
					help = "If you find character in the database that is not shown here, please edit their page and add "
					table.insert(output_categories, 'Characters by Nationality')
					if h.pages_in_category(nation, 'all') > 0
						then table.insert(output_categories, nation)
					end
					table.insert(output_categories, args[2])
					table.insert(output_categories, args[3])
				else 
					header = 'List of staff members of Marvel who are from '
					help = "If you find person in the database that is not shown here, please edit their page and add "
					table.insert(output_categories, 'Marvel Staff Members by Nationality')
					if h.pages_in_category(nation, 'all') > 0
						then table.insert(output_categories, nation)
					end
			end
			
			navigation = p.lua_add_nation_navigation(name)

			flag = get_flag_image(nation, frame)
			flag = tostring( mw.html.create('div'):wikitext(flag) )
			
			if n >=500 
				then n = frame:expandTemplate{title = 'CategoryTOC'}
				else n = ''
			end
			
			header = header..h.Link(nation, nation)..'.'
			header = design.span(header).bold
			
			help = help..'"'..nation..'"'..' into <code>Citizenship</code> field.'
			help = p.add_help(help)

			output = tostring( mw.html.create('div'):wikitext(header..help..navigation) )
			output = mw.html.create('div'):css('display', 'grid'):css('grid-template-columns', '140px 1fr'):wikitext(flag..output)
			output = tostring(output)
			output = design.messagebox({output})..n
	end

	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Hafta Category
function p.week_of_release_category(frame)
	local m_date = require('Modül:Date')
	local function week_category(date_info)
		local week_number = h.AddZeros(date_info.week_number, 2)
		local category = 'Hafta '..week_number..', '..date_info.year
		local value = h.AddZeros(date_info.day, 2)..' (H'..week_number..')'
		
		if date_info.week_number == 1 and date_info.month == 'Aralık'
			then value = 'Ara '..value
		end
		
		return p.lua_add_navigation_link(category, value)
	end
	local function month_of_release(month_number, year)
		local month_name = m_date.get_month_name({month_number})
		local category = 'Çizgi romanlar '..month_name..', '..year
		local value = string.sub(month_name, 1, 3)..', '..year
		local output = p.lua_add_navigation_link(category, value, 'all')
		return tostring( mw.html.create('td'):wikitext(output) )
	end
	local pagename = mw.title.getCurrentTitle().text
	local week_number = ''
	local week_year = ''
	local year = ''
	local month = ''
	local day = ''
	local last_week_in_year = 52
	local i
	local j
	local category
	local value
	local date_from_week_number
	local navigation_weeks = {}
	local navigation_weeks_headers = {}
	local navigation_weeks_temp1 = {}
	local navigation_weeks_temp2 = {}
	local date_info = {}
	local tag_table = mw.html.create('table'):css('width', '100%'):css('font-family', 'monospace'):css('font-size', '80%'):css('text-align', 'center')
	local tag_tr1 = mw.html.create('tr'):css('font-weight', 'bold')
	local tag_tr2 = mw.html.create('tr'):css('vertical-align', 'top')
	local output_categories = {}
	local output = ''

	if string.find(pagename, 'Hafta') ~= nil
		then
			week_number, week_year = string.match(pagename, 'Hafta (.+), (.+)')
			date_from_week_number = m_date.lua_get_date_from_week_number(tonumber(week_number), week_year)
			month, day, year = string.match(date_from_week_number, '(.+) (.+), (%d+)')
			category = 'Çizgi romanlar '..month..', '..year
			table.insert(output_categories, category)
			output = h.LinkToCategory(category, date_from_week_number)..' tarihinde çıkan çizgi romanlar.'
		elseif string.find(pagename, 'Çizgi romanlar') ~= nil
			then
				month, week_year = string.match(pagename, 'Çizgi romanlar (.+), (.+)')
				category = week_year..', '..month
				table.insert(output_categories, category)
				output = 'Çizgi romanlar '..h.LinkToCategory(category, month..', '..week_year)..'.'
	end
	
	-- previous/next years and links to  month of release categories
	table.insert( navigation_weeks_headers, tostring( mw.html.create('td'):css('font-size', '90%'):wikitext(week_year-1) ))
	for i = 1, 12 do
		table.insert( navigation_weeks_headers, month_of_release(i, week_year) )
	end
	table.insert( navigation_weeks_headers, tostring( mw.html.create('td'):css('font-size', '90%'):wikitext(week_year+1) ))
	navigation_weeks_headers = table.concat(navigation_weeks_headers)
	tag_tr1 = tostring( tag_tr1:wikitext(navigation_weeks_headers) )

	-- adding links to months of the previous year
	for i = 1, 12 do
		month = m_date.get_month_name({i})
		category = 'Çizgi romanlar '..month..', '..(week_year-1)
		value = string.sub(month, 1, 3)
		table.insert(navigation_weeks_temp2, p.lua_add_navigation_link(category, value, 'subcats'))
	end
	value = mw.text.listToText(navigation_weeks_temp2, ' ', ' ')
	value = tostring( mw.html.create('td'):css('width', '5%'):css('font-size', '90%'):wikitext(value) )
	table.insert(navigation_weeks, value)
	navigation_weeks_temp2 = {}

	-- adding weeks of the current year
	last_week_in_year = m_date.lua_get_last_week_of_year2(week_year)
	for i = 1, last_week_in_year do
		date_from_week_number = m_date.lua_get_date_from_week_number(i, week_year)
		month, day, year = string.match(date_from_week_number, '(.+) (.+), (%d+)')
		date_info = {week_number = i, year = tonumber(week_year), month = month, day = day}
		table.insert(navigation_weeks_temp1, date_info)
	end
		
	for i = 1, #navigation_weeks_temp1 do
		date_info = navigation_weeks_temp1[i]
		table.insert(navigation_weeks_temp2, week_category(date_info))
		if i == #navigation_weeks_temp1 
			or ( 
				date_info.month ~= navigation_weeks_temp1[i+1].month 
				and not (date_info.week_number == 1 and date_info.month == 'Aralık')
				)
			then 
				value = mw.text.listToText(navigation_weeks_temp2, '<br>', '<br>')
				value = tostring( mw.html.create('td'):wikitext(value) )
				table.insert(navigation_weeks, value)
				navigation_weeks_temp2 = {}
		end
	end 
	-- adding links to months of the next year
	navigation_weeks_temp2 = {}
	for i = 1, 12 do
		month = m_date.get_month_name({i})
		category = 'Çizgi romanlar '..month..', '..(week_year+1)
		value = string.sub(month, 1, 3)
		table.insert(navigation_weeks_temp2, p.lua_add_navigation_link(category, value, 'subcats'))
	end
	value = mw.text.listToText(navigation_weeks_temp2, ' ', ' ')
	value = tostring( mw.html.create('td'):css('width', '5%'):css('font-size', '90%'):wikitext(value) )
	table.insert(navigation_weeks, value)

	tag_tr2 = tostring( tag_tr2:wikitext( table.concat(navigation_weeks) ) )
		
	tag_table = tag_table:wikitext(tag_tr1..tag_tr2)
	output = design.span(output).bold..'\n----'..tostring(tag_table)

	return design.messagebox({output})..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Power Category
function p.power_category(frame)
	local list_of_powers =  mw.loadData('Modül:List of Powers')
	local pagename = mw.title.getCurrentTitle().text
	local power_description = '' 
	local power_info = {}
	local navigation = {}
	local value = ''
	local i
	local output_categories = {}
	local output = string.lower(pagename)

	table.insert(output_categories, 'Powers')
	
	power_info = list_of_powers[pagename]
	if power_info ~= nil
		then
			for i = 1, 20 do
				value = power_info.related[i]
				if not h.isempty(value)
					then table.insert( navigation, h.LinkToCategory(value, value) )
					else break
				end
			end
			navigation = p.lua_add_navigation(navigation)
			power_description = ' — '..power_info.description
			
			for i = 1, 20 do
				value = power_info.categories[i]
				if not h.isempty(value)
					then table.insert(output_categories, value)
					else break
				end
			end
	end	

	if h.exists('Glossary:'..pagename)
		then output = h.Link('Glossary:'..pagename, string.lower(pagename))
		elseif h.exists(pagename)
			then output = h.Link(pagename, string.lower(pagename))
	end
	output = design.span('Characters and items with the power of '..output..power_description..'.').bold

	return design.messagebox({output..navigation})..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Eye Category
function p.eye_category(frame)
	local function navigation_message(value)
		local list = {}
		local i
		local category
		local eye_color = ''
		local output = {}

		if string.find(value, 'No visible') ~= nil
			then list = {'No visible Irises or Pupils', 'Formerly No visible Irises or Pupils'}
			elseif string.find(value, 'No Eyes') ~= nil
				then list = {'No Eyes', 'Formerly No Eyes', 'Races with No Eyes'}
			else
				eye_color = string.match(string.gsub(value, 'Formerly ', ''), '(.+) Eye.+')
				list = {eye_color..' Eyes', 'Formerly '..eye_color..' Eyes', eye_color..' Eyeballs', 'Formerly '..eye_color..' Eyeballs', 'Races with '..eye_color..' Eyes'}
		end
		
		for i = 1, #list do
			category = list[i]
			if string.find(category, 'Races') ~= nil
				then value = category
				elseif category == 'No Eyes'
					then value = 'No Eyes At All'
				elseif category == 'Formerly No Eyes'
					then value = 'Formerly No Eyes At All'		
				else value = string.gsub(category, ' Eyes', '')
			end
			table.insert(output, p.lua_add_navigation_link(category, value) )
		end

		return output
	end
	local pagename = mw.title.getCurrentTitle().text
	local list = {}
	local navigation = ''
	local help = ''
	local value = ''
	local category = pagename
	local output_categories = {}
	local output = ''
	
	if string.find(pagename, 'Formerly ') ~= nil
		then
			category = string.match(pagename, 'Formerly (.+)')
			table.insert(output_categories, category)
			if category == 'No visible Irises or Pupils'
				then output = 'Characters whose eyes had formerly had no visible irises (pupils), but now gained color due to some reason.'
				elseif category == 'No Eyes'
					then output = 'Characters who formerly had no eyes at all, until they gained them for some reason.'
				elseif string.find(category, 'Eyeballs') ~= nil
					then
						value = string.lower( string.match(category, '(.+) Eyeballs') )
						if value == 'Variable'
							then output = 'Characters whose eyes had formerly had variable color of eyeballs (sclera); normally due to the power to change their physical appearance.'
							else output = 'Characters whose eyes had formerly had '..string.lower(value)..' color of eyeballs (sclera), but later the color changed due to some reason.'
						end
				elseif string.find(category, 'Eyes') ~= nil
					then
						value = string.lower( string.match(category, '(.+) Eyes') )
						if value == 'Variable'
							then output = 'Characters whose eyes had formerly had variable color of irises (pupils); normally due to the power to change their physical appearance.'
							else output = 'Characters whose eyes had formerly had '..string.lower(value)..' color of irises (pupils), but later the color changed due to some reason.'
						end
			end
			navigation = p.lua_add_navigation( navigation_message(pagename) )
		elseif string.find(pagename, 'Races ') ~= nil
			then
				category = string.match(pagename, 'Races with (.+)')
				if category == 'No Eyes'
					then 
						table.insert(output_categories, {'Races by Eyes', category})
						output = "Races with no eyes at all."
					else 
						table.insert(output_categories, {'Races by Eye Color', category})
						output = 'Races with '..string.lower(category)..'.'
				end
				navigation = p.lua_add_navigation( navigation_message(category) )
		elseif category == 'No visible Irises or Pupils'
			then
				output = 'Characters whose eyes do not have any visible eye irises (pupils).'
				help = 'Such eyes often have a different from norm '..h.LinkToCategory('Characters by Eyeball Color', 'coloration of eyeballs (sclera)')
				help = help..'.<br>(these characters should not be confused with '..h.LinkToCategory('No Eyes', 'characters that do not have any eyes at all')..')'
				table.insert(output_categories, 'Characters by Eyes')
				navigation = p.lua_add_navigation( navigation_message(category) )
		elseif category == 'No Eyes'
			then 
				output = "Characters who don't have any eyes at all"
				help = '(these characters should not be confused with characters who have eyes, but they '
				help = help..h.LinkToCategory('No visible Irises or Pupils', 'do not have any visible eye irises (pupils)')..')'
				table.insert(output_categories, 'Characters by Eyes')
				navigation = p.lua_add_navigation( navigation_message(category) )
		elseif string.find(pagename, 'Eyeballs') ~= nil
			then
				value = string.lower( string.match(pagename, '(.+) Eyeballs') )
				if value == 'white'
					then 
						output = 'Characters with white color of eyeballs (sclera) and '..h.LinkToCategory('No visible Irises or Pupils', 'no visible irises (pupils)')
						help = ''
					elseif value == 'variable'
						then output = 'Characters whose eyes have variable color of eyeballs (sclera); normally due to the power to change their physical appearance.'
					else 
						output = 'Characters with '..value..' color of eyeballs (sclera).'
						help = 'Often such characters '..h.LinkToCategory('No visible Irises or Pupils', 'do not have any visible eye irises (pupils)')..'.<br>'
				end	
				help = help..'(These characters should not be confused with characters who have '
				category = string.gsub(pagename, ' Eyeballs', ' Eyes')
				if h.pages_in_category(category) > 0
					then help = help..h.LinkToCategory(category, value..' color of eye irises (pupils)')..')'
					else help = help..value..' color of eye irises (pupils))'
				end
				table.insert(output_categories, 'Characters by Eyeball Color')
				navigation = p.lua_add_navigation( navigation_message(pagename) )
		else
				value = string.lower( string.match(pagename, '(.+) Eyes') )
				if value == 'variable'
					then 
						output = 'Characters whose eyes have variable color of irises (pupils); normally due to the power to change their physical appearance.'
					else 
						output = 'Characters with '..value..' color of eye irises (pupils).'
						help = '(These characters should not be confused with characters whose eyes actually have '
						category = string.gsub(pagename, ' Eyes', ' Eyeballs')
						if h.pages_in_category(category) > 0
							then help = help..h.LinkToCategory(category, value..' color of eyeballs (sclera)')
							else help = help..value..' color of eyeballs (sclera)'
						end
						help = help..' with '..h.LinkToCategory('No visible Irises or Pupils', 'no visible irises')..')'
				end
				table.insert(output_categories, 'Characters by Eye Color')
				navigation = p.lua_add_navigation( navigation_message(pagename) )
	end
	help = p.add_help(help)
	output = design.span(output).bold..help..navigation
	
	return design.messagebox({output})..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Hair Category
function p.hair_category(frame)
	local function navigation_message(hair_color)
		local list = {hair_color, 'Dyed '..hair_color, 'Formerly '..hair_color, 'Races with '..hair_color}
		local list2 = {'Shaved Hair', 'Balding', 'Bald', 'Formerly Bald', 'No Hair', 'Formerly No Hair', 'Races with No Hair'}
		local list3 = {'Variable Hair', 'Formerly Variable Hair', 'Races with Variable Hair'}
		local i
		local category
		local value
		local output = {}
		
		if hair_color ~= 'Grey-haired'
			then
				if h.in_list(list2, hair_color)
					then list = list2
					elseif string.find(hair_color, 'Variable') ~= nil
						then list = list3
				end
				for i = 1, #list do
					category = list[i]
					if string.find(category, 'Races') ~= nil
						then value = category
						elseif category == 'No Hair' or category == 'Formerly No Hair'
							then value = category..' At All'
						else value = string.gsub(category, ' Hair', '')
					end
					table.insert(output, p.lua_add_navigation_link(category, value) )
				end
		end	
		
		return output
	end
	local pagename = mw.title.getCurrentTitle().text
	local list = {}
	local help = ''
	local navigation = ''
	local value = ''
	local category = pagename
	local output_categories = {}
	local output = ''
	
	if string.find(pagename, 'Formerly ') ~= nil
		then
			category = string.match(pagename, 'Formerly (.+)')
			table.insert(output_categories, category)
			navigation = p.lua_add_navigation( navigation_message(category) )
			if category == 'No Hair'
				then 
					output = 'Characters who formerly had no hair at all, until they gained them for some reason.'
				elseif category == 'Bald'
					then output = 'Characters who formerly went bald, until they regained their hair for some reason.'
				else
					value = string.lower( string.match(category, '(.+) Hair') )
					if value == 'variable'
						then output = 'Characters who formerly had variable color of hair; normally due to the power to change their physical appearance.'
						else output = 'Characters who formerly had '..value..' color of hair, but later the color changed, they went bald, greyed or dyed hair to some other color.'
					end
			end
		elseif string.find(pagename, 'Dyed ') ~= nil
			then
				category = string.match(pagename, 'Dyed (.+)')
				table.insert(output_categories, category)
				table.insert(output_categories, {'Dyed Hair', category})
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = 'Characters who dyed their hair to '..string.lower( string.gsub(category, ' Hair', '') )..' color.'
		elseif string.find(pagename, 'Races ') ~= nil
			then
				category = string.match(pagename, 'Races with (.+)')
				navigation = p.lua_add_navigation( navigation_message(category) )
				if category == 'No Hair'
					then 
						table.insert(output_categories, {'Races by Hair', category})
						output = "Races with no hair at all on their head; for example, they can have feathers or fur instead, or be inorganic beings, etc."
					else
						value = string.lower( string.match(category, '(.+) Hair') )
						if value == 'Variable'
							then output = 'Races whose individual members normally have variable color of hair; normally due to the power to change their physical appearance.'
							else output = 'Races whose individual members normally have '..string.lower(category)..' color of hair.'
						end
						table.insert(output_categories, {'Races by Hair Color', category})
				end
		elseif category == 'Grey-haired'
			then
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = 'Characters whose hair turned grey (lost their pigmentation and melanin) due to age or some other reason.'
				help = 'Such hairs look grey, white or silver not because they trully have grey or white pigment, but due to how the light is reflected in them.<br>'
				help = help..'See categories '..h.LinkToCategory('Grey Hair', 'Grey Hair')..', '..h.LinkToCategory('White Hair', 'White Hair')..' and '..h.LinkToCategory('Silver Hair', 'Silver Hair')
				help = help..' for characters whose hair have such color naturally or were dyed.'
				table.insert(output_categories, 'Characters by Hair')
		elseif category == 'Bald'
			then
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = 'Characters who lost their hair due to some natural reasons.'
				table.insert(output_categories, 'Characters by Hair')
		elseif category == 'Balding'
			then 
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = 'Characters who partially lost their hair due to some natural reasons.'
				table.insert(output_categories, 'Characters by Hair')
		elseif category == 'Shaved Hair'
			then 
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = 'Characters who shaved their hair.' 
				table.insert(output_categories, 'Characters by Hair')
		elseif category == 'No Hair'
			then 
				navigation = p.lua_add_navigation( navigation_message(category) )
				output = "Characters who don't have any hair at all on their head. Such characters, for example, can have feathers or fur instead, or be inorganic being, etc."	
				table.insert(output_categories, 'Characters by Hair')
		else
			navigation = p.lua_add_navigation( navigation_message(category) )
			value = string.lower( string.match(pagename, '(.+) Hair') )
			if value == 'variable'
				then output = 'Characters who have variable color of hair; normally due to the power to change their physical appearance.'
				else output = 'Characters who have '..value..' color of hair.'
			end
			if h.in_list({'Grey Hair', 'Silver Hair', 'White Hair'}, pagename)
				then
					help = '(Characters whose hair turned '..value..' due to natural reason should be placed into '..h.LinkToCategory('Grey-haired', 'Category:Grey-haired')
					help = help..' instead. If you found such a character in this category, please make the appropriate changes to its page and place it into '
					help = help..h.LinkToCategory('Grey-haired', 'correct category')..'.)'
			end
			table.insert(output_categories, 'Characters by Hair Color')
	end
	help = p.add_help(help)
	output = design.span(output).bold..help..navigation
	
	return design.messagebox({output})..h.add_categories(output_categories)
end

--------------------------------------------------------------------------------
-- used in Şablon:Identity Category
function p.categories_by_identity(frame)
	local page_types = {'Characters', 'Organizations', 'Races', 'Teams'}
	local identity_types = {'No Dual', 'Public', 'Known to Authorities', 'Secret'}
	local pagename = mw.title.getCurrentTitle().text
	local identity
	local page_type
	local i
	local category
	local list_of_subpages = {}
	local navigation_by_type = {}
	local navigation_by_subject = {}
	local help = ''
	local output_categories = {}
	local output = ''

	if string.find(pagename, ' by ', 1, true) == nil
		then
			identity, page_type = string.match(pagename, '(.+ Identity)(.*)')
			if h.isempty(page_type)
				then
					for i = 1, #identity_types do
						table.insert(navigation_by_type, p.lua_add_navigation_link(identity_types[i]..' Identity', identity_types[i], 'all') )
					end
					for i = 1, #page_types do
						table.insert(navigation_by_subject, p.lua_add_navigation_link(page_types[i]..' by Identity', page_types[i], 'all') )
					end
					output = 'List of subjects, '
				else
					page_type = h.trim(page_type)
					for i = 1, #identity_types do
						table.insert(navigation_by_type, p.lua_add_navigation_link(identity_types[i]..' Identity '..page_type, identity_types[i], 'all') )
					end
					for i = 1, #page_types do
						table.insert(navigation_by_type, p.lua_add_navigation_link(identity..' '..page_types[i], page_types[i], 'all') )
					end

					output = 'List of '..string.lower(page_type)..', '
			end
			navigation_by_type = p.lua_add_navigation(navigation_by_type)
			navigation_by_subject = p.lua_add_navigation(navigation_by_subject)
		
			if identity == 'No Dual Identity'
				then 
					output = output..' who do not currently have any other identity, alter ego, or alias.'
					help = '(Subjects with an alias whose identities are known to the public belong in '
					if h.isempty(page_type)
						then help = help..h.LinkToCategory('Public Identity', 'the category for subjects with a public identity')
						else help = help..h.LinkToCategory('Public Identity '..page_type, 'the category for '..string.lower(page_type)..' with a public identity')
					end
					help = help..'. If there is a subject in that category who actually has no dual identity, please make the appropriate changes.)'
				elseif identity == 'Public Identity'
					then
						output = output..' whose true identity is known to the general populace.'
						help = '(Some of the subjects listed with a public identity actually have no other identity and should be placed into '
						if h.isempty(page_type)
							then help = help..h.LinkToCategory('No Dual Identity', 'the respective category')
							else help = help..h.LinkToCategory('No Dual Identity '..page_type, 'the respective category')
						end
						help = help..' instead. If this appears to be the case, please make the appropriate changes.)'						
				elseif identity == 'Secret Identity'
					then 
						output = output..' whose true identity is not known to the general populace and authorities.'
						help = '(Secret identity is often used to avoid any legal ramifications (e.g. lawsuits), pressure or public scrutiny.)'						
				elseif identity == 'Known to Authorities Identity'
					then
						output = output..' whose identities are secret to the general populace, but known to some authorities (police forces, governments, [[S.H.I.E.L.D.]], etc).'
			end	
			help = p.add_help(help)
			
			if h.isempty(page_type)
				then 
					table.insert(output_categories, 'Identity by Type')
				else 
					table.insert(output_categories, {page_type..' by Identity', identity})
					table.insert(output_categories, {identity, page_type})
					if identity == 'Known to Authorities Identity'
						then table.insert(output_categories, {'Secret Identity '..page_type, identity})
					end
			end
			
			output = design.span(output).bold..help..navigation_by_type..navigation_by_subject
		else
			page_type = string.match(pagename, '(.+) by Identity')
			for i = 1, #page_types do
				table.insert(navigation_by_subject, p.lua_add_navigation_link(page_types[i]..' by Identity', page_types[i], 'all') )
			end
			output = p.lua_add_navigation(navigation_by_subject)
			table.insert(output_categories, 'Identity by Subject')
			table.insert(output_categories, {page_type, 'Identity'})
	end
	
	return design.messagebox({output})..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
function p.marvel_staff_categories(frame)
	local args = getArgs(frame)
	local basepagename = mw.title.getCurrentTitle().baseText
	local subpagename = mw.title.getCurrentTitle().subpageText
	local list1 = {'Editör', 'Baş editör', 'Kapak sanatçısı', 'Yazar', 'Çizer', 'Mürekkepçi', 'Boyacı', 'Hattat', 'Yönetmen', 'Yapımcı'}
	local list2 = {'Yaratıcı', 'Kapak sanatçısı resimleri', 'Çizer resimleri', 'Mürekkepçi resimleri', 'Boyacı resimleri', 'Hattat resimleri'}
	local list3 = {
		{'Baş editör', 'List of all known comic(s) that were produced while ', ' was Editor-in-Chief.', 'Marvel personelleri/Editors-in-Chief'},
		{'Kapak sanatçısı', 'List of all known comic(s) where ', ' created the cover.', 'Marvel personelleri/Cover Artists'},
		{'Editör', 'List of all known work(s) that ', ' edited.', 'Marvel personelleri/Editors'},
		{'Yazar', 'List of all known work(s) that ', ' wrote.', 'Marvel personelleri/Writers'},
		{'Çizer', 'List of all known comic(s) that ', ' penciled.', 'Marvel personelleri/Pencilers'},
		{'Mürekkepçi', 'List of all known comic(s) that ', ' inked.', 'Marvel personelleri/Inkers'},
		{'Boyacı', 'List of all known comic(s) that ', ' colored.', 'Marvel personelleri/Colorists'},
		{'Hattat', 'List of all known comic(s) that ', ' lettered.', 'Marvel personelleri/Letterers'},
		{'Yönetmen', 'List of all known work(s) directed by ', '.', 'Marvel personelleri/Directors'},
		{'Yapımcı', 'List of all known work(s) produced by ', '.', 'Marvel personelleri/yapımcılar'},
		{'Yaratıcı', 'List of all known subject(s) created by ', '.', 'Subjects by Creator'},
		{'Kapak sanatçısı resimleri', 'List of all known covers drawn by ', '.', 'Images by Cover Artist'},
		{'Çizer resimleri', 'List of all images on the database penciled by ', '.', 'Images by Penciler'},
		{'Mürekkepçi resimleri', 'List of all images on the database inked by ', '.', 'Images by Inker'},
		{'Boyacı resimleri', 'List of all images on the database colored by ', '.', 'Images by Colorist'},
		{'Hattat resimleri', 'List of all images on the database lettered by ', '.', 'Images by Letterer'},
	}
	local i
	local category
	local message = ''
	local subcategories1 = {}
	local subcategories2 = {}
	local help = ''
	local output_categories = {}
	local output = ''
	
	for i = 1, #list1 do
		table.insert(subcategories1, p.lua_add_navigation_link(basepagename..'/'..list1[i], list1[i]) )
	end
	subcategories1 = p.lua_add_navigation(subcategories1)
	
	for i = 1, #list2 do
		category = basepagename..'/'..list2[i]
		if h.pages_in_category(category, 'files')>0 or (list2[i] == 'Creator' and h.pages_in_category(category, 'pages')>0)
			then table.insert(subcategories2, h.LinkToCategory(category, list2[i]))
			else table.insert(subcategories2, p.nonexistent_page(list2[i]))
		end
	end
	subcategories2 = p.lua_add_navigation(subcategories2)

	if not h.exists(basepagename)
		then table.insert(output_categories, 'Marvel Staff Categories with Articles Needed')
	end

	if subpagename ~= basepagename
		then
			for i = 1, #list3 do
				if subpagename == list3[i][1]
					then 
						message = list3[i][2]..h.Link(basepagename)..list3[i][3]
						table.insert(output_categories, list3[i][4])
						if h.in_list(list1, subpagename)
							then help = '(If you find an article that is not shown here, please add "'..basepagename..'" into "'..string.gsub(subpagename, ' ', '')..'" field of said article.)'
							elseif subpagename == 'yaratıcı'
								then help = '(If you find an article that is not shown here, please add "'..basepagename..'" into "Creators" field of said article.)'
							else 
								help = '(If you find an image in the database that is not shown here, please add "'..basepagename
								help = help..'" into "'..string.gsub(string.gsub(subpagename, ' ', ''), 'Images', '')..'" field of said image.)'
						end
						break
				end
			end
			if message ~= ''
				then 
					message = design.span(message).bold
					help = p.add_help(help)
					output = design.messagebox({message..help..subcategories1..subcategories2})
			end
	end
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- used in Şablon:Weight Category
function p.weight_category(frame)
	local units  = require('Modül:Units')	
	local pagename = mw.title.getCurrentTitle().text	
	local function lbs_to_kg(weightLbs)
		return h.round(tonumber(weightLbs) * units['lbs'].kg, 2)
	end
	local i
	local value1
	local value2
	local value3
	local sortname
	local category
	local help = {}
	local output_categories = {'Weight'}
	local output = 'List of characters with '
	
	value1, value2 = string.match(pagename, 'Weight (%d+)%-(%d+) lbs')
	if value1 ~= nil and value2 ~= nil
		then 
			sortname = lbs_to_kg(value1) * 1000
			if value2 == '9'
				then output = output..'weight below 10 lbs ('..lbs_to_kg(10)..' kg)'
				else output = output..'weight between '..value1..' lbs ('..lbs_to_kg(value1)..' kg) and '..value2..' lbs ('..lbs_to_kg(value2)..' kg)'
			end
		else 
			output = output..string.lower(pagename)
			sortname = lbs_to_kg(1000) * 1000
	end
	output = design.span(output..'.').bold
	sortname = ' '..string.rep('0', 10-#tostring(sortname))..sortname
	
	value1 = lbs_to_kg(10)
	category = 'Weight 0-9 lbs ('..value1..' kg)'
	text = '< 10 lbs ('..value1..' kg)'
	table.insert(help, h.LinkToCategory(category, text))
	
	value1 = lbs_to_kg(10)
	value2 = lbs_to_kg(20)
	category = 'Weight 10-19 lbs ('..value1..'-'..value2..' kg)'
	text = '10-19 lbs ('..value1..'-'..value2..' kg)'
	table.insert(help, h.LinkToCategory(category, text))
	
	i = 20
	while i <= 280 do
		value1 = lbs_to_kg(i)
		value2 = lbs_to_kg(i+20)
		text = i..'-'..(i+19)..' lbs ('..value1..'-'..value2..' kg)'
		category = 'Weight '..text
		table.insert(help, h.LinkToCategory(category, text))
		i = i + 20
	end
	
	i = 300
	while i <= 900 do
		value1 = lbs_to_kg(i)
		value2 = lbs_to_kg(i+100)
		text = i..'-'..(i+99)..' lbs ('..value1..'-'..value2..' kg)'
		category = 'Weight '..text
		table.insert(help, h.LinkToCategory(category, text))
		i = i + 100
	end
	
	value1 = lbs_to_kg(1000)
	category = 'Weight above 1000 lbs ('..value1..' kg)'
	text = '> 1000 lbs ('..value1..' kg)'
	table.insert(help, h.LinkToCategory(category, text))

	table.insert(help, h.LinkToCategory('Variable Weight', 'Variable'))

	help = p.lua_add_navigation(help)
	output = design.messagebox({output..help})

	return output..h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
-- used in Şablon:Height Category
function p.height_category(frame)
	local units  = require('Modül:Units')	
	local pagename = mw.title.getCurrentTitle().text	
	local function ft_to_m(heightFt)
		return tonumber( string.format("%.2f", tonumber(heightFt) * units['ft'].m) )
	end
	local i
	local j
	local value1
	local value2
	local value3
	local sortname
	local category
	local help = {}
	local output_categories = {'Height'}
	local output = 'List of characters with '
	
	value1, value2 = string.match(pagename, 'Height (%d)%-(%d) ft')
	if value1 ~= nil and value2 ~= nil
		then 
			sortname = ft_to_m(value1) * 1000
			if value2 == '1'
				then output = output..'height below 1 ft. ('..ft_to_m(1)..' m)'
				else output = output..'height between '..value1..' ft. ('..ft_to_m(value1)..' m) and '..value2..' ft. ('..ft_to_m(value2)..' m)'
			end
		else 
			output = output..string.lower(pagename)
			if string.find(pagename, ' above 8 ') ~= nil
				then sortname = ft_to_m(8) * 1000
				elseif string.find (pagename, 'Variable') ~= nil
					then sortname = '9999'
				else
					value1, value2 = string.match(pagename, '(%d+) ft%. (%d+) in')
					sortname = ft_to_m(tonumber(value1) + tonumber(value2)/12) * 1000
			end
	end
	output = design.span(output..'.').bold
	sortname = ' '..string.rep('0', 4-#tostring(sortname))..sortname
	
	value1 = ft_to_m(1)
	category = 'Height 0-1 ft. ('..value1..' m)'
	text = '< 1 ft. ('..value1..' m)'
	table.insert(help, h.LinkToCategory(category, text))
	for i = 1, 4 do
		value1 = ft_to_m(i)
    	value2 = ft_to_m(i+1)
    	text = i..'-'..(i+1)..' ft. ('..value1..'-'..value2..' m)'
    	category = 'Height '..text
    	table.insert(help, h.LinkToCategory(category, text))
    end
    for j = 5, 6 do
    	for i = 0, 11 do
    		value1 = ft_to_m(j + i/12)
    		text = j..' ft. '..i..' in. ('..value1..' m)'
    		category = 'Height '..text
    		table.insert(help, h.LinkToCategory(category, text))
    	end
    end
    
	i = 7
	value1 = ft_to_m(i)
    value2 = ft_to_m(i+1)
    text = i..'-'..(i+1)..' ft. ('..value1..'-'..value2..' m)'
    category = 'Height '..text
    table.insert(help, h.LinkToCategory(category, text))

    value1 = ft_to_m(8)
    category = 'Height above 8 ft. ('..value1..' m)'
    text = '> 8 ft. ('..value1..' m)'
    table.insert(help, h.LinkToCategory(category, text))
    
   	table.insert(help, h.LinkToCategory('Variable Height', 'Variable'))
    
	help = p.lua_add_navigation(help)
	output = design.messagebox({output..help})
	
	return output..h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
-- currently not working
function p.chronological_sort(frame)
	local pagename = "Xavier's School for Gifted Youngsters/Appearances" --mw.title.getCurrentTitle().text
	local CS = require('Modül:Chronological Sort')
	return design.messagebox({CS.main(frame, pagename)})
end


--------------------------------------------------------------------------------
-- used in Şablon:Power Grid Category
function p.power_grid_category(frame)
	local description = mw.loadData('Modül:Power Grid/Description')
	local args = getArgs (frame)
	local subpageText = mw.title.getCurrentTitle().subpageText
	local baseText = mw.title.getCurrentTitle().baseText
	local rootText = mw.title.getCurrentTitle().rootText
	local i
	local j
	local navigation_types = {}
	local navigation_values = {}
	local value 
	local category
	local output_category = ''
	local output = ''

	for i = 1,6 do
		category = 'Güç tablosu/'..description[i].label
		table.insert(navigation_types, h.LinkToCategory(category, description[i].label))
	end
	navigation_types = 'This category is a part of the power ratings presented in official Marvel handbooks.'..p.lua_add_navigation(navigation_types)

	if baseText == rootText
		then
			output_category = h.Category(baseText, subpageText)
			for i = 1,6 do
				if description[i].label == subpageText
					then output = design.span(string.upper(description[i].label)).bold..' — '..description[i].tooltip
				end
			end
			output = navigation_types..'\n----'..output
		else
			for i = 1,6 do
				if description[i].label == string.match(baseText, '/(.+)')
					then
						output = design.span(description[i].label).bold..' — '..description[i].tooltip
						for j = 1,7 do
							category = description[i].values[j].category
							table.insert(navigation_values,  h.LinkToCategory(category, j))
							if category == baseText..'/'..subpageText
								then 
									value = design.span(string.upper(description[i].values[j].tooltip)).bold
									output_category = h.Category(baseText, j)
							end
						end
						navigation_values = mw.text.listToText(navigation_values, ' · ', ' · ')
						output = navigation_types..'\n----'..output..'<br>'..navigation_values..'<br>'..value
				end
			end
	end
	output = design.messagebox({output})

	return output..output_category
end


--------------------------------------------------------------------------------
-- used in Şablon:Races by Location
function p.races_by_location(frame)
	local args = getArgs(frame)
	local pagename = mw.title.getCurrentTitle().baseText
	local page_content = h.get_content(pagename)
	local galaxy = h.get_field_value(page_content, 'Galaxy') 
	local dimension = h.get_field_value(page_content, 'Dimension') 
	local star_system = h.get_field_value(page_content, 'StarSystem') 
	local planet = h.get_field_value(page_content, 'Planet') 
	local page_type = args[1]
	local place = args[2]
	local output_categories = {}
	local output = ''
	
	if (not h.isempty(galaxy) and pagename == galaxy) or (not h.isempty(page_type) and string.lower(page_type) == 'galaxy')
		then
			output = 'galaxy'
			table.insert(output_categories, 'Races by Galaxy')
		elseif (not h.isempty(dimension) and pagename == dimension) or (not h.isempty(page_type) and string.lower(page_type) == 'dimension')
			then
				output = 'dimension'
				table.insert(output_categories, 'Races by Dimension')
		elseif (not h.isempty(star_system) and pagename == star_system) or (not h.isempty(page_type) and string.lower(page_type) == 'star system')
			then
				output = 'star system'
				table.insert(output_categories, 'Races by Star System')
				if not h.isempty(galaxy)
					then table.insert(output_categories, galaxy..'/Races')
					elseif not h.isempty(dimension)
						then table.insert(output_categories, dimension..'/Races')	
					elseif not h.isempty(place)
						then table.insert(output_categories, place..'/Races')
				end
		elseif (not h.isempty(planet) and pagename == planet) or (not h.isempty(page_type) and string.lower(page_type) == 'planet')
			then
				output = 'planet'
				table.insert(output_categories, 'Races by Planet')
				if not h.isempty(star_system)
					then table.insert(output_categories, star_system..'/Races')
					elseif not h.isempty(galaxy)
						then table.insert(output_categories, galaxy..'/Races')
					elseif not h.isempty(dimension)
						then table.insert(output_categories, dimension..'/Races')
					elseif not h.isempty(place)
						then table.insert(output_categories, place..'/Races')
				end
		else table.insert(output_categories, 'Races by Place of Origin')
	end
	
	table.insert(output_categories, pagename)
	output = 'Races which originated from '..h.Link(pagename, pagename)..' '..output..'.'
	output = design.span(output).bold
	output = design.messagebox({output})

	return output..h.add_categories(output_categories, pagename)
end


--------------------------------------------------------------------------------
-- used in:
--		Şablon:Appearances Category
--		Şablon:Mentions Category
--		Şablon:Minor Appearances Category
--		Şablon:Images Category
--		Şablon:Quotes
--		Şablon:Items by User
function p.standard_subcategories_and_subpages(frame)
	local m_pagetype = require('Modül:PageType')
	local basepagename = mw.title.getCurrentTitle().baseText
	local subpagename = mw.title.getCurrentTitle().subpageText
	local pagetype = getArgs(frame)[1]
	local s
	
	if string.find(basepagename, 'Killed by ') ~= nil
		then s = string.match(basepagename, 'Killed by (.+)')
		else s = basepagename
	end
	
	if h.isempty(pagetype)
		then 
			if string.find(basepagename, ' Sezon ') ~= nil and string.find(basepagename, ' Vol ') == nil and m_pagetype.get_page_type(s) ~= 'Bölüm'
				then pagetype = 'Sezon'
				else
					pagetype = m_pagetype.get_page_type(s)
					if (h.isempty(pagetype) or pagetype == 'Bilinmiyor') and not h.in_list({'Görünümler', 'El kitabı görünümleri', 'Küçük görünümler', 'Bahsedilmeler', 'El kitabı bahsedilmeleri', 'Yakarışlar', 'Eşyalar', 'Alıntılar', 'Resimler', 'Galeri'}, subpagename)
						then 
							basepagename = mw.title.getCurrentTitle().text
							pagetype = m_pagetype.get_page_type(basepagename)
					end
			end
	end

	if h.in_list({'Çizgi roman', 'Cilt', 'Roman', 'Bölüm', 'Sezon', 'Dizi', 'Film', 'Video oyunu', 'Kutu oyunu'}, pagetype)
		then return p.lua_standard_subcategories_and_subpages2(basepagename, subpagename, pagetype)
		else return p.lua_standard_subcategories_and_subpages(basepagename, subpagename, pagetype)
	end
end

-- for sources - 'Comic', 'Volume', 'Novel', 'Episode', 'Season', 'Series', 'Film', 'Video Game', 'Board Game'
function p.lua_standard_subcategories_and_subpages2(basepagename, subpagename, pagetype)
	local standard = require('Modül:StandardizedName')
	local m_pagetype = require('Modül:PageType')
	local sortname = ''
	local i
	local category
	local list = {}
	local list1 = {'Resimler', 'Yeniden basımlar'}
	local list2 = {'Resimler'}
	local list3 = {'Sayılar', 'Resimler', 'Yeniden basımlar', 'TC basım'}
	local list_of_subpages = {}
	local help = ''
	local info = ''
	local output_categories = {}
	local output = ''

	if string.find(basepagename, ' Sezon ') ~= nil and string.find(basepagename, ' Vol ') == nil and m_pagetype.get_page_type(basepagename) ~= 'Bölüm'
		then pagetype = 'Sezon'
		else pagetype = pagetype or m_pagetype.get_page_type(basepagename)
	end
	
	if pagetype == 'Cilt' or pagetype == 'Çizgi roman'
		then 
			info = standard.lua_get_title_volume_issue(basepagename, 'Vol')
			sortname = info.sortname.all
			if pagetype == 'Cilt' 
				then list = list3
				else list = list1
			end
		elseif h.in_list({'Bölüm', 'Sezon'}, pagetype)
			then 
				if subpagename == basepagename
					then list = list2
				end
				info = standard.lua_get_title_volume_issue(basepagename, 'Sezon')
				sortname = info.sortname.all
		--elseif h.in_list({'Novel', 'Film', 'Video Game', 'Board Game'}, pagetype)
		--	then list = list2
		elseif h.in_list({'Video oyunu', 'Dizi'}, pagetype)
			then 
				list = list2
				sortname = standard.lua_standardized_name_for_sorting(basepagename, pagetype)
		else sortname = standard.lua_standardized_name_for_sorting(basepagename, pagetype)
	end
	
	for i = 1, #list do
		if list[i] == 'Sayı'
			then 
				category = basepagename
				s = 'pages' 
			else 
				category = basepagename..'/'..list[i]
				if list[i] == 'Images'
					then s = 'files'
					elseif list[i] == 'Yeniden basımlar' 
						then 
							if pagetype == 'Çizgi roman'
								then s = 'pages' 
								else s = 'subcats'
							end
					else s = 'pages' 
				end
		end
		table.insert(list_of_subpages, p.lua_add_navigation_link(category, list[i], s) )
	end
	
	if h.in_list({'Video oyunu', 'Dizi'}, pagetype)
		then
			category = basepagename..'/galeri'
			if h.exists(category)
				then table.insert(list_of_subpages, h.Link(category, 'galeri') )
				else table.insert(list_of_subpages, p.nonexistent_page('galeri') )
			end
	end
	list_of_subpages = p.lua_add_navigation(list_of_subpages)
	
	if h.in_list({'Yeniden basımlar', 'TC basım', 'Yıllıklar', 'Özeller', 'Resimler', 'Galeri'}, subpagename) and subpagename ~= basepagename
		then
			if subpagename == 'yeniden basımlar'
				then 
					if pagetype == 'Çizgi roman'
						then 
							output = 'List of all known reprints of '..h.Link(basepagename, basepagename)..'.'
							help = '(If you find an issue that is not shown here, please add "'
							help = help..basepagename..'" into "ReprintOf_" field of said issue.)'
							table.insert(output_categories, 'Comic Reprints by Issue')
							table.insert(output_categories, info.noissue..'/Reprints')
						else
							output = 'List of reprints of issues from '..h.Link(basepagename, basepagename)..' volume.'
							help = '(If you find reprint of an issue from this volume that is not shown here, please add' 
							help = help..' original source into "ReprintOf_" field of said issue.)'
							table.insert(output_categories, 'Comic Reprints by Volume')
					end
				elseif subpagename == 'TPB'
					then
						output = 'List of all known TPB editions that focus on comic issues from '..h.Link(basepagename, basepagename)..' volume.'
						help = '(If you have found a volume that is not shown here, please add "'..basepagename..'" into <code>main_volume</code> field of said volume.)'
						table.insert(output_categories, 'TPBs by Source')  
				elseif subpagename == 'Annuals' or subpagename == 'Specials'
					then
						output = 'List of all known '..string.lower(subpagename)..' that focus on comic issues from '..h.Link(basepagename, basepagename)..' volume.'
						help = '(If you have found a volume that is not shown here, please add "'..basepagename..'" into <code>main_volume</code> field of said volume.)'
						table.insert(output_categories, subpagename..' by Source')
				elseif subpagename == 'resimler'
					then
						if pagetype == 'Sezon'
							then output = h.Link(info.title..'#Sezon '..info.volume, basepagename)..' tüm önemli görsellerinin listesidir.'
							else output = h.Link(basepagename, basepagename)..' tüm önemli görsellerinin listesidir.'
						end
						if pagetype == 'Cilt'
							then help = '(Eğer burada gösterilmeyen bir görsel bulursanız lütfen " bir sayısını ekleyiniz'
							elseif pagetype == 'Sezon' or pagetype == 'Dizi'
								then help = '(Eğer burada gösterilmeyen bir görsel bulursanız lütfen " bir bölümünü ekleyiniz'
							else help = '(Eğer burada gösterilmeyen bir görsel bulursanız lütfen " ekleyiniz'
						end
						help = help..basepagename..'" into "Source" field of said image.)'
						if pagetype == 'Çizgi roman'
							then 
								table.insert(output_categories, 'Çizgi roman sayısına göre resimler')
								table.insert(output_categories, info.noissue..'/resimler')
							elseif pagetype == 'Cilt'
								then table.insert(output_categories, 'Çizgi roman cildine göre resimler')
							elseif pagetype == 'Bölüm'
								then 
									table.insert(output_categories, 'Bölümüne göre resimler')
									table.insert(output_categories, info.noissue..'/resimler')
							elseif pagetype == 'Sezon'
								then 
									table.insert(output_categories, 'Sezonuna göre resimler')
									table.insert(output_categories, info.title..'/resimler')
							elseif pagetype == 'Dizi'
								then table.insert(output_categories, 'Dizisine göre resimler')
							else -- 'Novel', 'Film', 'Video Game', 'Board Game'
								table.insert(output_categories, 'Images by '..pagetype)		
						end
				elseif subpagename == 'Galeri'
					then
						output = 'Gallery of all notable images (or videos) from '..h.Link(basepagename, basepagename)..'.'
						help = h.Link('Marvel Wiki:Galeri şablonu', 'galeri şablonu')
						help = '(If you create a gallery or add image (or video) to existing one, please follow our '..help..').'
						table.insert(output_categories, pagetype..' Galleries')
			end
		else
			--basepagename = mw.title.getCurrentTitle().text
			--pagetype = m_pagetype.get_page_type(basepagename)
			if pagetype == 'Cilt'
				then
					output = h.Link(basepagename, basepagename)..' cildindeki tüm bilinen çizgi roman sayılarının listesidir.'
					help = h.Link('Marvel Wiki:Çizgi roman şablonu', 'çizgi roman şablonu')
					help = '(Eğer burada gösterilmeyen bir sayı bulursanız lütfen makalesine '..help..' ekleyiniz.)'
					table.insert(output_categories, 'Ciltler')
			end
	end
	help = p.add_help(help)
	output = design.span(output).bold..help..list_of_subpages
			
	return design.messagebox({output})..h.add_categories(output_categories, sortname)
end


-- for articles - characters, teams, etc.
function p.lua_standard_subcategories_and_subpages(basepagename, subpagename, pagetype)
	local m_pagetype = require('Modül:PageType')
	local sortname
	local i
	local category
	local list = {'Görünümler', 'El kitabı görünümleri', 'Küçük görünümler', 'Bahsedilmeler', 'El kitabı bahsedilmeleri', 'Yakarışlar', 'Eşyalar', 'Alıntılar', 'Resimler'}
	local list_of_subpages = {}
	local help = ''
	local s
	local killed_by = false
	local output_categories = {}
	local output = ''

	if string.find(basepagename, 'Killed by ') ~= nil
		then 
			basepagename = string.match(basepagename, 'Killed by (.+)')
			killed_by = true
	end

	sortname = require('Modül:StandardizedName').name_for_sorting({basepagename})
	pagetype = pagetype or m_pagetype.get_page_type(basepagename)
	if pagetype == 'Personel'
		then pagetype = 'Marvel personeli'
	end

	for i = 1, #list do
		category = basepagename..'/'..list[i]
		if list[i] == 'resimler'
			then s = 'files'
			else s = 'pages'
		end
		table.insert(list_of_subpages, p.lua_add_navigation_link(category, list[i], s))
	end
	category = basepagename..'/galeri'
	if h.exists(category)
		then table.insert(list_of_subpages, h.Link(category, 'galeri') )
		else table.insert(list_of_subpages, p.nonexistent_page('galeri') )
	end
	if h.in_list({'Karakter', 'Takım', 'Organizasyon', 'Irk'}, pagetype) 
		then
			category = 'Killed by '..basepagename
			table.insert(list_of_subpages, p.lua_add_navigation_link(category, 'Victims', 'pages'))
	end
	list_of_subpages = p.lua_add_navigation(list_of_subpages)
			
	if subpagename ~= basepagename
		then
			if h.in_list({'Görünümler', 'El kitabı görünümleri', 'Küçük görünümler', 'Alıntılar', 'El kitabı bahsedilmeleri', 'Yakarışlar'}, subpagename)
				then
					if h.in_list({ 'El kitabı görünümleri', 'El kitabı bahsedilmeleri' }, subpagename)
						then output = 'List of all known '..string.lower(string.gsub(subpagename, 'Handbook ', ''))..' of '..h.Link(basepagename, basepagename)..' in '..h.LinkToCategory('Handbooks', 'handbooks')..'.'
						else output = 'List of all known '..string.lower(subpagename)..' of '..h.Link(basepagename, basepagename)..'.'
					end
					for i = 1,6 do
						if subpagename == list[i]
							then 
								--help = list2[i]
								if h.in_list({ 'Yakarışlar', 'El kitabı bahsedilmeleri' }, list[i])
									then 
										table.insert(output_categories, list[i])
										table.insert(output_categories, basepagename..'/bahsedilmeler')
									elseif list[i] == 'El kitabı görünümleri'
										then
											table.insert(output_categories, list[i])
											table.insert(output_categories, basepagename..'/görünümler')
									else table.insert(output_categories, pagetype..' '..list[i])
								end
						end
					end
					help = '(If you find a medium that is not shown here, please add "'..basepagename
					help = help..'" to the appearances section with a '..h.Link('Marvel Wiki: Appearance Tags', 'proper tag')..'.)'
				elseif subpagename == 'eşyalar'
					then
						output = 'List of all notable items owned and/or used by '..h.Link(basepagename, basepagename)..'.'
						help = '(If you find an item that is not shown here, please add "'..basepagename
						help = help..'" to the "CurrentOwner" or "PreviousOwners" sections.)'
						table.insert(output_categories, 'Items by User')
				elseif subpagename == 'alıntılar'
					then
						output = 'List of all notable quotes by or about '..h.Link(basepagename, basepagename)..'.'
						help = '(Please add any important quotations that may be missing, ensuring to cite the original source. '
						help = help..'Pages with a quote from this character will automatically be added here along with the quote.)'
						table.insert(output_categories, 'Quotes')
				elseif subpagename == 'resimler'
					then
						output = 'List of all images of '..h.Link(basepagename, basepagename)..' on the database.'
						help = '(If you find an image in the database that is not shown here, please add "'..basepagename..'" as an image subject.)'
						table.insert(output_categories, pagetype..' resimler')
				elseif subpagename == 'galeri'
					then
						output = 'Gallery of all notable images '
						if pagetype == 'Marvel personeli' or pagetype == 'Kullanıcı görseli'
							then output = output..'tarafından '
							else output = output..'of '
						end
						if pagetype == 'Kullanıcı görseli'
							then output = output..h.Link('User:'..basepagename, 'User:'..basepagename)
							else output = output..h.Link(basepagename, basepagename)
						end
						output = output..' on the database.'
						help = h.Link('Marvel Database:Gallery Guidelines', 'Gallery Guidelines')
						help = '(If you create a gallery or add image(s) to existing one, please follow our '..help..').'
						table.insert(output_categories, pagetype..' Galleries')
				elseif killed_by == true
					then
						output = 'List of all notable victims killed by '..h.Link(basepagename, basepagename)..'.'
						help = '(If you find a character that is not shown here, please add "'..basepagename
						help = help..'" to the "KilledBy" field.)'
						table.insert(output_categories, 'Characters by Killer')
			end
			if ( pagetype ~= 'Kullanıcı resimleri' and not h.exists(basepagename) 	) or ( pagetype == 'User Art' and not h.exists('Kullanıcı:'..basepagename) )
				then 
					output_categories = {} -- remove all previous categories
					if killed_by == true
						then table.insert(output_categories, 'Killed By Categories with Articles Needed')
						else table.insert(output_categories, subpagename..'  Categories with Articles Needed')
					end
			end
	end
	help = p.add_help(help)
	output = design.span(output).bold..help..list_of_subpages
			
	return design.messagebox({output})..h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
-- used in Template:Season Category
function p.season_category(frame)
	local standard = require('Modül:StandardizedName')
	local basepagename = mw.title.getCurrentTitle().baseText
	local info = standard.lua_get_title_volume_issue(basepagename, 'Sezon')
	local sortname = info.sortname.all
	local i
	local category
	local images = basepagename..'/resimler'
	local seasons = {}
	local help = ''
	local output_categories = {}
	local output = ''

	output = design.span(h.Link(info.title..'#Sezon '..info.volume, basepagename)..' bilinen tüm bölümlerinin listesidir.').bold
	help = h.Link('Marvel Wiki:Bölüm şablonu', 'bölüm şablonu')
	help = '(Eğer burada gösterilmeyen bir bölümü bulursanız lütfen sayfasına '..help..' ekleyin.)'
	
	for i = 1, 30 do
		category = info.title..' Sezon '..i
		if h.exists('Kategori:'..category)
			then 
				category = h.LinkToCategory(category, 'Sezon '..i)
				table.insert(seasons, category)
		end
	end
	seasons = p.lua_add_navigation(seasons)
	
	if h.pages_in_category(images, 'files') > 0
		then images = p.lua_add_navigation({ h.LinkToCategory(images, 'resimler') })
		else images = ''
	end
	
	output = output..'<br>'..help..images..seasons
	table.insert(output_categories, 'Sezonlar')

	return design.messagebox({output})..h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
-- used in Şablon:Reality Category
function p.categories_by_reality(frame)
	local page_types = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Team', 'Vehicle'}
	local basepagename = mw.title.getCurrentTitle().baseText
	local subpagename = mw.title.getCurrentTitle().subpageText
	local sortname = require('Modül:Reality').get_reality_info({basepagename}).padded_number
	local i
	local category
	local list_of_subpages = {}
	local help = ''
	local output_categories = {}
	local output = ''
	
	if string.find(basepagename, ' by Reality') ~= nil
		then 
			for i = 1, #page_types do
				category = page_types[i]..'s by Reality'
				table.insert(list_of_subpages, h.LinkToCategory(category, page_types[i]..'s') )
			end
			list_of_subpages = mw.text.listToText(list_of_subpages, ' · ', ' · ')
		else
			for i = 1, #page_types do
				table.insert(list_of_subpages, p.lua_add_navigation_link(basepagename..'/'..page_types[i]..'s', page_types[i]..'s'))
			end
			list_of_subpages = p.lua_add_navigation(list_of_subpages)
	end
	
	if subpagename == basepagename
		then
			if string.find(basepagename, ' by Reality') ~= nil
				then 
					category = string.match(basepagename, '(.+) by Reality')
					table.insert(output_categories, category)
					sortname = 'Reality'
				else
					output = 'Articles related to '..h.Link(basepagename, basepagename)..' reality.'
					table.insert(output_categories, 'Realities by Category')
			end
		else
			output = subpagename..' that originate from '..h.Link(basepagename, basepagename)..' reality.'
			table.insert(output_categories, subpagename..' by Reality')
			table.insert(output_categories, {basepagename, subpagename})
			help = '(To add '..string.lower(string.sub(subpagename, 1, -1))..' to this list enter "'..basepagename..'" in the "Universe" field of its template.)'
			help = p.add_help(help)
	end
	output = design.span(output).bold..help..list_of_subpages
	
	return design.messagebox({output})..h.add_categories(output_categories, sortname)
end


--------------------------------------------------------------------------------
-- used in Şablon:Year of Debut Category
function p.debut_category(frame)
	local page_types = {}
	local page_types2 = {}
	local page_types1_1 = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Reality', 'Team', 'Vehicle'}
	local page_types1_2 = {'Characters', 'Items', 'Locations', 'Organizations', 'Races', 'Realities', 'Teams', 'Vehicles'}
	local page_types2_1 = {'Event', 'Story Arc', 'Storyline'}
	local page_types2_2 = {'Events', 'Story Arcs', 'Storylines'}
	local pagename = mw.title.getCurrentTitle().text
	local page_type
	local page_type2
	local year
	local i
	local category
	local navigation = {}
	local header = ''
	local output_categories = {}
	local output = ''
	
	year, page_type = string.match(pagename, '^(%d%d%d%d) (.+) Debuts')
	if page_type == nil
		then
			page_type2 = string.match(pagename, '^(.+)s by Year of Debut')
			if page_type2 == 'Realitie'
				then page_type = 'Reality'
				else page_type = page_type2
			end
			output = p.debut_categories_navigation(page_type)
			table.insert(output_categories, {page_type2..'s', 'Year of Debut'})
		else
			if h.in_list(page_types1_1, page_type)
				then 
					page_types  = page_types1_1
					page_types2 = page_types1_2
					header = ' which first appeared in medium released in '
				else 
					page_types  = page_types2_1
					page_types2 = page_types2_2
					header = ' what were released in '
			end
			
			for i = 1, #page_types do
				if page_types[i] == page_type
					then page_type2 = page_types2[i]
				end
				table.insert(navigation, p.lua_add_navigation_link(year..' '..page_types[i]..' Debuts', page_types2[i]))
			end
			navigation = p.lua_add_navigation(navigation)
			table.insert(output_categories, page_type2..' by Year of Debut')
			table.insert(output_categories, {year, page_type..' Debuts'})
			header = design.span(page_type2..header..h.LinkToCategory(year, year)..'.').bold
			output = design.messagebox({header..navigation})..p.debut_categories_navigation(page_type)
	end
	
	return output..h.add_categories(output_categories)
end


function p.debut_categories_navigation(page_type)
	local page_types = {}
	local page_types2 = {}
	local page_types1_1 = {'Character', 'Item', 'Location', 'Organization', 'Race', 'Reality', 'Team', 'Vehicle'}
	local page_types1_2 = {'Characters', 'Items', 'Locations', 'Organizations', 'Races', 'Realities', 'Teams', 'Vehicles'}
	local page_types2_1 = {'Event', 'Story Arc', 'Storyline'}
	local page_types2_2 = {'Events', 'Story Arcs', 'Storylines'}
	local current_year = tonumber(mw.language.new('tr'):formatDate('Y'))
	local header
	local i
	local category
	local help = {}
	local navigation = {}
	local output = {}

	if h.in_list(page_types1_1, page_type)
		then 
			page_types  = page_types1_1
			page_types2 = page_types1_2
			header = ' by year of their first appearance.'
		else 
			page_types  = page_types2_1
			page_types2 = page_types2_2
			header = ' by year of their release.'
	end

	for i = 1939, current_year do
		table.insert(navigation, p.lua_add_navigation_link(i..' '..page_type..' Debuts', i))
	end
	navigation = p.lua_add_navigation(navigation, ' ')

	for i = 1, #page_types do
		category = page_types2[i]..' by Year of Debut'
		table.insert(help, h.LinkToCategory(category, page_types2[i]))
		if page_type == page_types[i]
			then page_type = page_types2[i]
		end
	end
	header = design.span(page_type..header).bold
	output = header..'<br>'..p.lua_add_navigation(help) ..'\n----\n'..navigation
	return design.messagebox({output})
end


--------------------------------------------------------------------------------
-- for Şablon:Volume Debut and Şablon:Volume End
function p.volume_debut_or_end_category(frame)
	local pagename = mw.title.getCurrentTitle().text
	local m_date = require("Modül:Date")
	local current_year = tonumber(mw.language.new('tr'):formatDate('Y'))
	local debuts_ends = {'Volume Debut', 'Volume End'}
	local s_type = ''
	local i 
	local help = {}
	local help_months = {}
	local help_years = {}
	local year
	local month
	local category
	local header = 'Comic volumes which '
	local output_categories = {}
	local output =''

	if string.find(pagename, 'Debut') ~= nil
		then s_type = 'Debut'
		elseif string.find(pagename, 'End') ~= nil
			then s_type = 'End'
	end
	header = header..string.lower(s_type)..'ed in '

	for i = 1939, current_year do
		table.insert(help_years, p.lua_add_navigation_link(i..' Volume '..s_type..'s', i, 'all') )
	end
	help_years = p.lua_add_navigation(help_years, ' ')

	year = string.match(pagename, '(%d+) Volume '..s_type..'s')
	if year ~= nil
		then
			for i = 1, 2 do
				table.insert(help, p.lua_add_navigation_link(year..' '..debuts_ends[i]..'s', debuts_ends[i]..'s', 'all'))
			end
			help = p.lua_add_navigation(help)

			table.insert(output_categories, {'Volumes by Year of '..s_type, year})
			table.insert(output_categories, {year, 'Volume '..s_type})
			header = design.span( header..h.LinkToCategory(year, year)..'.' ).bold
			output = header..help..'\n----\n'..help_years
		else
			month, year = string.match(pagename, '(.+) (%d+) Volume '..s_type)
			for i = 1, 2 do
				table.insert(help, p.lua_add_navigation_link(month..' '..year..' '..debuts_ends[i], debuts_ends[i], 'all') )
			end
			help = p.lua_add_navigation(help)

			for i = 1, 12 do
				table.insert(help_months, p.lua_add_navigation_link(g_list_of_months[i]..' '..year..' Volume '..s_type, g_list_of_months[i]) )
			end
			help_months = p.lua_add_navigation(help_months)
			
			table.insert(output_categories, {year..' Volume '..s_type..'s', ' '..m_date.get_month_number({month})..pagename})
			table.insert(output_categories, {year..', '..month, 'Volume '..s_type})
			header = design.span( header..h.LinkToCategory(year..', '..month, month..', '..year)..'.' ).bold
			output = header..help..help_months..'\n----\n'..help_years
	end

	return design.messagebox({output})..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------
-- for Şablon:Volumes by Number of Issues
function p.volumes_by_number_of_issues_category(frame)
	local function lpad(n)
		return string.rep('0', 3-string.len(n))..n
	end
	local pagename = mw.title.getCurrentTitle().text
	local i
	local header = design.span('Comic volumes by number of issues.<br>').bold
	local category_text = ''
	local category = ''
	local output = {}
	
	table.insert(output, h.LinkToCategory('One Shots', 'One Shots'))
	table.insert(output, h.LinkToCategory('Volumes With 2 to 9 Issues', '002-009') )
	for i = 10, 90, 10 do
		category = 'Volumes With '..i..' to '..(i+9)..' Issues'
		category_text = lpad(i)..'-'..lpad(i+9)
		table.insert(output, p.lua_add_navigation_link(category, category_text))
	end
	for i = 100, 950, 50 do
		category = 'Volumes With '..i..' to '..(i+49)..' Issues'
		category_text = i..'-'..(i+49)
		table.insert(output, p.lua_add_navigation_link(category, category_text))
	end
	output = p.lua_add_navigation(output)

	if pagename == 'One Shots'
		then category = h.Category('Volumes by Number of Issues', '001')
		elseif string.find(pagename, 'Volumes With') ~= nil
			then
				first = string.match(pagename, 'Volumes With (%d+) to (%d+) Issues')
				category = h.Category('Volumes by Number of Issues', lpad(first))
	end

	return design.messagebox({header..output})..category
end


-- ***************************************************************************************
-- following functions are used only within this module
--------------------------------------------------------------------------------
function p.nonexistent_page(text)
	return tostring( mw.html.create('span'):addClass('messagebox__nonexistent_page'):wikitext(text))
end


--------------------------------------------------------------------------------
function p.add_help(value)
	local output = ''

	if not h.isempty(value)
		then output = '<br>'..tostring(mw.html.create('span'):css('font-size', '80%'):wikitext(value))
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.lua_add_navigation_link(category, value, page_types)
	if h.pages_in_category(category, page_types) > 0
		then return h.LinkToCategory(category, value)
		else return p.nonexistent_page(value)
	end
end


--------------------------------------------------------------------------------
function p.lua_add_navigation(navigation_list, separator)
	local output = ''
	
	if h.isempty(separator)
		then separator = ' · '
	end
	
	if not h.isempty(navigation_list)
		then
			output = mw.text.listToText(navigation_list, separator, separator)
			output = '<br>'..tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.lua_add_nation_navigation(value)
	local output = {}
	
	table.insert(output, p.lua_add_navigation_link(value, 'Citizens', 'pages'))
	table.insert(output, p.lua_add_navigation_link(value..' Staff Members', 'Staff Members', 'pages'))
	table.insert(output, p.lua_add_navigation_link(value..' Organizations', 'Organizations', 'pages'))
	table.insert(output, p.lua_add_navigation_link(value..' Technology', 'Technologies', 'pages'))
	
	output = mw.text.listToText(output, ' · ', ' · ')
	output = '<br>'..tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )

	return output
end


--------------------------------------------------------------------------------
function p.lua_add_year_of_birth_death_navigation(value)
	local output = {}
	
	table.insert(output, p.lua_add_navigation_link('Born in '..value, 'Born', 'pages'))
	table.insert(output, p.lua_add_navigation_link('Died in '..value, 'Died', 'pages'))

	output = mw.text.listToText(output, ' · ', ' · ')
	output = '<br>'..tostring( mw.html.create('span'):addClass('messagebox__help'):wikitext(output) )

	return output
end

return p
Advertisement