Module:Design

From Chill


  • ~ Sign your name with 4 tildes. ~



  • Write below double line.



local p = {}
local h = require("Module:HF")
local getArgs = require('Dev:Arguments').getArgs


--------------------------------------------------------------------------------
function p.get_main_border_color()
	return '#B5B7CF'
end

function p.get_main_background_color()
	return '#EFF0FF'
end

--------------------------------------------------------------------------------
function p.green(text)
	local output = ''
	if not h.isempty(text)
		then 
			output = mw.html.create( 'span' )
				:css( 'color', 'darkgreen' )
				:css( 'font-weight', 'bold' )
				:css( 'font-style', 'italic' )
				:css( 'font-size', 'smaller' )
				:wikitext('('..text..')')
				:done()
			output = tostring(output)
	end
	return output
end


--------------------------------------------------------------------------------
function p.span(text)
	local italic = mw.html.create( 'span' ):css( 'font-style', 'italic' )
	local bold = mw.html.create( 'span' ):css( 'font-weight', 'bold' )
	local both = mw.html.create( 'span' ):css( 'font-weight', 'bold' ):css( 'font-style', 'italic' )
	local output = { italic = '', bold = '', both = '' }
	
	if not h.isempty(text)
		then
			output = {
				italic  = tostring(italic:wikitext(text):done()),
				bold	= tostring(bold:wikitext(text):done()),
				both	= tostring(both:wikitext(text):done()),
			}
	end

	return output
end


--------------------------------------------------------------------------------
-- creates message box
function p.messagebox(frame)
	local args = getArgs (frame)
	local width = args['width'] or '95%'
	local textalign = args['text-align'] or 'center'
	local fontsize = args['font-size'] or '100%'
	local border = args['border'] or p.get_main_border_color()
	local background = args['background'] or p.get_main_background_color()
	local margin = args['margin'] or '1em'
	local clear = args['clear'] or 'none'
	local padding = args['padding'] or '5px'
	local extrastyle = args['extrastyle'] or ''
	local message = args[1] or args['Message'] or ''
	
	local tag = mw.html.create( 'div' )
				:attr( 'id', 'messageBox' )
				:attr( 'align', 'center' )
				:css( 'width', width )
				:css( 'text-align', textalign )
				:css( 'font-size', fontsize )
				:css( 'border', '1px solid '..border )
				:css( 'background', background )
				:css( 'border-radius', '10px' )
				:css( 'margin', margin )
				:css( 'clear', clear )
				:css( 'padding', padding )
				:wikitext( message )
				:done()
	if not h.isempty(extrastyle)
		then tag:cssText (extrastyle):done()
	end
	
	return tostring(tag)
end


--------------------------------------------------------------------------------
-- creates message box with spoiler warning 
function p.spoiler_warning()
	local background = 'rgb(255, 102, 102)'
	local border = 'rgb(255, 20, 20)'
	local extrastyle = 'color: white; clear: both;'
	local header = p.span('Spoiler Warning!').bold
	local message = '<br>This page may contain spoilers with plot and/or ending details about stories which have been only recently published or broadcast.<br>'
	message = message..'Please see our [[Marvel Database:Spoilers|spoiler policy]] for our rules governing articles about such subjects.'

	return p.messagebox( {Message = header..message, background = background, border = border, extrastyle = extrastyle}) 
end


--------------------------------------------------------------------------------
-- creates table with "previous" and "next" sections
function p.table_previous_and_next(message, link_to_previous, link_to_next)
	local td_left = mw.html.create('td')
					:css('width', '10%')
					:css('max-width', '20%')
					--:css('border-right', '1px solid '..p.get_main_border_color() )
					:css('text-align', 'left')
	local td_right = mw.html.create('td')
					:css('width', '10%')
					:css('max-width', '20%')
					--:css('border-left', '1px solid '..p.get_main_border_color() )
					:css('text-align', 'right')
	local td_left_arrow = mw.html.create('td')
					:css('vertical-align', 'middle')
					:css('font-size', '18px')
					:css('width', '1%')
					:wikitext('←')
	local td_right_arrow = mw.html.create('td')
					:css('vertical-align', 'middle')
					:css('font-size', '18px')
					:css('width', '1%')
					:wikitext('→')
	local td_empty = mw.html.create('td')
					:css('width', '11%')
	local tr = mw.html.create('tr')
	local left = ''
	local right = ''
	local output = mw.html.create('table')
					:css('width', '100%')
			
	if h.isempty(message)
		then message = ''
	end
	message = tostring( mw.html.create('td'):wikitext(message) )
	
	if h.isempty(link_to_previous)
		then left = tostring(td_empty)
		else left = tostring(td_left_arrow)..tostring(td_left:wikitext(link_to_previous))
	end
	if h.isempty(link_to_next)
		then right = tostring(td_empty)
		else right = tostring(td_right:wikitext(link_to_next))..tostring(td_right_arrow)
	end
	tr = tostring( tr:wikitext(left..message..right) )
	output = tostring( output:wikitext(tr) )
			
	return output
