Module:Introduction

local Introduction = {} local HF = require('Module:HF') local getArgs = require('Module:Arguments').getArgs local language = mw.language.new('en')

local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame) return Introduction[funcName](args) end end

Introduction.character = makeInvokeFunc('_character') Introduction.episode = makeInvokeFunc('_episode')

function Introduction._character( args ) local intro = {} local story = HF.parseStory( args.story ) or "" local plural = 1 local gender = args.gender or 'neutral' if not HF.isempty( args.plural ) then plural = 2 end if not HF.isempty( args.name ) then table.insert( intro, "'''" ) if not HF.isempty( args.honorific ) then table.insert( intro, args.honorific .. ' ' ) end table.insert( intro, "" .. args.name .. "''' " ) if not HF.isempty( args.othernames ) then local othernames = mw.html.create('span'):addClass('plainlinks'):wikitext( args.othernames ) table.insert( intro, tostring(othernames) .. ' ' ) end table.insert( intro, language:plural( plural, 'is ', 'are ' ) ) if not HF.isempty( args.description ) then table.insert( intro, args.description .. '. ') else table.insert( intro, language:plural( plural, 'a character. ', 'characters. ' ) )   end table.insert( intro, language:gender( gender, language:plural( plural, 'He ', 'They '), language:plural( plural, 'She ', 'They '), language:plural( plural, 'It ', 'They ' ) ) ) table.insert( intro, language:plural( plural, 'is ', 'are ' ) ) if not HF.isempty( args.maintitleorder ) then table.insert( intro, language:plural( plural, 'a main character ', 'main characters ' ) ) elseif HF.isempty(args.maintitleorder) and HF.episodeCount(args.appearances) > 3 then table.insert( intro, language:plural( plural, 'a supporting character ', 'supporting characters ' ) ) else table.insert( intro, language:plural( plural, 'a character ', 'characters ' ) ) end table.insert( intro, 'in ' ) if story == 'Murder House' then table.insert( intro, "the first season (dubbed by fans \"Murder House\")" ) elseif (story ~= "") then table.insert( intro,  .. story ..  ) else table.insert( intro, 'American Horror Story' ) end if not HF.isempty( args.portrayer ) then if not HF.isempty( args.altportrayer ) then table.insert( intro, ' primarily ' ) end table.insert( intro, ' portrayed by ' .. args.portrayer ) end table.insert( intro, '.' ) if not HF.isempty( args.additional ) then table.insert( intro, " " .. args.additional ) end end return table.concat( intro ) end

function Introduction._episode( args ) local introduction = '' local intro = {} local story = HF.parseStory( args.story ) or '' if not HF.isempty( args.name ) then table.insert( intro, "\"" .. args.name .."\" " ) if not HF.isempty( args.story ) and not HF.isempty( args.episode ) then table.insert( intro, 'is the '..HF.numtoordinal(args.episode)..' episode of ' ) if story == "Murder House" then table.insert( intro, "the first season (\"Murder House\")." ) elseif (story ~= '') then table.insert( intro, ''..story..'.' ) else table.insert( intro, 'American Horror Story.' ) end else table.insert( intro, 'is an episode of American Horror Story.' ) end if not HF.isempty( args.premiere) then table.insert( intro, ' It premiered '..HF._formatDate( args.premiere )..'.' ) end if not HF.isempty( args.additional ) then table.insert( intro, ' '..args.additional ) end end -- Synopsis is going to be args[2] return table.concat( intro ) end

function Introduction.delay(frame) local diff = os.difftime(language:formatDate('U',nil,false),language:formatDate('U',(frame.args['premiere'] .. 'T21:00:00-05:00'),false)) local output = diff return output end

return Introduction