Module:Live song/sandbox

local p = {}

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

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

return out .. ']]' end

local function live_debut(name) local page_title = mw.title.getCurrentTitle.text local show_date = p._parse_date(page_title) local cargo = mw.ext.cargo local debut = cargo.query(		'live_songs, ',		'MIN(date)=date',		{			where = 'name = "' .. name .. '" AND abandoned = 0 AND soundcheck = 0 AND tease = 0'		}	)

if next(debut) == nil then return false end

return debut[1]['date'] == show_date end

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

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

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

out = out .. '" '

if cover ~= '' then out = out .. '&#91;' .. cover .. '&#93; '	end

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

if acoustic ~= '' then out = out .. '(acoustic)' end

if note ~= '' then out = out .. '(' .. note .. ') ' end if length ~= '' then out = out .. '[' .. length .. '] '	end if live_debut(name) then out = out .. "[ live debut ]" 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] local acoustic = frame.args[8] return p._entry(name, title, note, cover, tease, abandoned, length, acoustic) end

function p._parse_date(title) return string.match(title, "%d%d%d%d%-%d%d%-%d%d") end

function p.parse_date(frame) local name = frame.args[1] return p._parse_date(name) end

return p