Marvel Database
Advertisement
Marvel Database

Documentation for this module may be created at Module:Film Template/doc

-- module for Marvel Database:Episode Template
local p = {}
local getArgs = require('Module:Arguments').getArgs 
local h = require("Module:HF")
local design = require('Module:Design')
local standard = require("Module:StandardizedName")
local m_date = require("Module:Date")


function p.main(frame)
	local args = getArgs(frame)
	local pagename = mw.title.getCurrentTitle().text
	local page_type = 'Film'
	local released = false
	local release_date = args['Release Date']
	local year
	local month
	local day
	local value
	local categories = {}
	local output_categories = {}
	local output_infobox = {}
	local output = {}

	table.insert(output_categories, p.lua_get_outdated_fields(args) )
	
	if not h.isempty(release_date)
		then
			released = m_date.lua_date_comparison(release_date)
			
			month, day, year = string.match(release_date, '(%D+) (%d+), (%d%d%d%d)')

			_, category = m_date.lua_get_publication_category(year, month, day)
			table.insert(output_categories, category)
	end

-- sections
	value = require("Module:Quote").main(args.Tagline)
	table.insert(output, value)

	if released == true	
		then
			value = args.Appearances
			if h.isempty(value)
				then value = 'Appearances not yet listed'
			end
			table.insert( output, design.add_section('Appearances', value, 2) )

			value = args.Plot
			if h.isempty(value)
				then 
					value = 'Plot not yet listed'
					table.insert(output_categories, 'Film Synopsis Needed')
			end
			table.insert( output, design.add_section('Plot', value, 2) )
	end
	
	value = args.Cast
	if h.isempty(value)
		then value = 'Cast not yet listed'
	end
	table.insert( output, design.add_section('Cast', value, 2) )
	
	value = p.get_alternate_posters(args)
	table.insert( output, design.add_section('Alternate Posters', value, 2) )

	value, categories = design.add_notes_trivia_see_also_recommended_links_references(args, page_type, pagename)
	output_categories = h.join_tables(output_categories, categories)
	output = h.join_tables(output, value)
--
	output_categories = h.add_categories(output_categories)
	output = table.concat(output)
	
	return frame:preprocess(output)..output_categories
end


--------------------------------------------------------------------------------------------------
function p.lua_get_outdated_fields(args)
	local i
	local output = ''
	
	if  not h.isempty(args.Custom) 
		or not h.isempty(args.CustomLabel) 
		or not h.isempty(args.AppearancesHeader) 
		or not h.isempty(args.PlotHeader) 
		or not h.isempty(args.CastHeader)
		or not h.isempty(args.NotesHeader) 
		or not h.isempty(args.TriviaHeader) 
		or not h.isempty(args.SeeAlsoHeader) 
		or not h.isempty(args.LinksHeader)
		or not h.isempty(args.CustomSection1)
		or not h.isempty(args.CustomText1) 
		or not h.isempty(args.CustomSection2) 
		or not h.isempty(args.CustomText2) 
		or not h.isempty(args.RecommendedHeader) 
		or not h.isempty(args.ImageText) 
			then output = 'Outdated Fields/Film'
	end

	return output	
end


--------------------------------------------------------------------------------
function p.spoiler_alert(frame)
	local args = getArgs(frame)
	local release_date = args['Release Date']
	local year
	local month
	local day
	local output = ''

	month, day, year = string.match(release_date, '(%D+) (%d+), (%d%d%d%d)')
	if m_date.lua_is_recently_released_episode(year, month, day)
		then output = design.spoiler_warning()..h.Category('Spoilers')
	end

	return output
end

--------------------------------------------------------------------------------------------------
function p.get_previous(frame)
	local args = getArgs(frame)
	local previous1 = args['Previous Film']
	local previous2 = args['Previous Film2']
	local output = ''
	
	if ( h.isempty(previous1) and h.isempty(previous2) ) or h.in_list({'-', '--', '---', '—'}, previous1) 
		then output = '—'
		else output = standard.get_link_and_release_date({previous1})
	end
	if not h.isempty(previous2)
		then output = output..' '..previous2
	end

	return output
end


--------------------------------------------------------------------------------------------------
function p.get_next(frame)
	local args = getArgs(frame)
	local next1 = args['Next Film']
	local next2 = args['Next Film2']
	local output = ''

	if ( h.isempty(next1) and h.isempty(next2) ) or h.in_list({'-', '--', '---', '—'}, next1) 
		then output = '—'
		else output = standard.get_link_and_release_date({next1})
	end
	if not h.isempty(next2)
		then output = output..' '..next2
	end

	return output
end


--------------------------------------------------------------------------------------------------
function p.get_reality(frame)
	local args = getArgs (frame)
	local value = args.Reality or args.Universe
	local output = ''

	if not h.isempty(value)
		then
			value = require("Module:Reality").get_reality_info({args.Universe}).name
			output = h.Link(value, value)
	end
	
	return output
end


--------------------------------------------------------------------------------------------------
function p.get_staff(frame)
	local SC = require("Module:StaffCorrection")
	local args = getArgs(frame)
	local pagename = mw.title.getCurrentTitle().text
	local output_categories
	local output
	
	output, output_categories = SC.lua_get_list_of_staff(args[1], 'Writer')
	
	return output..h.add_categories(output_categories)
end


--------------------------------------------------------------------------------------------------
function p.get_alternate_posters(args)
	local i
	local value
	local output = {}

	for i = 2, 30 do
		value = args['Image'..i]
		if not h.isempty(value)
			then table.insert(output, '\n'..value)
		end
	end
	
	output = table.concat(output)
	
	if not h.isempty(output)
		then output = '{{#tag:gallery|'..output..'|position=center|captionalign=center|hideaddbutton=true|widths=200px}}'
	end
	
	return output
end
	

return p
Advertisement