Module:Film

require('strict')

local p = {}

local getArgs = require('Module:Arguments').getArgs
-- local yesno = require('Module:Yesno')
local error_message = require('Module:Error')['error']

local film_song_list = require('Module:Film song')._film_song_list
local generateCastAndCrew = require('Module:Cast and crew')._generateCastAndCrew
local pre_code_check = require('Module:Pre-Code film').check
-- local blackface_warning = require('Module:Blackface').blackface

function p.film_key()
	local film_key = mw.html.create('table')
		:addClass('wst-film-key')
		:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:tag('span')
					:addClass('key')
					:wikitext('Key')
					:done()
				:wikitext(' ')
				:tag('span')
					:addClass('info')
					:wikitext('([[Help:Film|info]])')
					:done()
				:done()
			:done()
		:tag('tr')
			:tag('td')
				:addClass('dialog')
				:done()
			:tag('td')
				:wikitext('Dialogue')
				:done()
			:done()
		:tag('tr')
			:tag('td')
				:addClass('in_scene')
				:done()
			:tag('td')
				:wikitext('In scene')
				:done()
			:done()
		:tag('tr')
			:tag('td')
				:addClass('storyline')
				:done()
			:tag('td')
				:wikitext('Storyline')
				:allDone()
	return film_key
end

function p._film(args)
	if not args[1] then
		return error_message({'[[Module:Film]] error: no file provided'})
	end
	
	local container = mw.html.create('div'):addClass('wst-film-container')
		-- container:wikitext(yesno(args.blackface) and blackface_warning())
		:node(p.film_key())
		:tag('div')
			:addClass('wst-film-file')
			:wikitext('[[File:' .. args[1] .. '|center|thumbtime=' .. (args.thumbtime or '') .. '|' .. (args.size or '400px') .. ']]')
			:done()
		:node(film_song_list({args['wikidata_id']}))
		:node(generateCastAndCrew({args['wikidata_id']}))
		:tag('div')
			:addClass('wst-transcript-info')
			:wikitext('[[File:Video Camera Icon.svg|20px]] The following is a transcription of a [[Portal:Film|film]]. The contents below represent text or spoken dialogue that are transcribed directly from the video of the film provided above. On certain screen sizes, each line is represented by a timestamp next to it which shows when the text appears on the video. For more information, see [[Help:Film]].')
			:done()
		:tag('div')
			:css({['clear'] = 'both'})
			:done()
		:wikitext(pre_code_check())
		:wikitext(args.category or '[[Category:' .. 'Film' .. ']]')
	
	return container
end

function p.film(frame)
	return p._film(getArgs(frame))
end

return p