Module:Live song

From SPCodex, The Smashing Pumpkins wiki
Revision as of 22:15, 3 August 2020 by MusikAnimal (talk | contribs)

Documentation for this module may be created at Module:Live song/doc

local p = {}

local function link(name, title)
	local out = '[['

	if title == '' then
		out = out .. name
	else
		out = out .. name .. '|' .. title
	end

	return out .. ']]'
end

function p._entry(name, title, note, cover, tease, abandoned, length)
	local out = '"'

	if cover ~= '' and (tease ~= '' or abandoned ~= '') then
		local mw_title = mw.title.makeTitle(0, name)

		if mw_title.exists then
			out = out .. link(name, title)
		else
			out = out .. name
		end
	else
		out = out .. link(name, title)
	end

	out = out .. '" '

	if cover ~= '' then
		out = out .. '[' .. cover .. '] '
	end

	if tease ~= '' and abandoned ~= '' then
		out = out .. '(tease / abandoned) '
	elseif tease ~= '' then
		out = out .. '(tease) '
	elseif abandoned ~= '' then
		out = out .. '(abandoned) '
	end

	if note ~= '' then
		out = out .. '(' .. note .. ') '
	end
	
	if length ~= '' then
		out = out .. '[' .. length .. ']'
	end

	return out
end

function p.entry(frame)
	local name = frame.args[1]
	local title = frame.args[2]
	local note = frame.args[3]
	local cover = frame.args[4]
	local tease = frame.args[5]
	local abandoned = frame.args[6]
	local length = frame.args[7]
	return p._entry(name, title, note, cover, tease, abandoned, length)
end

return p