Module:CitePodcast

local p = {}

local episodes = mw.loadData('Module:CitePodcast/data') local ref = require('Module:Reftag') local params = require('Module:Paramtest')

local function setup(frame) local args = frame:getParent.args local podcast = episodes[args.episode] if not podcast then error('Episode not found: "'..(args.episode or '')..'"') end local name,group,author,quote, time,notes = params.defaults{ {args.name,nil}, {args.group,nil}, {args.author,nil}, {args.quote,nil}, {args.time,nil}, {args.notes,nil} }	return { podcast.url, podcast.title, podcast.date, podcast.type, name, group, author, quote, time, notes } end

local function citation(...) local url,title, date,type, name,group,author,quote, time,notes = unpack(...) local ret = 'Jagex. ['..url..' '..title..']' if author then ret = ret..' '..author end if quote then ret = ret..tostring(				mw.html.create('span')					:addClass('refhide')					:wikitext(' : "'..quote..'"') ) end if time then ret = ret..' ('..time..')' end ret = ret..' '..type..', '..date..'.' if notes then ret = ret..' '..notes end return ret, name, group end

function p.valid_params local ret = mw.html.create('ul') for n, v in pairs(episodes) do		ret:tag('li') :wikitext(n) :done end table.sort(ret, function(a,b)			return string.byte(a)<=string.byte(b)		end) return ret end

function p.plain(frame) local ret, name, group = citation(setup(frame)) return ret end

function p.main(frame) local ret, name, group = citation(setup(frame)) return ref{name = name, group = group, text = ret} end

return p