Module:Cite

-- This module implements cite templates. -- See for the base template and a documentation. local cite = {} local getArgs = require('Dev:Arguments').getArgs local data = mw.loadData('Module:Codename') -- Helper functions local function gamelink(game) game = string.lower(game) local link = data[game]['link'] local shortname = data[game]['shortname'] return string.format("[" .. "[" .. "%s|\'\'%s\'\']]", link, shortname) end local function gamefile(file) return string.format(', file: ', file) end local function script(game, scriptsection, display) game = string.lower(game) local gamename = data[game]['shortname'] if display then return string.format(' [' .. '[' .. '%s script#%s|script &sect; \"%s\"]]', gamename, scriptsection, display) else return string.format(' [' .. '[' .. '%s script#%s|script &sect; \"%s\"]]', gamename, scriptsection, scriptsection) end end -- Produces the cite template. function cite.main(frame) local args = getArgs(frame) local game = args['game'] or args[1] local gamesec = '' if game then gamesec = gamelink(game) end local contentsec = '' if args['file'] then contentsec = gamefile(args['file']) elseif args['script'] then contentsec = script(game, args['script'], args['display']) elseif args['guide'] then contentsec = ", ''" .. data[game]['guide']['title'] .. "'', p. " .. args['guide'] elseif args['manual'] then contentsec = ', ' .. data[game]['manual'][args['version']] .. ', p. ' .. args['manual'] elseif args[2] or args['other'] then contentsec = ', ' .. (args[2] or args['other']) end local refname = '' if args['name'] then refname = ' name="' .. args['name'] .. '"' end local citeoutput = '' .. gamesec .. contentsec .. ' '	return frame:preprocess(citeoutput) end return cite