end

--------------------------------------------------------------------------------
function p.show_hide(frame)
	local args = getArgs (frame)
	local title = args['title'] or args['header'] or ' '
	local body = args['body'] or args['text'] or ''
	local collapsed = args['collapsed']
	local clear = args['clear'] or 'both'
	local border = args['border'] or p.get_main_border_color()
	local extrastyle = args['extrastyle'] or ''
	local extrastyle2 = args['extrastyle2'] or ''
	local extrastyle3 = args['extrastyle3'] or ''
	local width = args['width'] or '100%'
	local background = args['background'] or p.get_main_background_color()
	local titlestyle = args['titlestyle'] or ''
	local expandtext = args['expandtext'] or 'Expand'
	local collapsetext = args['collapsetext'] or 'Collapse'

	if h.isempty(collapsed) or collapsed == 'true' or collapsed == true
		then collapsed = ' mw-collapsed'
		else collapsed = ''
	end

	local tag_td = mw.html.create( 'td' )
		:css( 'margin', '0.5em' )
		:css( 'font-size', '12px' )
		:wikitext(body)
		:done()
	if not h.isempty(extrastyle3)
		then tag_td:cssText (extrastyle3):done()
	end
	tag_td = '<tr>'..tostring(tag_td)..'</tr>'

	local tag_div = mw.html.create( 'div' )
		:css( 'font-weight', 'bold' )
		:wikitext(title)
		:done()
	if not h.isempty(titlestyle)
		then tag_div:cssText (titlestyle):done()
	end
	tag_div = tostring(tag_div)
	
	local tag_th = mw.html.create( 'th' )
		:attr('colspan', '1')
		:css( 'background-color', background )
		:css( 'font-size', '12px' )
		:wikitext(tag_div)
		:done()
	if not h.isempty(extrastyle2)
		then tag_th:cssText (extrastyle2):done()
	end
	tag_th = '<tr>'..tostring(tag_th)..'</tr>'
	
	local tag_table = mw.html.create( 'table' )
		:addClass('mw-collapsible'..collapsed)
		:attr('data-expandtext', expandtext)
		:attr('data-collapsetext', collapsetext)
		:css( 'clear', clear )
		:css( 'border', '1px solid '..border )
		:css( 'font-size', '12px' )
		:css( 'width', width )
		:wikitext(tag_th..tag_td)
		:done()
	if not h.isempty(extrastyle)
		then tag_table:cssText (extrastyle):done()
	end
	
	return tostring(tag_table) 
end


--------------------------------------------------------------------------------
function p.add_header(text, level, align)
	local output = ''
	level = level or '2'
	align = align or 'left'
	
	if not h.isempty(text)
		then output = '\n'..tostring( mw.html.create( 'h'..level ):css('text-align', align):wikitext( text ) )
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.lua_add_tooltip(text, tooltip)
	local output = mw.html.create('span')
					:css('border-bottom', '1px dotted')
					:css('cursor', 'help')
					:attr('title', tooltip)
					:wikitext(text)
	return tostring(output)
end

--*******************************************************************************************
-- ************* functions to create INFOBOX *************

--------------------------------------------------------------------------------
function p.create_infobox(text, width)
	width = width or '250px'
	text = text or ''

	return '__NOEDITSECTION__'..tostring( mw.html.create( 'div' )
		:attr('class', 'infobox')
		:css( 'width', width )
		:css( 'float', 'right' )
		:css( 'clear', 'none' )
		:css( 'margin', '0px 0px 1em 1em' )
		:css( 'border', '1px solid '..p.get_main_border_color() )
		:css( 'background', p.get_main_background_color() )
		:css( 'border-radius', '10px' )
		:css( 'padding', '10px' )
		:wikitext(text)
		:done() )
end


