This module depends on the following other modules: |
To generate {{Infobox song}}, invoke using the main function.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local args = {}
local colors = {
vs = { bg = '#00CDBA', text = '#FFFFFF' },
ln = { bg = '#4455DD', text = '#FFFFFF' },
mmj = { bg = '#6CCB20', text = '#FFFFFF' },
vbs = { bg = '#EE1166', text = '#FFFFFF' },
wxs = { bg = '#FF9900', text = '#FFFFFF' },
niigo = { bg = '#884499', text = '#FFFFFF' }
}
local palette = { bg = '#FFAFA8', text = '#FFFFFF' }
local default_jacket = 'Dummyalbumart.png'
local units = {
vs = { image = 'Virtualsingerlogo.png', link = 'VIRTUAL SINGERS' },
ln = { image = 'Leoneedlogo.png', link = 'Leo/need' },
mmj = { image = 'MMJ_logo.png', link = 'MORE MORE JUMP!'},
vbs = { image = 'Vivid_logo.png', link = 'Vivid BAD SQUAD'},
wxs = { image = 'Wonderlandsxswowtimelogo.png', link = 'Wonderlands×Showtime' },
niigo = { image = '25ji-logo.png', link = '25-ji, Night Code de.' }
}
local root
local function addRow(label, data)
if data then
local row = root:tag('tr')
row:attr('id', label)
row:tag('th')
:attr('scope', 'row')
:wikitext(label)
:done()
local dataCell = row:tag('td')
dataCell
:wikitext(data)
end
end
local function addHeader(label)
local row = root:tag('tr')
row:tag('th')
:attr('colspan', 2)
:css({
['text-align'] = 'center',
['background-color'] = palette.bg,
color = palette.text
})
:wikitext(label)
end
local function addSongJacket(file)
local image
if file then
image = file
else
image = default_jacket
end
local row = root:tag('tr')
row:tag('td')
:attr('colspan', 2)
:css('text-align', 'center')
:wikitext(
string.format(
"[[File:%s|220px]]",
image
)
)
end
local function addUnitRow(unit)
if unit and units[unit] then
local row = root:tag('tr')
local unit_info = units[unit]
row:tag('th')
:wikitext('Unit')
row:tag('td')
:wikitext(
string.format(
"[[File:%s|150px|link=%s]]",
unit_info.image,
unit_info.link
)
)
end
end
function p.box(frame)
args = getArgs(frame)
if args.bg_color or args.text_color then
if args.bg_color then
palette.bg = args.bg_color
end
if args.text_color then
palette.text = args.text_color
end
elseif args.unit and colors[args.unit] then
palette = colors[args.unit]
end
root = mw.html.create('table')
root
:addClass('infobox')
:css('width', '22em')
addHeader(args.songtitle)
addSongJacket(args.image)
addRow('Original Song Title', args.kanji)
addRow('Romaji', args.romaji)
addRow('English', args.english)
addHeader('Information')
addRow('Producer(s)', args.producer)
addRow('Composer', args.composer)
addRow('Lyricist', args.lyricist)
addUnitRow(args.unit)
addRow('BPM', args.bpm)
addRow('Duration', args.duration)
addRow('MV', args.mv)
return tostring(root)
end
return p