Module:Live song/sandbox
Documentation for this module may be created at Module:Live song/sandbox/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
local function live_debut(name)
local page_title = mw.title.getCurrentTitle()
mw.log(page_title)
local show_date = p._parse_date(page_title)
mw.log(show_date)
local cargo = mw.ext.cargo
local debut = cargo.query(
'live_songs, ',
'MIN(date)=date',
{
where = 'name = "' .. name .. '" AND abandoned = 0 AND soundcheck = 0'
}
)
if next(debut) == nil then
return false
end
mw.logObject(debut[1]['date'])
mw.logObject(show_date)
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 .. '[' .. 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 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 .. "[<span style='color:green'>live debut</span>]"
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