--------------------------------------------------------------------------------
function p.add_infobox_row(label, value)
	local width_l = '40%'
	local width_r = '60%'
	local tag_label
	local tag_value
	local output = ''
	
	if not h.isempty(value)
		then
			if string.find(value, '^\n') == nil
				then value = '\n'..value
			end
			
			tag_label = mw.html.create( 'div' )
				:css( 'width', width_l )
				:css( 'text-align', 'left' )
				:css( 'float', 'left' )
				:css( 'font-weight', 'bold')
				:wikitext(label)
				:done()
			tag_value = mw.html.create( 'div' )
				:css( 'width', width_r )
				:css( 'text-align', 'left' )
				:css( 'float', 'left' )
				:wikitext(value)
				:done()
				
			tag_label = tostring(tag_label)
			tag_value = tostring(tag_value)
			
			output = mw.html.create( 'div' )
				:css( 'border-top', '1px solid '..p.get_main_border_color() )
				:css( 'padding', '2px 0px 2px 0px')
				:css( 'height', '1.5em' )
				:css( 'text-align', 'center' )
				:css( 'clear', 'left' )
				:css( 'font-size', '12px' )
				:wikitext(tag_label..tag_value)
				:done()
			output = tostring(output)
	end

	return output
end

--------------------------------------------------------------------------------
-- for fields with a lot of text
function p.add_infobox_row_collapsible(label, value, formerly_sub_section)
	local i
	local j
	local output = ''
	
	-- boolean variable used to check if 'value' should be divided into two parts - current and former, 
	-- for example for team leaders - current would be displayed, while former would be hidden into collapsible table.
	formerly_sub_section = formerly_sub_section or false
	
	if not h.isempty(value) and #value > 500
		then 
			i, j = string.find(value, '; formerly ') 
			if i ~= nil and formerly_sub_section == true
				then value = string.sub(value, 1, i-1) .. '<br>' .. p.show_hide( { title = 'Formerly',  body = string.sub(value, j+1, #value) } )
				else value = p.show_hide( {
						title = '', 
						body = value, 
						collapsed = 'true',
						extrastyle = 'width: 100%; margin: 0px; text-align: left; border: none;',
						extrastyle2 = 'background-color: transparent;',
					} )
			end
	end
	output = p.add_infobox_row(label, value)

	return output
end


--------------------------------------------------------------------------------
function p.add_infobox_group(group, header)
	local output = ''
	
	if table.concat(group) ~= ''
		then
			header = mw.html.create( 'div' )
			:css( 'clear', 'both' )
				:css( 'text-align', 'center' )
				:css( 'font-weight', 'bold' )
				:css( 'padding', '10px' )
				:css( 'height', '1.5em' )
				:css( 'background', p.get_main_background_color())
				:css( 'font-size', '14px' )
				:wikitext(header)
				:done()
			output = tostring(header)..'\n'..table.concat(group)
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.add_infobox_horizontal_group(frame)
	local args = getArgs (frame)
	local centralheader = args['central_header'] or ''
	local leftheader = args['left_header'] or ''
	local lefttext = args['left_text'] or ''
	local rightheader = args['right_header'] or ''
	local righttext = args['right_text'] or ''
	local totalwidth = args['total_width']
	local tag_centralheader
	local tag_leftheader
	local tag_rightheader
	local tag_lefttext
	local tag_righttext
	local output = ''
 
	if not h.isempty(righttext)
		then 
			if not h.isempty(totalwidth)
				then totalwidth = tostring(tonumber(totalwidth)/2)..'px' 
				else totalwidth = '50%'
			end
		else totalwidth = '100%'
	end

	if not h.isempty(centralheader)
		then
			tag_centralheader = mw.html.create( 'div' )
				:css( 'width', '100%' )
				:css( 'float', 'left' )
				:css( 'font-weight', 'bold')
				:css( 'font-size', '12px' )
				:wikitext(centralheader)
				:done()
			output = output..tostring(tag_centralheader)
		else
			tag_leftheader = mw.html.create( 'div' )
				:css( 'width', totalwidth )
				:css( 'float', 'left' )
				:css( 'font-weight', 'bold')
				:css( 'font-size', '12px' )
				:wikitext(leftheader)
				:done()
			output = output..tostring(tag_leftheader)
	end
 
	if not h.isempty(righttext) and h.isempty(centralheader)
		then
			tag_rightheader = mw.html.create( 'div' )
					:css( 'width', totalwidth )
					:css( 'float', 'left' )
					:css( 'clear', 'right' )
					:css( 'font-weight', 'bold')
					:css( 'font-size', '12px' )
					:wikitext(rightheader)
					:done()
			output = output..tostring(tag_rightheader)
	end
 
	tag_lefttext = mw.html.create( 'div' )
		:css( 'width', totalwidth )
		:css( 'float', 'left' )
		:css( 'clear', 'left' )
		:css( 'font-size', '12px' )
		:wikitext(lefttext)
		:done()
	output = output..tostring(tag_lefttext)
 
 
	if not h.isempty(righttext)
		then
			tag_righttext = mw.html.create( 'div' )
					:css( 'width', totalwidth )
					:css( 'float', 'left' )
					:css( 'text-align', 'center' )
					:css( 'font-size', '12px' )
					:wikitext(righttext)
					:done()
			output = output..tostring(tag_righttext)
	end
 
	return tostring( mw.html.create( 'div' )
		:css( 'border-top', '1px solid '..p.get_main_border_color() )
		:css( 'text-align', 'center' )
		:css( 'clear', 'left' )
		:wikitext(output)
		:done() )
end 


--------------------------------------------------------------------------------
function p.add_infobox_page_title_and_image(args, pagename, page_type)
	local title = args.Title
	local name = args.OfficialName
	local image = args.Image or args.Video
	local image_size = '250px'
	local image_text = args.ImageText
	local alias = ''
	local gallery = ''
	local i
	local output_categories = {}
	local output = ''

	if page_type == 'Character'
		then
			name = args.RealName
			alias = args.CurrentAlias
		elseif page_type == 'Race'
			then name = args.Name
	end
	
	if not h.isempty(title)
		then output = title
		elseif not h.isempty(alias)
			then output = alias
		elseif not h.isempty(name)
			then output = name
		else output = pagename
	end
	
	if not h.is_link(output) and h.exists(output)
		then output = h.Link(output)
	end

	output = mw.html.create('div')
			:css('text-align', 'center')
			:css('font-size', '18px')
			:css('font-weight', 'bold')
			:css('line-height', '2em')
			:wikitext(output)
	output = tostring( output )

	if not h.isempty(image_size)
		then image_size = string.gsub(image_size, 'px', '')..'px'
	end
	if not h.isempty(image)
		then 
			image = string.gsub(image, 'File:', '')
			if not h.exists('File:'..image)
				then table.insert(output_categories, page_type..' Image Correction Needed')
			end
			if h.in_list({'None.jpg', 'Needed.png'}, image)
				then table.insert(output_categories, page_type..' Image Needed')
			end
			if h.isempty(image_text)
				then image_text = image
			end
			if image ~= 'No Image Available At All.png'
				then output = output .. '[[File:'..image..'|'..image_size..'|center|'..image_text..']]'
			end
		else
			table.insert(output_categories, page_type..' Image Needed')
	end
	
	if h.pages_in_category(pagename..'/Images', 'files') > 0 
	or ( not h.isempty(image) and not h.in_list({'None.jpg', 'Needed.png', 'No Image Available At All.png'}, image) )
		then 
			gallery = h.Link(pagename..'/Gallery', 'Gallery')
			if not h.exists(pagename..'/Gallery')
				then table.insert(output_categories,  page_type..' Gallery Page Needed')
			end
			gallery = mw.html.create('div')
						:css('text-align', 'center')
						:css('font-size', '14px')
						:css('font-weight', 'bold')
						:css('font-style', 'italic')
						:css('line-height', '2em')
						:wikitext(gallery)
			output = output .. tostring(gallery)
	end

	return output, output_categories
end


-------------------------------------------------------------------------------
function p.add_infobox_official_name(args, page_type)
	local name = args.OfficialName
	local name2 = args.OfficialName2
	local ref = args.OfficialNameRef
	local label = "Official Name"
	local output = ''

	if page_type == 'Character'
		then
			name = args.RealName
			name2 = args.RealName2
			ref = args.RealNameRef
			label = "Real Name"
		elseif page_type == 'Race'
			then 
				name = args.Name
				name2 = args.Name2
				ref = args.NameRef
				label = "Name"
	end
	
	if h.isempty(name)
		then output = 'Unknown'
		else output = name
	end
	if not h.isempty(name2)
		then output = output..' '..name2
	end
	if not h.isempty(ref)
		then output = output..ref
	end

	return p.add_infobox_row(label, output)
end

--------------------------------------------------------------------------------
function p.add_infobox_appearances_and_creators(args, page_type)
	local value
	local categories
	local output_categories = {}
	local output = {}

	value, categories = p.add_infobox_creators(args, page_type)
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.add_infobox_appearances(args, page_type)
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	return p.add_infobox_group(output, 'Creators and Appearances'), output_categories
end

--------------------------------------------------------------------------------
function p.add_infobox_appearances(args, page_type)
	local standard = require("Module:StandardizedName")
	local first_appearance = ''
	local last_appearance
	local last_appearance2
	local last_header
	local debut
	local output_categories = {}
	local output = {}

	if not h.isempty(args.First)
		then 
			first_appearance, debut = standard.lua_get_link_and_release_date(args.First)
			if not h.isempty(debut)
				then
					debut = string.match(debut, '(%d%d%d%d)')
					if debut ~= nil
						then 
							if not h.isempty(page_type)
								then table.insert(output_categories, debut..' '..page_type..' Debuts')
								else table.insert(output_categories, debut..' Debuts')
							end
					end
			end	
		elseif h.isempty(args.First2)
			then
				if not h.isempty(page_type)
					then first_appearance = page_type..' First Appearance Needed'
					else first_appearance = 'First Appearance Needed'
				end
				table.insert(output_categories, first_appearance)
				first_appearance = h.LinkToCategory(first_appearance, 'Unknown')
	end
	if not h.isempty(args.First2)
		then first_appearance = first_appearance .. args.First2
	end

	if not h.isempty(args.Death) or not h.isempty(args.Death2)
		then 
			last_header = 'Appearance of Death'
			last_appearance = args.Death
			last_appearance2 = args.Death2
		elseif not h.isempty(args.Destruction) or not h.isempty(args.Destruction2)
			then
			last_header = 'Destruction'
			last_appearance = args.Destruction
			last_appearance2 = args.Destruction2
		else
			last_header = 'Last Appearance'
			last_appearance = args.Last
			last_appearance2 = args.Last2
	end
	if not h.isempty(last_appearance)
		then last_appearance = standard.lua_get_link_and_release_date(last_appearance)
		else last_appearance = ''
	end
	if not h.isempty(last_appearance2)
		then last_appearance = last_appearance .. last_appearance2
	end
	
	output = {  left_header = 'First Appearance', 
				left_text = first_appearance,
				right_header = last_header, 
				right_text = last_appearance,
			}
	output = p.add_infobox_horizontal_group(output)

	return output, output_categories
end


--------------------------------------------------------------------------------
function p.add_infobox_creators(args, page_type)
	local SC = require("Module:StaffCorrection")
	local creators = args.Creators
	local creators2 = args.Creators2
	local output_categories = {}
	local output = ''
	
	if not h.isempty(creators) or not h.isempty(creators2)
		then
			output, output_categories = SC.lua_get_creators(creators)
	
			if not h.isempty(creators2)
				then output = output..creators2
			end
		else table.insert(output_categories, page_type..' Creators Needed')
	end
	
	return p.add_infobox_row('Creators', output), output_categories
end


--------------------------------------------------------------------------------
function p.add_infobox_reality(args, pagename, page_type)
	local module_reality = require("Module:Reality")
	local i
	local reality1 = args.Universe
	local reality2 = args.Universe2
	local value
	local category
	local output_categories = {}
	local output = {}

	if h.isempty(reality1) and h.isempty(reality2) 
		then 
			if h.in_list({'/Characters', '/Teams', '/Organizations'}, page_type)
				then table.insert(output_categories, 'Unspecified Reality')
			end
			if string.find(pagename, '(', 1, true) ~= nil
				then
					_, reality1 = module_reality.lua_get_name_and_reality(pagename)
					reality1 = reality1.name
			end
	end
	
	if not h.isempty(reality1)
		then 
			if string.find(reality1, ';') ~= nil
				then 
					reality1  = mw.text.split(reality1, ';')
					for i = 1, #reality1 do
						value = reality1[i]
						value = module_reality.get_reality_info({value, 1})
						if value ~= nil
							then
								table.insert(output, h.Link(value))
								table.insert(output_categories, value..page_type)
						end
					end
				else
					value = module_reality.get_reality_info({reality1, 1})
					if value ~= nil
						then
							table.insert(output, h.Link(value))
							table.insert(output_categories, value..page_type)
					end
			end
	end
	
	if not h.isempty(reality2)
		then 
			value = module_reality.get_reality_info({reality2, 1})
			if value ~= nil
				then
					table.insert(output, h.Link(value))
					table.insert(output_categories, value..page_type)
			end
	end
	
	output = mw.text.listToText(output, ', ', ', ')
	return p.add_infobox_row('Reality', output), output_categories
end


--------------------------------------------------------------------------------
function p.add_overview_and_toc(overview)
	local output = '__TOC__'
	
	if not h.isempty(overview)
		then output = overview..'<br>'..output
	end
	
	return output
end


--------------------------------------------------------------------------------
function p.add_quote(args)
	local output_categories = {}
	local output = ''
	
	if not h.isempty(args.Quotation)
		then output, output_categories = require("Module:Quote").main(args.Quotation, args.Speaker, args.QuoteSource, true)
	end
	if not h.isempty(args.BlockQuote)
		then 
			output = args.BlockQuote
			table.insert(output_categories, 'BlockQuotes')
	end
	
	return output, output_categories
end

--------------------------------------------------------------------------------
-- used to add sections like "Notes", "Trivia", etc.
function p.add_section(header, section, header_level)
	local output = ''
	
	header_level = header_level or 2
	
	if not h.isempty(section)
		then output = p.add_header(header, header_level)..'\n'..section
	end
	
	return output
end


--------------------------------------------------------------------------------
-- used to add links to standard sub-pages/categories - "Appearances", "Minor Appearances", Mentions", "Images", "Quotes" and "Gallery" 
function p.add_links_to_standard_subpages(pagename, page_type)
	local value
	local category
	local output_categories = {}
	local output = {}
	
	value, categories = p.links_to_subcategories(pagename..'/Appearances', 'pages', pagename, ' appearance(s) of ', page_type..' Appearances Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/Minor Appearances', 'pages', pagename, ' minor appearance(s) of ', page_type..' Minor Appearances Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)
	
	value, categories = p.links_to_subcategories(pagename..'/Mentions', 'pages', pagename, ' mention(s) of ', page_type..' Mentions Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	value, categories = p.links_to_subcategories(pagename..'/Images', 'files', pagename, ' image(s) of ', page_type..' Images Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	value, categories = p.links_to_subcategories(pagename..'/Quotes', 'pages', pagename, ' quotation(s) by or about ', 'Quotes Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	value, categories = p.links_to_subcategories('Killed by '..pagename, 'pages', pagename, ' victim(s) killed by ', 'Killed By Category Needed')
	output_categories = h.join_tables(output_categories, categories)
	table.insert(output, value)

	if page_type ~= 'Reality'
		then
			value, categories = p.links_to_subcategories(pagename..'/Items', 'pages', pagename, ' item(s) used/owned by ', 'Items Category Needed')
			output_categories = h.join_tables(output_categories, categories)
			table.insert(output, value)
	end
	
	return output, output_categories
end


function p.links_to_subcategories(category, page_types, pagename, text, needed)
	local n = 0
	local output_category = ''
	local output = ''
	
	n = h.pages_in_category(category, page_types)
	if n > 0
		then 
			output = '\n* '..h.LinkToCategory(category, n..text..pagename)
			if not h.exists('Category:'..category)
				then output_category = needed
			end
	end

	return output, output_category
end


--------------------------------------------------------------------------------
function p.add_links_and_references(args, pagename)
	local value
	local output = {}
	
	table.insert(output, p.add_header('Links and References', 2) )
	
	value = args.Wikipedia
	if not h.isempty(value)
		then 
			value = h.Link('Wikipedia:'..value, pagename..' at Wikipedia.org')
			table.insert(output, '\n* '..value)
	end

	value = args.Links
	if not h.isempty(value)
		then table.insert(output, '\n'..value)
	end

	table.insert(output, p.add_list_of_references() )

	value = tostring( mw.html.create('span'):attr('id', 'twitter-button') )
	value = mw.html.create('div')
			:css('width', '99%')
			:css('padding', '5px')
			:css('text-align', 'center')
			:css('font-weight', 'bold')
			:css('border-top', '1px solid #AAAAAA')
			:css('border-bottom', '1px solid #AAAAAA')
			:wikitext('Like this? Let us know!   '..value)
	table.insert(output, tostring(value))

	return table.concat(output)
end


--------------------------------------------------------------------------------
function p.add_list_of_references()
	local output = mw.html.create('div')
	:css('overflow', 'auto')
	:css('height', 'auto')
	:css('max-height', '250px')
	:css('width', '99%')
	:css('font-size', '12px')
	:css('border', '1px solid #AAAAAA')
	:wikitext('<references group="note" /><references />')

	return p.add_header('Footnotes', 3)..'\n'..tostring(output)
end

return p