Module:InsiderCite

-- This module implements Template:InsiderCite.

local p = {}

function p._main(args) -- Define defaults local image = 'SWInsider_small.jpg' local publication = 'Star Wars Insider' local defaultIssue = ''

-- Find optional values, and override defaults if necessary local size, page, display, issue, extra if args[1] and (			args[1]:find('^Special%s')			or args[1]:find('^Best%s') 			or args[1]:find('^Digital%s')		) then if args[2] then page = args[2] display = args[3] or args[2] end issue = args[1] or defaultIssue elseif args.issue1 then if args[1] then page = args[1] display = args[2] or args[1] end issue = args.issue1 if args.issue2 then extra = string.format(				'–%s',				publication, args.issue2, args.issue2			) end elseif tonumber(args[1]) and tonumber(args[1]) <= 22 then image = 'LFCMlogo.jpg' publication = 'The Lucasfilm Fan Club Magazine' size = '35px' if args[2] then page = args[2] display = args[3] or args[2] end issue = args[1] or defaultIssue else if args[2] then page = args[2] display = args[3] or args[2] end issue = args[1] or defaultIssue end

-- Make the file link local fileLink = string.format(		,		image,		size and '|' .. size or 	)

-- Make the story link local storyLink if page and display then storyLink = string.format("\"%s\"&mdash;", page, display) else storyLink = '' end

-- Make the issue link local issueLink = string.format(		"%s %s",		publication, issue, publication, issue	)

-- Make the final output. extra = extra or '' return fileLink .. ' ' .. storyLink .. issueLink .. extra end

function p.main(frame) local args = {} for k, v in pairs(frame:getParent.args) do		v = v:match('^%s*(.-)%s*$') -- trim whitespace if v ~= '' then args[k] = v		end end return p._main(args) end

return p