Module:Songs: Difference between revisions

Jump to navigation Jump to search
19 bytes added ,  Thursday at 01:56
m
no edit summary
mNo edit summary
mNo edit summary
Line 65: Line 65:


local groups = {}
local groups = {}
local songPages = {}
local songTitles = {}
local songNames = {}
local songPageNames = {}
for _, result in ipairs(results) do
for _, result in ipairs(results) do
local singers = mw.text.split(result.singers, ",")
local singers = mw.text.split(result.singers, ",")
Line 84: Line 84:


if type ~= nil then
if type ~= nil then
if not groups[result.song_page] then groups[result.song_page] = {} end
if not groups[result.song_title] then groups[result.song_title] = {} end
songNames[result.song_page] = result.song_title
songPageNames[result.song_title] = result.song_page
table.insert(songPages, result.song_page)
table.insert(songTitles, result.song_title)
table.insert(groups[result.song_page], { album = result.album, type = type })
table.insert(groups[result.song_title], { album = result.album, type = type })
end
end
end
end


local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n'
local text = '{| class="wikitable sortable mw-collapsible"\n! Song !! Album !! Type\n'
for _, song in ipairs(songPages) do
for _, song in ipairs(songTitles) do
local rows = groups[song]
local rows = groups[song]
local rowspan = #rows
local rowspan = #rows
local head = table.remove(rows, 1)
local head = table.remove(rows, 1)
text = text ..
text = text ..
string.format('|-\n| rowspan=%d|[[%s|%s]] || [[%s]] || %s\n', rowspan, song, songNames[song], head.album, head.type)
string.format('|-\n| rowspan=%d|[[%s|%s]] || [[%s]] || %s\n', rowspan, songPageNames[song], song, head.album, head.type)
for _, row in ipairs(rows) do
for _, row in ipairs(rows) do
text = text ..
text = text ..

Navigation menu